summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLostDragonist <lost.dragonist@gmail.com>2018-12-23 00:55:54 -0600
committerLostDragonist <lost.dragonist@gmail.com>2018-12-23 00:57:28 -0600
commitfcff329c1e5529bbceaf46592c30cd87dc6a6f44 (patch)
tree03ff51cf02725839c495fcb650f27ef601bfbb9d
parent2d79e37e59cf9c38b08250baa1f0e6e7f7b70545 (diff)
Add sorting for the notes column
-rw-r--r--src/modlistsortproxy.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index b5f1ee5c..833e16c3 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -214,9 +214,25 @@ bool ModListSortProxy::lessThan(const QModelIndex &left,
lt = comp < 0;
}
} break;
+ case ModList::COL_NOTES: {
+ QString leftComments = leftMod->comments();
+ QString rightComments = rightMod->comments();
+ if (leftComments != rightComments) {
+ if (leftComments.isEmpty()) {
+ lt = sortOrder() == Qt::DescendingOrder;
+ } else if (rightComments.isEmpty()) {
+ lt = sortOrder() == Qt::AscendingOrder;
+ } else {
+ lt = leftComments < rightComments;
+ }
+ }
+ } break;
case ModList::COL_PRIORITY: {
// nop, already compared by priority
} break;
+ default: {
+ qWarning() << "Sorting is not defined for column " << left.column();
+ } break;
}
return lt;
}