]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kbaloorolesprovider.h
Merge branch 'Applications/16.04'
[dolphin.git] / src / kitemviews / private / kbaloorolesprovider.h
1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2013 by Vishesh Handa <me@vhanda.in> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef KBALOO_ROLESPROVIDER_H
22 #define KBALOO_ROLESPROVIDER_H
23
24 #include "dolphin_export.h"
25
26 #include <QHash>
27 #include <QSet>
28 #include <QVariant>
29 namespace Baloo {
30 class File;
31 }
32
33 /**
34 * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
35 *
36 * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
37 * are only accessible with Baloo.
38 */
39 class DOLPHIN_EXPORT KBalooRolesProvider
40 {
41 public:
42 static KBalooRolesProvider& instance();
43 virtual ~KBalooRolesProvider();
44
45 /**
46 * @return Roles that can be provided by KBalooRolesProvider.
47 */
48 QSet<QByteArray> roles() const;
49
50 /**
51 * @return Values for the roles \a roles that can be determined from the file
52 * with the URL \a url.
53 */
54 QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
55 const QSet<QByteArray>& roles) const;
56
57 QByteArray roleForProperty(const QString& property) const;
58
59 protected:
60 KBalooRolesProvider();
61
62 private:
63 /**
64 * @return User visible string for the given tag-values.
65 */
66 QString tagsFromValues(const QStringList& values) const;
67
68 /**
69 * @return User visible string for the EXIF-orientation property
70 * which can have the values 0 to 8.
71 * (see http://sylvana.net/jpegcrop/exif_orientation.html)
72 */
73 QString orientationFromValue(int value) const;
74
75 /**
76 * @return Duration in the format HH::MM::SS for the value given
77 * in seconds.
78 */
79 QString durationFromValue(int value) const;
80
81 private:
82 QSet<QByteArray> m_roles;
83 QHash<QString, QByteArray> m_roleForProperty;
84
85 friend class KBalooRolesProviderSingleton;
86 };
87
88 #endif
89