summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 01:35:02 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:15 +0100
commitd979e60aed14b368ac9badf0b88c06f61c17893b (patch)
treee9b3357349da605308014bae9a28f0836997b655 /src/modlist.cpp
parent7a65cc64885724c409f2deadaac925c66a9b00ee (diff)
Fix automatic refresh of the collapsible separator proxy.
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 8c14d509..1f2f1171 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -1493,14 +1493,33 @@ QString ModList::getColumnToolTip(int column) const
}
}
+QModelIndex ModList::indexToProxy(QAbstractItemModel* proxyModel, const QModelIndex& index)
+{
+ if (!proxyModel) {
+ return QModelIndex();
+ }
+
+ if (proxyModel == this) {
+ return index;
+ }
+
+ if (auto* proxy = qobject_cast<QAbstractProxyModel*>(proxyModel)) {
+ return proxy->mapFromSource(indexToProxy(proxy->sourceModel(), index));
+ }
+
+ return QModelIndex();
+}
bool ModList::moveSelection(QAbstractItemView *itemView, int direction)
{
QItemSelectionModel *selectionModel = itemView->selectionModel();
+ int currentIndex = itemView->currentIndex().data(IndexRole).toInt();
const QAbstractProxyModel *proxyModel = qobject_cast<const QAbstractProxyModel*>(selectionModel->model());
const QSortFilterProxyModel *filterModel = nullptr;
+ emit layoutAboutToBeChanged();
+
while ((filterModel == nullptr) && (proxyModel != nullptr)) {
filterModel = qobject_cast<const QSortFilterProxyModel*>(proxyModel);
if (filterModel == nullptr) {
@@ -1534,7 +1553,18 @@ bool ModList::moveSelection(QAbstractItemView *itemView, int direction)
}
}
+ emit layoutChanged();
+
emit modPrioritiesChanged(allIndex);
+
+ // reset the selection and the index
+ itemView->setCurrentIndex(indexToProxy(itemView->model(), index(currentIndex, 0)));
+ for (auto idx : allIndex) {
+ itemView->selectionModel()->select(
+ indexToProxy(itemView->selectionModel()->model(), index(idx, 0)),
+ QItemSelectionModel::Select | QItemSelectionModel::Rows);
+ }
+
return true;
}