]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kdirectorycontentscounterworker.h
[Details mode] Allow to fill the column size of directories with actual size
[dolphin.git] / src / kitemviews / private / kdirectorycontentscounterworker.h
1 /***************************************************************************
2 * Copyright (C) 2013 by Frank Reininghaus <frank78ac@googlemail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef KDIRECTORYCONTENTSCOUNTERWORKER_H
21 #define KDIRECTORYCONTENTSCOUNTERWORKER_H
22
23 #include <QMetaType>
24 #include <QObject>
25
26 class QString;
27
28 class KDirectoryContentsCounterWorker : public QObject
29 {
30 Q_OBJECT
31
32 public:
33 enum Option {
34 NoOptions = 0x0,
35 CountHiddenFiles = 0x1,
36 CountDirectoriesOnly = 0x2
37 };
38 Q_DECLARE_FLAGS(Options, Option)
39
40 struct CountResult {
41 /// number of elements in the directory
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
48 explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr);
49
50 /**
51 * Counts the items inside the directory \a path using the options
52 * \a options.
53 *
54 * @return The number of items.
55 */
56 static CountResult subItemsCount(const QString& path, Options options);
57
58 signals:
59 /**
60 * Signals that the directory \a path contains \a count items and optionally the size of its content.
61 */
62 void result(const QString& path, int count, long size);
63
64 public slots:
65 /**
66 * Requests the number of items inside the directory \a path using the
67 * options \a options. The result is announced via the signal \a result.
68 */
69 // Note that the full type name KDirectoryContentsCounterWorker::Options
70 // is needed here. Just using 'Options' is OK for the compiler, but
71 // confuses moc.
72 void countDirectoryContents(const QString& path, KDirectoryContentsCounterWorker::Options options);
73 };
74
75 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options)
76 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options)
77
78 #endif