]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kbaloorolesprovider.h
Output of licensedigger + manual cleanup afterwards.
[dolphin.git] / src / kitemviews / private / kbaloorolesprovider.h
1 /*
2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
3 * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #ifndef KBALOO_ROLESPROVIDER_H
9 #define KBALOO_ROLESPROVIDER_H
10
11 #include "dolphin_export.h"
12
13 #include <QHash>
14 #include <QSet>
15 #include <QVariant>
16
17 namespace Baloo {
18 class File;
19 }
20
21 /**
22 * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
23 *
24 * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
25 * are only accessible with Baloo.
26 */
27 class DOLPHIN_EXPORT KBalooRolesProvider
28 {
29 public:
30 static KBalooRolesProvider& instance();
31 virtual ~KBalooRolesProvider();
32
33 /**
34 * @return Roles that can be provided by KBalooRolesProvider.
35 */
36 QSet<QByteArray> roles() const;
37
38 /**
39 * @return Values for the roles \a roles that can be determined from the file
40 * with the URL \a url.
41 */
42 QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
43 const QSet<QByteArray>& roles) const;
44
45 QByteArray roleForProperty(const QString& property) const;
46
47 protected:
48 KBalooRolesProvider();
49
50 private:
51 /**
52 * @return User visible string for the given tag-values.
53 * The tag-values are sorted in alphabetical order.
54 */
55 QString tagsFromValues(const QStringList& values) const;
56
57 private:
58 QSet<QByteArray> m_roles;
59 QHash<QString, QByteArray> m_roleForProperty;
60
61 friend struct KBalooRolesProviderSingleton;
62 };
63
64 #endif
65