1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
3 * Copyright (C) 2013 by Vishesh Handa <me@vhanda.in> *
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. *
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. *
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 ***************************************************************************/
21 #ifndef KBALOO_ROLESPROVIDER_H
22 #define KBALOO_ROLESPROVIDER_H
24 #include "dolphin_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 Baloo.
40 class DOLPHIN_EXPORT KBalooRolesProvider
43 static KBalooRolesProvider
& instance();
44 virtual ~KBalooRolesProvider();
47 * @return Roles that can be provided by KBalooRolesProvider.
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 Baloo::File
& file
,
56 const QSet
<QByteArray
>& roles
) const;
58 QByteArray
roleForProperty(const QString
& property
) const;
61 KBalooRolesProvider();
65 * @return User visible string for the given tag-values.
66 * The tag-values are sorted in alphabetical order.
68 QString
tagsFromValues(const QStringList
& values
) const;
71 QSet
<QByteArray
> m_roles
;
72 QHash
<QString
, QByteArray
> m_roleForProperty
;
74 friend struct KBalooRolesProviderSingleton
;