summaryrefslogtreecommitdiff
path: root/src/modlistbypriorityproxy.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-30 00:28:48 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:16 +0100
commit373b659dcbcac5dfc081ca7fa5f78788166a4e39 (patch)
treec3ed9de9b64e2a875e4d6cde6d420d05cb743028 /src/modlistbypriorityproxy.cpp
parent095348c16f58d757f2d9549d06fd12d5ed14a1d2 (diff)
Fix and move stuff around.
- Move selection-related code from ModList to ModListView. - Fix move-selection for multi-selection. - Fix refresh of mod list on toggle selection.
Diffstat (limited to 'src/modlistbypriorityproxy.cpp')
-rw-r--r--src/modlistbypriorityproxy.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/modlistbypriorityproxy.cpp b/src/modlistbypriorityproxy.cpp
index f898b85b..dc16d8ea 100644
--- a/src/modlistbypriorityproxy.cpp
+++ b/src/modlistbypriorityproxy.cpp
@@ -23,6 +23,7 @@ void ModListByPriorityProxy::setSourceModel(QAbstractItemModel* model)
connect(sourceModel(), &QAbstractItemModel::layoutChanged, this, [this]() { buildTree(); }, Qt::UniqueConnection);
connect(sourceModel(), &QAbstractItemModel::rowsRemoved, this, [this]() { buildTree(); }, Qt::UniqueConnection);
connect(sourceModel(), &QAbstractItemModel::modelReset, this, &ModListByPriorityProxy::buildTree, Qt::UniqueConnection);
+ connect(sourceModel(), &QAbstractItemModel::dataChanged, this, &ModListByPriorityProxy::modelDataChanged, Qt::UniqueConnection);
refresh();
}
}
@@ -93,6 +94,22 @@ void ModListByPriorityProxy::expandItems(const QModelIndex& index) const
}
}
+void ModListByPriorityProxy::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
+{
+ QModelIndex proxyTopLeft = mapFromSource(topLeft);
+ if (!proxyTopLeft.isValid()) {
+ return;
+ }
+
+ if (topLeft == bottomRight) {
+ emit dataChanged(proxyTopLeft, proxyTopLeft);
+ }
+ else {
+ QModelIndex proxyBottomRight = mapFromSource(bottomRight);
+ emit dataChanged(proxyTopLeft, proxyBottomRight);
+ }
+}
+
QModelIndex ModListByPriorityProxy::mapFromSource(const QModelIndex& sourceIndex) const
{
if (!sourceIndex.isValid()) {