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, CountDirectoriesOnly
= 0x2 };
21 Q_DECLARE_FLAGS(Options
, Option
)
24 /// number of elements in the directory
26 /// Recursive sum of the size of the directory content files and folders
27 /// Calculation depends on DetailsModeSettings::recursiveDirectorySizeLimit
31 explicit KDirectoryContentsCounterWorker(QObject
*parent
= nullptr);
34 * Counts the items inside the directory \a path using the options
37 * @return The number of items.
39 CountResult
subItemsCount(const QString
&path
, Options options
);
43 * Signals that the directory \a path contains \a count items and optionally the size of its content.
45 void result(const QString
&path
, int count
, long size
);
49 * Requests the number of items inside the directory \a path using the
50 * options \a options. The result is announced via the signal \a result.
52 // Note that the full type name KDirectoryContentsCounterWorker::Options
53 // is needed here. Just using 'Options' is OK for the compiler, but
55 void countDirectoryContents(const QString
&path
, KDirectoryContentsCounterWorker::Options options
);
60 KDirectoryContentsCounterWorker::CountResult
61 walkDir(const QString
&dirPath
, const bool countHiddenFiles
, const bool countDirectoriesOnly
, const uint allowedRecursiveLevel
);
64 bool m_stopping
= false;
67 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options
)
68 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options
)