]> cloud.milkyroute.net Git - dolphin.git/blob - src/kitemviews/private/kbaloorolesprovider.h
Remove unused #include
[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
30 namespace Baloo {
31 class File;
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 Baloo.
39 */
40 class DOLPHIN_EXPORT KBalooRolesProvider
41 {
42 public:
43 static KBalooRolesProvider& instance();
44 virtual ~KBalooRolesProvider();
45
46 /**
47 * @return Roles that can be provided by KBalooRolesProvider.
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 Baloo::File& file,
56 const QSet<QByteArray>& roles) const;
57
58 QByteArray roleForProperty(const QString& property) const;
59
60 protected:
61 KBalooRolesProvider();
62
63 private:
64 /**
65 * @return User visible string for the given tag-values.
66 * The tag-values are sorted in alphabetical order.
67 */
68 QString tagsFromValues(const QStringList& values) const;
69
70 /**
71 * @return User visible string for the EXIF-orientation property
72 * which can have the values 0 to 8.
73 * (see http://sylvana.net/jpegcrop/exif_orientation.html)
74 */
75 QString orientationFromValue(int value) const;
76
77 /**
78 * @return Duration in the format HH::MM::SS for the value given
79 * in seconds.
80 */
81 QString durationFromValue(int value) const;
82
83 /**
84 * @return Bitrate in the format N kB/s for the value given
85 * in b/s.
86 */
87 QString bitrateFromValue(int value) const;
88
89 private:
90 QSet<QByteArray> m_roles;
91 QHash<QString, QByteArray> m_roleForProperty;
92
93 friend struct KBalooRolesProviderSingleton;
94 };
95
96 #endif
97