From ba930ddb3635fe2d94d727e72aaf261513b28060 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Sun, 12 Feb 2023 11:21:53 +0000 Subject: Optimize Directory size counting Two changes: * Prioritise size counting for visible path * stop the worker when switching dirs --- src/kitemviews/private/kdirectorycontentscounter.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/kitemviews/private/kdirectorycontentscounter.h') diff --git a/src/kitemviews/private/kdirectorycontentscounter.h b/src/kitemviews/private/kdirectorycontentscounter.h index f74565b73..9a5e4a86b 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.h +++ b/src/kitemviews/private/kdirectorycontentscounter.h @@ -21,6 +21,8 @@ class KDirectoryContentsCounter : public QObject Q_OBJECT public: + enum PathCountPriority { Normal, High }; + explicit KDirectoryContentsCounter(KFileItemModel *model, QObject *parent = nullptr); ~KDirectoryContentsCounter() override; @@ -35,7 +37,12 @@ public: * Uses a cache internally to speed up first result, * but emit again result when the cache was updated */ - void scanDirectory(const QString &path); + void scanDirectory(const QString &path, PathCountPriority priority); + + /** + * Stops the work until new input is passed + */ + void stopWorker(); Q_SIGNALS: /** @@ -46,14 +53,13 @@ Q_SIGNALS: void requestDirectoryContentsCount(const QString &path, KDirectoryContentsCounterWorker::Options options); + void stop(); + private Q_SLOTS: void slotResult(const QString &path, int count, long size); void slotDirWatchDirty(const QString &path); void slotItemsRemoved(); -private: - void startWorker(const QString &path); - private: KFileItemModel *m_model; -- cgit v1.3.1