void CtrlSortFilter::actSortType2( int i_type) { if( *m_sorttype2 == i_type ) return; *m_sorttype2 = i_type; selLabel(); emit sortTypeChanged(); }
void CommandsModel::sortCommands(CommandsModel::SortType type, bool isResort) { QList<ShellCommand*> temp; bool newValue = m_sort_type != type; if(newValue) { m_sort_type = type; emit sortTypeChanged(); } if(newValue || isResort) { beginResetModel(); switch(type) { case ByLeastRuns: this->sortCommandsByLeastRuns(); break; case ByMostRuns: this->sortCommandsByMostRuns(); break; case ByName: this->sortCommandsByName(); break; case ByNameReverse: this->sortCommandsByReverseName(); break; case ByNewestCreated: this->sortCommandsByNewestCreated(); break; case ByOldestCreated: this->sortCommandsByOldestCreated(); break; case ByNewestRun: this->sortCommandsByNewestRun(); break; case ByOldestRun: this->sortCommandsByOldestRun(); break; case ByIsRunning: this->sortCommandsByIsRunning(); break; default: break; } //hackish way to sort, not optimal.. later change to Sorting proxy model! //remove all items and push them into a temp list. // while(!m_commands.empty()) // { // // beginRemoveRows(QModelIndex(), 0, 0); // temp.push_front(m_commands.at(0)); // m_commands.pop_front(); // // endRemoveRows(); // } // //insert them back to the model in the new sorting order // for(int i = 0; i < temp.count(); ++i) // { // this->insertOnReset(temp.at(i)); // } endResetModel(); } }