]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodelrolesupdater.cpp
Add setting also hide application/x-trash files when hiding hidden files
[dolphin.git] / src / kitemviews / kfileitemmodelrolesupdater.cpp
index 06500b45dd168f9a2ddee88a5af07a3fe626f807..a136dab388153109998b8a1296573e9134c5131d 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <KConfig>
 #include <KConfigGroup>
+#include <KIO/ListJob>
 #include <KIO/PreviewJob>
 #include <KIconLoader>
 #include <KJobWidgets>
@@ -1306,8 +1307,6 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
             url = QUrl::fromLocalFile(item.localPath());
         }
 
-        data.insert("isExpandable", false);
-        data.insert("count", 0);
         data.insert("size", -2); // invalid size, -1 means size unknown
 
         disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
@@ -1315,7 +1314,11 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
         connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
 
         auto listJob = KIO::listDir(url, KIO::HideProgressInfo);
-        QObject::connect(listJob, &KIO::ListJob::entries, this, [this, index](const KJob * /*job*/, const KIO::UDSEntryList &list) {
+        QObject::connect(listJob, &KIO::ListJob::entries, this, [this, item](const KJob * /*job*/, const KIO::UDSEntryList &list) {
+            int index = m_model->index(item);
+            if (index < 0) {
+                return;
+            }
             auto data = m_model->data(index);
             int origCount = data.value("count").toInt();
             int entryCount = origCount;
@@ -1344,6 +1347,9 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
                 disconnect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
                 m_model->setData(index, data);
                 connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
+                if (m_model->sortRole() == "size") {
+                    m_model->scheduleResortAllItems();
+                }
             }
         });
         return;