From e4473d8fd500cd8af2f5131a0a22deb4697846d7 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 27 Dec 2020 18:43:30 +0100 Subject: Restrict collapsible separators to sort-by-priority. --- src/mainwindow.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/mainwindow.cpp') 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& 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()); } -- cgit v1.3.1