]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/knepomukrolesprovider.h
Fix Bug 310465 - Can't switch view mode for non-writable paths
[dolphin.git] / src / kitemviews / private / knepomukrolesprovider.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.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 KNEPOMUKROLESPROVIDER_H
21 #define KNEPOMUKROLESPROVIDER_H
22
23 #include <libdolphin_export.h>
24
25 #include <QHash>
26 #include <QSet>
27 #include <QUrl>
28
29 namespace Nepomuk
30 {
31 class Resource;
32 }
33
34 /**
35 * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
36 *
37 * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
38 * are only accessible with Nepomuk.
39 */
40 class LIBDOLPHINPRIVATE_EXPORT KNepomukRolesProvider
41 {
42 public:
43 static KNepomukRolesProvider& instance();
44 virtual ~KNepomukRolesProvider();
45
46 /**
47 * @return Roles that can be provided by KNepomukRolesProvider.
48 */
49 QSet<QByteArray> roles() const;
50
51 /**
52 * @return Values for the roles \a roles that can be determined from the file
53 * with the URL \a url.
54 */
55 QHash<QByteArray, QVariant> roleValues(const Nepomuk::Resource& resource,
56 const QSet<QByteArray>& roles) const;
57
58 protected:
59 KNepomukRolesProvider();
60
61 private:
62 /**
63 * @return User visible string for the given tag-values.
64 */
65 QString tagsFromValues(const QStringList& values) const;
66
67 /**
68 * @return User visible string for the EXIF-orientation property
69 * which can have the values 0 to 8.
70 * (see http://sylvana.net/jpegcrop/exif_orientation.html)
71 */
72 QString orientationFromValue(int value) const;
73
74 /**
75 * @return Duration in the format HH::MM::SS for the value given
76 * in milliseconds.
77 */
78 QString durationFromValue(int value) const;
79
80 private:
81 QSet<QByteArray> m_roles;
82 QHash<QUrl, QByteArray> m_roleForUri;
83
84 friend class KNepomukRolesProviderSingleton;
85 };
86
87 #endif
88