]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodelrolesupdater.cpp
"Group by" exists, group sorting rule is separate from sorting rule. Very WIP and...
[dolphin.git] / src / kitemviews / kfileitemmodelrolesupdater.cpp
index 070b958650e81896e22bbd3c2046d51fab18429f..0ff431ac99a5366120d6fafb568ee52d12209438 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <KConfig>
 #include <KConfigGroup>
+#include <KIO/ListJob>
 #include <KIO/PreviewJob>
 #include <KIconLoader>
 #include <KJobWidgets>
@@ -1287,11 +1288,11 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
 
 void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &item, int index)
 {
-    if (!item.isLocalFile()) {
+    if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::None || !item.isLocalFile()) {
         return;
     }
 
-    if (ContentDisplaySettings::directorySizeCount() || item.isSlow()) {
+    if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount || item.isSlow()) {
         // fastpath no recursion necessary
 
         auto data = m_model->data(index);
@@ -1337,18 +1338,22 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
                 ++entryCount;
             }
 
-            // count has changed
-            if (origCount < entryCount) {
-                QHash<QByteArray, QVariant> data;
-                data.insert("isExpandable", entryCount > 0);
-                data.insert("count", entryCount);
+            QHash<QByteArray, QVariant> newData;
+            QVariant expandable = data.value("isExpandable");
+            if (expandable.isNull() || expandable.toBool() != (entryCount > 0)) {
+                // if expandable has changed
+                newData.insert("isExpandable", entryCount > 0);
+            }
 
+            if (origCount != entryCount) {
+                // count has changed
+                newData.insert("count", entryCount);
+            }
+
+            if (!newData.isEmpty()) {
                 disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
-                m_model->setData(index, data);
+                m_model->setData(index, newData);
                 connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
-                if (m_model->sortRole() == "size") {
-                    m_model->scheduleResortAllItems();
-                }
             }
         });
         return;