]> cloud.milkyroute.net Git - dolphin.git/commitdiff
kfileitemmodel: sortRoleCompare: allow to sort by access time.
authorMéven Car <meven29@gmail.com>
Mon, 30 May 2022 21:26:09 +0000 (23:26 +0200)
committerMéven Car <meven.car@kdemail.net>
Tue, 31 May 2022 12:21:04 +0000 (12:21 +0000)
We had all sorts of weird behavior when sorting by access time.
The comparison was simply missing in sortRoleCompare.

src/kitemviews/kfileitemmodel.cpp

index 0f5cffed126830d4e78dfe57b97460174ef9baf6..b1a70f6fa4e87f6f76d22818e51a75525c35345f 100644 (file)
@@ -2067,6 +2067,17 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
         break;
     }
 
+    case AccessTimeRole: {
+        const long long dateTimeA = itemA.entry().numberValue(KIO::UDSEntry::UDS_ACCESS_TIME, -1);
+        const long long dateTimeB = itemB.entry().numberValue(KIO::UDSEntry::UDS_ACCESS_TIME, -1);
+        if (dateTimeA < dateTimeB) {
+            return -1;
+        } else if (dateTimeA > dateTimeB) {
+            return +1;
+        }
+        break;
+    }
+
     case CreationTimeRole: {
         const long long dateTimeA = itemA.entry().numberValue(KIO::UDSEntry::UDS_CREATION_TIME, -1);
         const long long dateTimeB = itemB.entry().numberValue(KIO::UDSEntry::UDS_CREATION_TIME, -1);