┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private/kdirectorycontentscounterworker.h
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2023-05-26 15:10:09 +0000
committerMéven Car <[email protected]>2023-05-26 15:10:09 +0000
commita1c5c5cf81b5d1f6b7a0aa10b8a981cb70c5b26c (patch)
tree0fcfce01dcef32b1b70b084e9719cf7d9c26418d /src/kitemviews/private/kdirectorycontentscounterworker.h
parentab13c8881dafbe5beefef0db5891ce9f731ef489 (diff)
KDirectoryContentsCounter: show intermediate dir size counting results, improve stopping, improve data caching
Two user visible changes: * we can see the dir size changing as it is updated. * This makes the file counting a lot more reactive, when changing directories for instance. `KDirectoryContentsCounterWorker::walkDir` is not recursive anymore. The cache is now shared and only a single thread is used to count size recursively.
Diffstat (limited to 'src/kitemviews/private/kdirectorycontentscounterworker.h')
-rw-r--r--src/kitemviews/private/kdirectorycontentscounterworker.h33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/kitemviews/private/kdirectorycontentscounterworker.h b/src/kitemviews/private/kdirectorycontentscounterworker.h
index 5266960cd..077df9f69 100644
--- a/src/kitemviews/private/kdirectorycontentscounterworker.h
+++ b/src/kitemviews/private/kdirectorycontentscounterworker.h
@@ -17,32 +17,20 @@ class KDirectoryContentsCounterWorker : public QObject
Q_OBJECT
public:
- enum Option { NoOptions = 0x0, CountHiddenFiles = 0x1, CountDirectoriesOnly = 0x2 };
+ enum Option { NoOptions = 0x0, CountHiddenFiles = 0x1 };
Q_DECLARE_FLAGS(Options, Option)
- struct CountResult {
- /// number of elements in the directory
- int count;
- /// Recursive sum of the size of the directory content files and folders
- /// Calculation depends on DetailsModeSettings::recursiveDirectorySizeLimit
- long size;
- };
-
explicit KDirectoryContentsCounterWorker(QObject *parent = nullptr);
- /**
- * Counts the items inside the directory \a path using the options
- * \a options.
- *
- * @return The number of items.
- */
- CountResult subItemsCount(const QString &path, Options options);
-
+ bool stopping() const;
+ QString scannedPath() const;
Q_SIGNALS:
/**
* Signals that the directory \a path contains \a count items and optionally the size of its content.
*/
- void result(const QString &path, int count, long size);
+ void result(const QString &path, int count, long long size);
+ void intermediateResult(const QString &path, int count, long long size);
+ void finished();
public Q_SLOTS:
/**
@@ -52,16 +40,17 @@ public Q_SLOTS:
// Note that the full type name KDirectoryContentsCounterWorker::Options
// is needed here. Just using 'Options' is OK for the compiler, but
// confuses moc.
- void countDirectoryContents(const QString &path, KDirectoryContentsCounterWorker::Options options);
+ void countDirectoryContents(const QString &path, KDirectoryContentsCounterWorker::Options options, int maxRecursiveLevel);
void stop();
private:
#ifndef Q_OS_WIN
- KDirectoryContentsCounterWorker::CountResult
- walkDir(const QString &dirPath, const bool countHiddenFiles, const bool countDirectoriesOnly, const uint allowedRecursiveLevel);
+ void walkDir(const QString &dirPath, bool countHiddenFiles, uint allowedRecursiveLevel);
#endif
- bool m_stopping = false;
+ QString m_scannedPath;
+
+ std::atomic<bool> m_stopping = false;
};
Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options)