Changeset View
Changeset View
Standalone View
Standalone View
src/kitemviews/private/kdirectorycontentscounterworker.h
Show All 31 Lines | |||||
32 | public: | 32 | public: | ||
33 | enum Option { | 33 | enum Option { | ||
34 | NoOptions = 0x0, | 34 | NoOptions = 0x0, | ||
35 | CountHiddenFiles = 0x1, | 35 | CountHiddenFiles = 0x1, | ||
36 | CountDirectoriesOnly = 0x2 | 36 | CountDirectoriesOnly = 0x2 | ||
37 | }; | 37 | }; | ||
38 | Q_DECLARE_FLAGS(Options, Option) | 38 | Q_DECLARE_FLAGS(Options, Option) | ||
39 | 39 | | |||
40 | struct CountResult { | ||||
ngraham: whitespace | |||||
41 | /// number of elements in the directory | ||||
ngraham: "number" would be more readable than "nb" | |||||
42 | int count; | ||||
43 | /// Recursive sum of the size of the directory content files and folders | ||||
44 | /// Calculation depends on DetailsModeSettings::recursiveDirectorySizeLimit | ||||
45 | long size; | ||||
46 | }; | ||||
47 | | ||||
40 | explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr); | 48 | explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr); | ||
41 | 49 | | |||
42 | /** | 50 | /** | ||
43 | * Counts the items inside the directory \a path using the options | 51 | * Counts the items inside the directory \a path using the options | ||
44 | * \a options. | 52 | * \a options. | ||
45 | * | 53 | * | ||
46 | * @return The number of items. | 54 | * @return The number of items. | ||
47 | */ | 55 | */ | ||
48 | static int subItemsCount(const QString& path, Options options); | 56 | static CountResult subItemsCount(const QString& path, Options options); | ||
49 | 57 | | |||
50 | signals: | 58 | signals: | ||
51 | /** | 59 | /** | ||
52 | * Signals that the directory \a path contains \a count items. | 60 | * Signals that the directory \a path contains \a count items and optionally the size of its content. | ||
meven: typo optinnaly | |||||
53 | */ | 61 | */ | ||
54 | void result(const QString& path, int count); | 62 | void result(const QString& path, int count, long size); | ||
55 | 63 | | |||
56 | public slots: | 64 | public slots: | ||
57 | /** | 65 | /** | ||
58 | * Requests the number of items inside the directory \a path using the | 66 | * Requests the number of items inside the directory \a path using the | ||
59 | * options \a options. The result is announced via the signal \a result. | 67 | * options \a options. The result is announced via the signal \a result. | ||
60 | */ | 68 | */ | ||
61 | // Note that the full type name KDirectoryContentsCounterWorker::Options | 69 | // Note that the full type name KDirectoryContentsCounterWorker::Options | ||
62 | // is needed here. Just using 'Options' is OK for the compiler, but | 70 | // is needed here. Just using 'Options' is OK for the compiler, but | ||
63 | // confuses moc. | 71 | // confuses moc. | ||
64 | void countDirectoryContents(const QString& path, KDirectoryContentsCounterWorker::Options options); | 72 | void countDirectoryContents(const QString& path, KDirectoryContentsCounterWorker::Options options); | ||
65 | }; | 73 | }; | ||
66 | 74 | | |||
67 | Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options) | 75 | Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options) | ||
68 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options) | 76 | Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options) | ||
69 | 77 | | |||
70 | #endif | 78 | #endif |
whitespace