diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-27 20:01:41 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:15 +0100 |
| commit | c46432cc2ef4a108557c1405a0f9c01616bc176e (patch) | |
| tree | aa8ccbca7d4ac55de3642185b551f75c1e68c5b5 /src | |
| parent | 14bdef9ea68ce1dd8945113f1dece595adf4f013 (diff) | |
Move common code to method.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 27 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7f9e81fc..74f3fd62 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -546,6 +546,17 @@ MainWindow::MainWindow(Settings &settings ui->statusBar->updateNormalMessage(m_OrganizerCore); } +void MainWindow::updateModListByPriorityProxy() +{ + if (m_ModListSortProxy->sortColumn() == ModList::COL_PRIORITY && m_ModListSortProxy->sortOrder() == Qt::AscendingOrder) { + m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); + emit m_OrganizerCore.modList()->layoutChanged(); + } + else { + m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); + } +} + void MainWindow::setupModList() { m_ModListByPriorityProxy = new ModListByPriorityProxy(m_OrganizerCore.currentProfile(), &m_OrganizerCore); @@ -561,13 +572,7 @@ void MainWindow::setupModList() connect(m_ModListSortProxy, &QAbstractItemModel::layoutAboutToBeChanged, this, [this](const QList<QPersistentModelIndex>& parents, QAbstractItemModel::LayoutChangeHint hint) { if (hint == QAbstractItemModel::VerticalSortHint) { - if (m_ModListSortProxy->sortColumn() == ModList::COL_PRIORITY && m_ModListSortProxy->sortOrder() == Qt::AscendingOrder) { - m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); - emit m_OrganizerCore.modList()->layoutChanged(); - } - else { - m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); - } + updateModListByPriorityProxy(); } }); @@ -5968,13 +5973,7 @@ void MainWindow::on_groupCombo_currentIndexChanged(int index) connect(ui->modList, SIGNAL(collapsed(QModelIndex)), newModel, SLOT(collapsed(QModelIndex))); connect(newModel, SIGNAL(expandItem(QModelIndex)), this, SLOT(expandModList(QModelIndex))); } else { - if (m_ModListSortProxy->sortColumn() == ModList::COL_PRIORITY && m_ModListSortProxy->sortOrder() == Qt::AscendingOrder) { - m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); - emit m_OrganizerCore.modList()->layoutChanged(); - } - else { - m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); - } + updateModListByPriorityProxy(); } modFilterActive(m_ModListSortProxy->isFilterActive()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 19a1b179..ccfd4881 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -608,6 +608,7 @@ private slots: // ui slots void storeSettings(); void readSettings(); void setupModList(); + void updateModListByPriorityProxy(); }; #endif // MAINWINDOW_H |
