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"
19 class KDirectoryContentsCounter
: public QObject
24 explicit KDirectoryContentsCounter(KFileItemModel
*model
, QObject
*parent
= nullptr);
25 ~KDirectoryContentsCounter() override
;
28 * Requests the number of items inside the directory \a path. The actual
29 * counting is done asynchronously, and the result is announced via the
32 * The directory \a path is watched for changes, and the signal is emitted
33 * again if a change occurs.
35 * Uses a cache internally to speed up first result,
36 * but emit again result when the cache was updated
38 void scanDirectory(const QString
&path
);
42 * Signals that the directory \a path contains \a count items of size \a
43 * Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit
45 void result(const QString
&path
, int count
, long size
);
47 void requestDirectoryContentsCount(const QString
&path
, KDirectoryContentsCounterWorker::Options options
);
50 void slotResult(const QString
&path
, int count
, long size
);
51 void slotDirWatchDirty(const QString
&path
);
52 void slotItemsRemoved();
55 void startWorker(const QString
&path
);
58 KFileItemModel
*m_model
;
60 // Used as FIFO queues.
61 std::list
<QString
> m_priorityQueue
;
62 std::list
<QString
> m_queue
;
64 static QThread
*m_workerThread
;
66 KDirectoryContentsCounterWorker
*m_worker
;
69 KDirWatch
*m_dirWatcher
;
70 QSet
<QString
> m_watchedDirs
; // Required as sadly KDirWatch does not offer a getter method
71 // to get all watched directories.