]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodel.cpp
KFileItemModel: Allow to group files and folder together
[dolphin.git] / src / kitemviews / kfileitemmodel.cpp
index a6c5e48ec7b1e44cbaa61b78f4a9d07e47388333..9441bc8714c4ad6cd020b90b782dec060c2a9f41 100644 (file)
@@ -2026,16 +2026,24 @@ QList<QPair<int, QVariant> > KFileItemModel::sizeRoleGroups() const
         }
 
         const KFileItem& item = m_itemData.at(i)->item;
-        const KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
+        KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
         QString newGroupValue;
         if (!item.isNull() && item.isDir()) {
-            newGroupValue = i18nc("@title:group Size", "Folders");
-        } else if (fileSize < 5 * 1024 * 1024) {
-            newGroupValue = i18nc("@title:group Size", "Small");
-        } else if (fileSize < 10 * 1024 * 1024) {
-            newGroupValue = i18nc("@title:group Size", "Medium");
-        } else {
-            newGroupValue = i18nc("@title:group Size", "Big");
+            if (DetailsModeSettings::directorySizeCount() || m_sortDirsFirst) {
+                newGroupValue = i18nc("@title:group Size", "Folders");
+            } else {
+                fileSize = m_itemData.at(i)->values.value("size").toULongLong();
+            }
+        }
+
+        if (newGroupValue.isEmpty()) {
+            if (fileSize < 5 * 1024 * 1024) { // < 5 MB
+                newGroupValue = i18nc("@title:group Size", "Small");
+            } else if (fileSize < 10 * 1024 * 1024) { // < 10 MB
+                newGroupValue = i18nc("@title:group Size", "Medium");
+            } else {
+                newGroupValue = i18nc("@title:group Size", "Big");
+            }
         }
 
         if (newGroupValue != groupValue) {