]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kbaloorolesprovider.h
6fef98edee635884619d16df8008aacf3f1f20c4
[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 * The tag-values are sorted in alphabetical order.
66 */
67 QString tagsFromValues(const QStringList& values) const;
68
69 /**
70 * @return User visible string for the EXIF-orientation property
71 * which can have the values 0 to 8.
72 * (see http://sylvana.net/jpegcrop/exif_orientation.html)
73 */
74 QString orientationFromValue(int value) const;
75
76 /**
77 * @return Duration in the format HH::MM::SS for the value given
78 * in seconds.
79 */
80 QString durationFromValue(int value) const;
81
82 /**
83 * @return Bitrate in the format N kB/s for the value given
84 * in b/s.
85 */
86 QString bitrateFromValue(int value) const;
87
88 private:
89 QSet<QByteArray> m_roles;
90 QHash<QString, QByteArray> m_roleForProperty;
91
92 friend struct KBalooRolesProviderSingleton;
93 };
94
95 #endif
96