]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kdirectorycontentscounterworker.h
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / kitemviews / private / kdirectorycontentscounterworker.h
1 /*
2 * SPDX-FileCopyrightText: 2013 Frank Reininghaus <frank78ac@googlemail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef KDIRECTORYCONTENTSCOUNTERWORKER_H
8 #define KDIRECTORYCONTENTSCOUNTERWORKER_H
9
10 #include <QMetaType>
11 #include <QObject>
12
13 class QString;
14
15 class KDirectoryContentsCounterWorker : public QObject
16 {
17 Q_OBJECT
18
19 public:
20 enum Option { NoOptions = 0x0, CountHiddenFiles = 0x1 };
21 Q_DECLARE_FLAGS(Options, Option)
22
23 explicit KDirectoryContentsCounterWorker(QObject *parent = nullptr);
24
25 bool stopping() const;
26 QString scannedPath() const;
27 Q_SIGNALS:
28 /**
29 * Signals that the directory \a path contains \a count items and optionally the size of its content.
30 */
31 void result(const QString &path, int count, long long size);
32 void intermediateResult(const QString &path, int count, long long size);
33 void finished();
34
35 public Q_SLOTS:
36 /**
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.
39 */
40 // Note that the full type name KDirectoryContentsCounterWorker::Options
41 // is needed here. Just using 'Options' is OK for the compiler, but
42 // confuses moc.
43 void countDirectoryContents(const QString &path, KDirectoryContentsCounterWorker::Options options, int maxRecursiveLevel);
44 void stop();
45
46 private:
47 #ifndef Q_OS_WIN
48 void walkDir(const QString &dirPath, bool countHiddenFiles, uint allowedRecursiveLevel);
49 #endif
50
51 QString m_scannedPath;
52
53 std::atomic<bool> m_stopping = false;
54 };
55
56 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options)
57 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options)
58
59 #endif