]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodelrolesupdater.h
Count the items inside directories in another thread
[dolphin.git] / src / kitemviews / kfileitemmodelrolesupdater.h
index aa47f175628db1a9b24487a487ada7ef0a271642..fced44a85da6be095899c01c7db50253a5b0e082 100644 (file)
@@ -32,7 +32,7 @@
 #include <QSize>
 #include <QStringList>
 
-class KDirWatch;
+class KDirectoryContentsCounter;
 class KFileItemModel;
 class KJob;
 class QPixmap;
@@ -43,6 +43,10 @@ class QTimer;
     {
         class ResourceWatcher;
         class Resource;
+        namespace Types
+        {
+            class Property;
+        }
     }
 #else
     // Required for the slot applyChangedNepomukRoles() that
@@ -50,6 +54,10 @@ class QTimer;
     namespace Nepomuk2
     {
         class Resource;
+        namespace Types
+        {
+            class Property;
+        }
     }
 #endif
 
@@ -208,14 +216,9 @@ private slots:
      */
     void resolveRecentlyChangedItems();
 
-    void applyChangedNepomukRoles(const Nepomuk2::Resource& resource);
+    void applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property);
 
-    /**
-     * Is invoked if a directory watched by KDirWatch got dirty. Updates
-     * the "isExpandable"- and "size"-roles of the item that matches to
-     * the given path.
-     */
-    void slotDirWatchDirty(const QString& path);
+    void slotDirectoryContentsCountReceived(const QString& path, int count);
 
 private:
     /**
@@ -224,13 +227,22 @@ private:
     void startUpdating();
 
     /**
-     * Creates previews for the items starting from the first item of the
-     * given list.
+     * Loads the icons for the visible items. After 200 ms, the function
+     * stops determining mime types and only loads preliminary icons.
+     * This is a compromise that prevents that
+     * (a) the GUI is blocked for more than 200 ms, and
+     * (b) "unknown" icons could be shown in the view.
+     */
+    void updateVisibleIcons();
+
+    /**
+     * Creates previews for the items starting from the first item in
+     * m_pendingPreviewItems.
      * @see slotGotPreview()
      * @see slotPreviewFailed()
      * @see slotPreviewJobFinished()
      */
-    void startPreviewJob(const KFileItemList items);
+    void startPreviewJob();
 
     /**
      * Ensures that icons, previews, and other roles are determined for any
@@ -250,7 +262,7 @@ private:
         ResolveAll
     };
     bool applyResolvedRoles(const KFileItem& item, ResolveHint hint);
-    QHash<QByteArray, QVariant> rolesData(const KFileItem& item) const;
+    QHash<QByteArray, QVariant> rolesData(const KFileItem& item);
 
     /**
      * @return The number of items of the path \a path.
@@ -311,11 +323,6 @@ private:
     // Items for which the sort role still has to be determined.
     QSet<KFileItem> m_pendingSortRoleItems;
 
-    // While the sort role is being resolved, we also keep the indexes
-    // in a sorted list. The reason is that this enables us to determine
-    // both the sort role and the icon for the visible items first.
-    QList<int> m_pendingSortRoleIndexes;
-
     // Indexes of items which still have to be handled by
     // resolveNextPendingRoles().
     QList<int> m_pendingIndexes;
@@ -337,9 +344,8 @@ private:
     // Items which have not been changed repeatedly recently.
     QSet<KFileItem> m_changedItems;
 
-    KDirWatch* m_dirWatcher;
-    mutable QSet<QString> m_watchedDirs; // Required as sadly KDirWatch does not offer a getter method
-                                         // to get all watched directories.
+    KDirectoryContentsCounter* m_directoryContentsCounter;
+
 #ifdef HAVE_NEPOMUK
     Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher;
     mutable QHash<QUrl, KUrl> m_nepomukUriItems;