]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kfileitemmodelrolesupdater.h
[Details mode] Allow to fill the column size of directories with actual size
[dolphin.git] / src / kitemviews / kfileitemmodelrolesupdater.h
index 605c36f81af3943d5a7ffb22c739c5c03063e910..e21cd30dfe0672b358fd012467c9d73fc4b0399e 100644 (file)
 #ifndef KFILEITEMMODELROLESUPDATER_H
 #define KFILEITEMMODELROLESUPDATER_H
 
-#include <config-nepomuk.h>
+#include "dolphin_export.h"
+#include "kitemviews/kitemmodelbase.h"
 
 #include <KFileItem>
-#include <kitemviews/kitemmodelbase.h>
-
-#include <libdolphin_export.h>
+#include <config-baloo.h>
 
 #include <QObject>
 #include <QSet>
 #include <QSize>
 #include <QStringList>
 
-class KDirWatch;
+class KDirectoryContentsCounter;
 class KFileItemModel;
-class KJob;
 class QPixmap;
 class QTimer;
+class KOverlayIconPlugin;
 
-#ifdef HAVE_NEPOMUK
-    namespace Nepomuk2
-    {
-        class ResourceWatcher;
-        class Resource;
-    }
-#else
-    // Required for the slot applyChangedNepomukRoles() that
-    // cannot be ifdefined due to moc.
-    namespace Nepomuk2
+namespace KIO {
+    class PreviewJob;
+}
+
+#ifdef HAVE_BALOO
+    namespace Baloo
     {
-        class Resource;
+        class FileMonitor;
     }
+    #include <Baloo/IndexerConfig>
 #endif
 
 /**
@@ -92,13 +88,13 @@ class QTimer;
  * 3.   Finally, the entire process is repeated for any items that might have
  *      changed in the mean time.
  */
-class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject
+class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject
 {
     Q_OBJECT
 
 public:
-    explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = 0);
-    virtual ~KFileItemModelRolesUpdater();
+    explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = nullptr);
+    ~KFileItemModelRolesUpdater() override;
 
     void setIconSize(const QSize& size);
     QSize iconSize() const;
@@ -161,7 +157,7 @@ public:
 private slots:
     void slotItemsInserted(const KItemRangeList& itemRanges);
     void slotItemsRemoved(const KItemRangeList& itemRanges);
-    void slotItemsMoved(const KItemRange& itemRange, QList<int> movedToIndexes);
+    void slotItemsMoved(const KItemRange& itemRange, const QList<int> &movedToIndexes);
     void slotItemsChanged(const KItemRangeList& itemRanges,
                           const QSet<QByteArray>& roles);
     void slotSortRoleChanged(const QByteArray& current,
@@ -187,6 +183,11 @@ private slots:
      */
     void slotPreviewJobFinished();
 
+    /**
+     * Is invoked when one of the KOverlayIconPlugin emit the signal that an overlay has changed
+     */
+    void slotOverlaysChanged(const QUrl& url, const QStringList&);
+
     /**
      * Resolves the sort role of the next item in m_pendingSortRole, applies it
      * to the model, and invokes itself if there are any pending items left. If
@@ -208,14 +209,10 @@ private slots:
      */
     void resolveRecentlyChangedItems();
 
-    void applyChangedNepomukRoles(const Nepomuk2::Resource& resource);
+    void applyChangedBalooRoles(const QString& file);
+    void applyChangedBalooRolesForItem(const KFileItem& file);
 
-    /**
-     * 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, long size);
 
 private:
     /**
@@ -258,8 +255,8 @@ private:
         ResolveFast,
         ResolveAll
     };
-    bool applyResolvedRoles(const KFileItem& item, ResolveHint hint);
-    QHash<QByteArray, QVariant> rolesData(const KFileItem& item) const;
+    bool applyResolvedRoles(int index, ResolveHint hint);
+    QHash<QByteArray, QVariant> rolesData(const KFileItem& item);
 
     /**
      * @return The number of items of the path \a path.
@@ -328,7 +325,7 @@ private:
     // A new preview job will be started from them once the first one finishes.
     KFileItemList m_pendingPreviewItems;
 
-    KJob* m_previewJob;
+    KIO::PreviewJob* m_previewJob;
 
     // When downloading or copying large files, the slot slotItemsChanged()
     // will be called periodically within a quite short delay. To prevent
@@ -341,12 +338,13 @@ 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.
-#ifdef HAVE_NEPOMUK
-    Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher;
-    mutable QHash<QUrl, KUrl> m_nepomukUriItems;
+    KDirectoryContentsCounter* m_directoryContentsCounter;
+
+    QList<KOverlayIconPlugin*> m_overlayIconsPlugin;
+
+#ifdef HAVE_BALOO
+    Baloo::FileMonitor* m_balooFileMonitor;
+    Baloo::IndexerConfig m_balooConfig;
 #endif
 };