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 enum PathCountPriority
{ Normal
, High
};
26 explicit KDirectoryContentsCounter(KFileItemModel
*model
, QObject
*parent
= nullptr);
27 ~KDirectoryContentsCounter() override
;
30 * Requests the number of items inside the directory \a path. The actual
31 * counting is done asynchronously, and the result is announced via the
34 * The directory \a path is watched for changes, and the signal is emitted
35 * again if a change occurs.
37 * Uses a cache internally to speed up first result,
38 * but emit again result when the cache was updated
40 void scanDirectory(const QString
&path
, PathCountPriority priority
);
43 * Stops the work until new input is passed
49 * Signals that the directory \a path contains \a count items of size \a
50 * Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit
52 void result(const QString
&path
, int count
, long size
);
54 void requestDirectoryContentsCount(const QString
&path
, KDirectoryContentsCounterWorker::Options options
);
59 void slotResult(const QString
&path
, int count
, long size
);
60 void slotDirWatchDirty(const QString
&path
);
61 void slotItemsRemoved();
64 KFileItemModel
*m_model
;
66 // Used as FIFO queues.
67 std::list
<QString
> m_priorityQueue
;
68 std::list
<QString
> m_queue
;
70 static QThread
*m_workerThread
;
72 KDirectoryContentsCounterWorker
*m_worker
;
75 KDirWatch
*m_dirWatcher
;
76 QSet
<QString
> m_watchedDirs
; // Required as sadly KDirWatch does not offer a getter method
77 // to get all watched directories.