2 * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2013 Frank Reininghaus <frank78ac@googlemail.com>
5 * SPDX-License-Identifier: GPL-2.0-or-later
8 #ifndef KDIRECTORYCONTENTSCOUNTER_H
9 #define KDIRECTORYCONTENTSCOUNTER_H
11 #include "kdirectorycontentscounterworker.h"
20 class KDirectoryContentsCounter
: public QObject
25 explicit KDirectoryContentsCounter(KFileItemModel
* model
, QObject
* parent
= nullptr);
26 ~KDirectoryContentsCounter() override
;
29 * Requests the number of items inside the directory \a path. The actual
30 * counting is done asynchronously, and the result is announced via the
33 * The directory \a path is watched for changes, and the signal is emitted
34 * again if a change occurs.
36 * Uses a cache internally to speed up first result,
37 * but emit again result when the cache was updated
39 void scanDirectory(const QString
& path
);
43 * Signals that the directory \a path contains \a count items of size \a
44 * Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit
46 void result(const QString
& path
, int count
, long size
);
48 void requestDirectoryContentsCount(const QString
& path
, KDirectoryContentsCounterWorker::Options options
);
51 void slotResult(const QString
& path
, int count
, long size
);
52 void slotDirWatchDirty(const QString
& path
);
53 void slotItemsRemoved();
56 void startWorker(const QString
& path
);
59 KFileItemModel
* m_model
;
61 // Used as FIFO queues.
62 std::list
<QString
> m_priorityQueue
;
63 std::list
<QString
> m_queue
;
65 static QThread
* m_workerThread
;
67 KDirectoryContentsCounterWorker
* m_worker
;
70 KDirWatch
* m_dirWatcher
;
71 QSet
<QString
> m_watchedDirs
; // Required as sadly KDirWatch does not offer a getter method
72 // to get all watched directories.