]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kdirectorycontentscounterworker.h
b40da6e87b57f5f99eb48c57b302a012bdc8b2d5
[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 explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr);
41
42 /**
43 * Counts the items inside the directory \a path using the options
44 * \a options.
45 *
46 * @return The number of items.
47 */
48 static int subItemsCount(const QString& path, Options options);
49
50 signals:
51 /**
52 * Signals that the directory \a path contains \a count items.
53 */
54 void result(const QString& path, int count);
55
56 public slots:
57 /**
58 * 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.
60 */
61 // Note that the full type name KDirectoryContentsCounterWorker::Options
62 // is needed here. Just using 'Options' is OK for the compiler, but
63 // confuses moc.
64 void countDirectoryContents(const QString& path, KDirectoryContentsCounterWorker::Options options);
65 };
66
67 Q_DECLARE_METATYPE(KDirectoryContentsCounterWorker::Options)
68 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirectoryContentsCounterWorker::Options)
69
70 #endif