Warning, file /libraries/baloo-widgets/src/filemetadataprovider.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz@gmx.at> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef _BALOO_FILEMETADATAPROVIDER_H 0008 #define _BALOO_FILEMETADATAPROVIDER_H 0009 0010 #include <QObject> 0011 #include <QString> 0012 #include <QVariant> 0013 0014 #include <Baloo/IndexerConfig> 0015 #include <KFileItem> 0016 0017 namespace Baloo 0018 { 0019 /** 0020 * @brief Provides the data for the MetaDataWidget. 0021 * 0022 * The default implementation provides all meta data 0023 * that are available due to Baloo. If custom 0024 * meta data should be added, the method KFileMetaDataProvider::loadData() 0025 * must be overwritten. 0026 * 0027 * @see FileMetaDataWidget 0028 */ 0029 class FileMetaDataProvider : public QObject 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 explicit FileMetaDataProvider(QObject *parent = nullptr); 0035 ~FileMetaDataProvider() override; 0036 0037 /** 0038 * Sets the items, where the meta data should be 0039 * requested. The loading of the meta data is done 0040 * asynchronously. The signal loadingFinished() is 0041 * emitted, as soon as the loading has been finished. 0042 * The meta data can be retrieved by 0043 * KFileMetaDataProvider::data() afterwards. The label for 0044 * each item can be retrieved by KFileMetaDataProvider::label(). 0045 */ 0046 void setItems(const KFileItemList &items); 0047 KFileItemList items() const; 0048 0049 /** 0050 * If set to true, data such as the comment, tag or rating cannot be changed by the user. 0051 * Per default read-only is disabled. The method readOnlyChanged() can be overwritten 0052 * to react on the change. 0053 */ 0054 void setReadOnly(bool readOnly); 0055 bool isReadOnly() const; 0056 0057 /** 0058 * @return Translated string for the label of the meta data represented 0059 * by \p metaDataUri. If no custom translation is provided, the 0060 * base implementation must be invoked. 0061 */ 0062 virtual QString label(const QString &metaDataLabel) const; 0063 0064 /** 0065 * Meta data items are sorted alphabetically by their translated 0066 * label per default. However it is possible to provide an internal 0067 * prefix to the label, so that specific items are grouped together. 0068 * For example it makes sense that the meta data for 'width' and 'height' 0069 * of an image are shown below each other. By adding a common prefix, 0070 * a grouping is done. 0071 * @return Returns the name of the group the meta data indicated 0072 * by \p label belongs to. Per default an empty string 0073 * is returned. 0074 */ 0075 virtual QString group(const QString &label) const; 0076 0077 /** 0078 * @return Meta data for the items that have been set by 0079 * KFileMetaDataProvider::setItems(). The method should 0080 * be invoked after the signal loadingFinished() has 0081 * been received (otherwise no data will be returned). 0082 */ 0083 QVariantMap data() const; 0084 0085 Q_SIGNALS: 0086 /** 0087 * Emitted once per KFileMetaDataProvider::setItems() 0088 * after data loading is finished. 0089 */ 0090 void loadingFinished(); 0091 0092 private Q_SLOTS: 0093 void slotFileFetchFinished(KJob *job); 0094 0095 private: 0096 void insertEditableData(); 0097 0098 void setFileItem(); 0099 void setFileItems(); 0100 0101 /** 0102 * Insert basic data of a single file 0103 */ 0104 void insertSingleFileBasicData(); 0105 0106 /** 0107 * Insert basic data of a list of files 0108 */ 0109 void insertFilesListBasicData(); 0110 0111 bool m_readOnly; 0112 0113 QList<KFileItem> m_fileItems; 0114 0115 QVariantMap m_data; 0116 Baloo::IndexerConfig m_config; 0117 }; 0118 0119 } 0120 #endif