summaryrefslogtreecommitdiff
path: root/src/modlistsortproxy.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 01:01:12 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:15 +0100
commit54ea4445b00301fe30eb346eb10f83e55e6d0ea0 (patch)
treeeae5825d1e7e8a739cd8d1c64969c1c2ac105976 /src/modlistsortproxy.cpp
parent64f771bc1f974c60c508a65b7a0d0e412a27fb04 (diff)
Fix sorting of backups when using collapsible separators.
Diffstat (limited to 'src/modlistsortproxy.cpp')
-rw-r--r--src/modlistsortproxy.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index cf82ca74..422fa044 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -133,12 +133,17 @@ bool ModListSortProxy::lessThan(const QModelIndex &left,
const QModelIndex &right) const
{
if (sourceModel()->hasChildren(left) || sourceModel()->hasChildren(right)) {
- return QSortFilterProxyModel::lessThan(left, right);
+ // when sorting by priority, we do not want to use the parent lessThan because
+ // it uses the display role which can be inconsistent (e.g. for backups)
+ if (sortColumn() != ModList::COL_PRIORITY) {
+ return QSortFilterProxyModel::lessThan(left, right);
+ }
}
bool lOk, rOk;
- int leftIndex = left.data(Qt::UserRole + 1).toInt(&lOk);
- int rightIndex = right.data(Qt::UserRole + 1).toInt(&rOk);
+ int leftIndex = left.data(ModList::IndexRole).toInt(&lOk);
+ int rightIndex = right.data(ModList::IndexRole).toInt(&rOk);
+
if (!lOk || !rOk) {
return false;
}