]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kdirectorycontentscounterworker.h
Output of licensedigger + manual cleanup afterwards.
[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 {
21 NoOptions = 0x0,
22 CountHiddenFiles = 0x1,
23 CountDirectoriesOnly = 0x2
24 };
25 Q_DECLARE_FLAGS(Options, Option)
26
27 struct CountResult {
28 /// number of elements in the directory
29 int count;
30 /// Recursive sum of the size of the directory content files and folders
31 /// Calculation depends on DetailsModeSettings::recursiveDirectorySizeLimit
32 long size;
33 };
34
35 explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr);
36
37 /**
38 * Counts the items inside the directory \a path using the options
39 * \a options.
40 *
41 * @return The number of items.
42 */
43 static CountResult subItemsCount(const QString& path, Options options);
44
45 signals:
46 /**
47 * Signals that the directory \a path contains \a count items and optionally the size of its content.
48 */
49 void result(const QString& path, int count, long size);
50
51 public slots:
52 /**
53 * Requests the number of items inside the directory \a path using the
54 * options \a options. The result is announced via the signal \a result.
55 */
56 // Note that the full type name KDirectoryContentsCounterWorker::Options
57 // is needed here. Just using 'Options' is OK for the compiler, but
58 // confuses moc.
59 void countDirectoryContents(const QString& path, KDirectoryContentsCounterWorker::Options options);
60 };
61
62 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options)
63 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options)
64
65 #endif