From c46432cc2ef4a108557c1405a0f9c01616bc176e Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 27 Dec 2020 20:01:41 +0100 Subject: Move common code to method. --- src/mainwindow.cpp | 27 +++++++++++++-------------- src/mainwindow.h | 1 + 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src') 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& 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 -- cgit v1.3.1