2 * SPDX-FileCopyrightText: 2013 Frank Reininghaus <frank78ac@googlemail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef KDIRECTORYCONTENTSCOUNTERWORKER_H
8 #define KDIRECTORYCONTENTSCOUNTERWORKER_H
15 class KDirectoryContentsCounterWorker
: public QObject
20 enum Option
{ NoOptions
= 0x0, CountHiddenFiles
= 0x1 };
21 Q_DECLARE_FLAGS(Options
, Option
)
23 explicit KDirectoryContentsCounterWorker(QObject
*parent
= nullptr);
25 bool stopping() const;
26 QString
scannedPath() const;
29 * Signals that the directory \a path contains \a count items and optionally the size of its content.
31 void result(const QString
&path
, int count
, long long size
);
32 void intermediateResult(const QString
&path
, int count
, long long size
);
37 * Requests the number of items inside the directory \a path using the
38 * options \a options. The result is announced via the signal \a result.
40 // Note that the full type name KDirectoryContentsCounterWorker::Options
41 // is needed here. Just using 'Options' is OK for the compiler, but
43 void countDirectoryContents(const QString
&path
, KDirectoryContentsCounterWorker::Options options
, int maxRecursiveLevel
);
48 void walkDir(const QString
&dirPath
, bool countHiddenFiles
, uint allowedRecursiveLevel
);
51 QString m_scannedPath
;
53 std::atomic
<bool> m_stopping
= false;
56 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options
)
57 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options
)