File indexing completed on 2024-05-12 05:47:29

0001 /*
0002  * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
0003  * SPDX-FileCopyrightText: 2013 Vishesh Handa <me@vhanda.in>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef KBALOO_ROLESPROVIDER_H
0009 #define KBALOO_ROLESPROVIDER_H
0010 
0011 #include "dolphin_export.h"
0012 
0013 #include <QHash>
0014 #include <QSet>
0015 #include <QVariant>
0016 
0017 namespace Baloo
0018 {
0019 class File;
0020 }
0021 
0022 /**
0023  * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
0024  *
0025  * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that
0026  * are only accessible with Baloo.
0027  */
0028 class DOLPHIN_EXPORT KBalooRolesProvider
0029 {
0030 public:
0031     static KBalooRolesProvider &instance();
0032     virtual ~KBalooRolesProvider();
0033 
0034     /**
0035      * @return Roles that can be provided by KBalooRolesProvider.
0036      */
0037     QSet<QByteArray> roles() const;
0038 
0039     /**
0040      * @return Values for the roles \a roles that can be determined from the file
0041      *         with the URL \a url.
0042      */
0043     QHash<QByteArray, QVariant> roleValues(const Baloo::File &file, const QSet<QByteArray> &roles) const;
0044 
0045 protected:
0046     KBalooRolesProvider();
0047 
0048 private:
0049     QSet<QByteArray> m_roles;
0050 
0051     friend struct KBalooRolesProviderSingleton;
0052 };
0053 
0054 #endif