1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef KNEPOMUKROLESPROVIDER_H
21 #define KNEPOMUKROLESPROVIDER_H
23 #include <libdolphin_export.h>
35 * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
37 * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
38 * are only accessible with Nepomuk.
40 class LIBDOLPHINPRIVATE_EXPORT KNepomukRolesProvider
43 static KNepomukRolesProvider
& instance();
44 virtual ~KNepomukRolesProvider();
47 * @return Roles that can be provided by KNepomukRolesProvider.
49 QSet
<QByteArray
> roles() const;
52 * @return Values for the roles \a roles that can be determined from the file
53 * with the URL \a url.
55 QHash
<QByteArray
, QVariant
> roleValues(const Nepomuk::Resource
& resource
,
56 const QSet
<QByteArray
>& roles
) const;
59 KNepomukRolesProvider();
63 * @return User visible string for the given tag-values.
65 QString
tagsFromValues(const QStringList
& values
) const;
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)
72 QString
orientationFromValue(int value
) const;
75 * @return Duration in the format HH::MM::SS for the value given
78 QString
durationFromValue(int value
) const;
81 QSet
<QByteArray
> m_roles
;
82 QHash
<QUrl
, QByteArray
> m_roleForUri
;
84 friend class KNepomukRolesProviderSingleton
;