diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-27 18:43:30 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:15 +0100 |
| commit | e4473d8fd500cd8af2f5131a0a22deb4697846d7 (patch) | |
| tree | df18f7783b3ebec3e5b4559ebe96018f86035df6 /src | |
| parent | 6444dd7f5c3596181a50fb408c012e3ed71fc283 (diff) | |
Restrict collapsible separators to sort-by-priority.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5fe1b39d..173dc53d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -557,8 +557,19 @@ void MainWindow::setupModList() ui->modList->setModel(m_ModListSortProxy); m_ModListByPriorityProxy->setSourceModel(m_OrganizerCore.modList()); - m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); - emit m_OrganizerCore.modList()->layoutChanged(); + + 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->setSourceModel(m_ModListByPriorityProxy); + emit m_OrganizerCore.modList()->layoutChanged(); + } + else { + m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); + } + } + }); ui->modList->sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder); @@ -5953,8 +5964,13 @@ 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 { - m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); - emit m_OrganizerCore.modList()->layoutChanged(); + if (m_ModListSortProxy->sortColumn() == ModList::COL_PRIORITY) { + m_ModListSortProxy->setSourceModel(m_ModListByPriorityProxy); + emit m_OrganizerCore.modList()->layoutChanged(); + } + else { + m_ModListSortProxy->setSourceModel(m_OrganizerCore.modList()); + } } modFilterActive(m_ModListSortProxy->isFilterActive()); } |
