X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f3537f5b5fb0fd107a2e299aaeca3524cf1dd792..e6ea3ab4c41dcc115143a237aafd3a1152849433:/src/kitemviews/private/kdirectorycontentscounter.h diff --git a/src/kitemviews/private/kdirectorycontentscounter.h b/src/kitemviews/private/kdirectorycontentscounter.h index 425c3632a..0c900ec64 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.h +++ b/src/kitemviews/private/kdirectorycontentscounter.h @@ -23,8 +23,9 @@ #include "kdirectorycontentscounterworker.h" -#include #include +#include +#include class KDirWatch; class KFileItemModel; @@ -35,8 +36,8 @@ class KDirectoryContentsCounter : public QObject Q_OBJECT public: - explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = 0); - ~KDirectoryContentsCounter(); + explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = nullptr); + ~KDirectoryContentsCounter() override; /** * Requests the number of items inside the directory \a path. The actual @@ -45,28 +46,23 @@ public: * * The directory \a path is watched for changes, and the signal is emitted * again if a change occurs. - */ - void addDirectory(const QString& path); - - /** - * In contrast to \a addDirectory, this function counts the items inside - * the directory \a path synchronously and returns the result. * - * The directory is watched for changes, and the signal \a result is - * emitted if a change occurs. + * Uses a cache internally to speed up first result, + * but emit again result when the cache was updated */ - int countDirectoryContentsSynchronously(const QString& path); + void scanDirectory(const QString& path); signals: /** - * Signals that the directory \a path contains \a count items. + * Signals that the directory \a path contains \a count items of size \a + * Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit */ - void result(const QString& path, int count); + void result(const QString& path, int count, long size); void requestDirectoryContentsCount(const QString& path, KDirectoryContentsCounterWorker::Options options); private slots: - void slotResult(const QString& path, int count); + void slotResult(const QString& path, int count, long size); void slotDirWatchDirty(const QString& path); void slotItemsRemoved(); @@ -78,7 +74,8 @@ private: QQueue m_queue; - QThread* m_workerThread; + static QThread* m_workerThread; + KDirectoryContentsCounterWorker* m_worker; bool m_workerIsBusy; @@ -87,4 +84,4 @@ private: // to get all watched directories. }; -#endif \ No newline at end of file +#endif