Baloo Widgets

filemetadataprovider.h
1/*
2 SPDX-FileCopyrightText: 2010 Peter Penz <peter.penz@gmx.at>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef _BALOO_FILEMETADATAPROVIDER_H
8#define _BALOO_FILEMETADATAPROVIDER_H
9
10#include <QObject>
11#include <QString>
12#include <QVariant>
13
14#include <KFileItem>
15
16namespace Baloo
17{
18class FileMetaDataProviderPrivate;
19
20/**
21 * @brief Provides the data for the MetaDataWidget.
22 *
23 * The default implementation provides all meta data
24 * that are available due to Baloo. If custom
25 * meta data should be added, the method KFileMetaDataProvider::loadData()
26 * must be overwritten.
27 *
28 * @see FileMetaDataWidget
29 */
31{
33
34public:
35 explicit FileMetaDataProvider(QObject *parent = nullptr);
36 ~FileMetaDataProvider() override;
37
38 /**
39 * Sets the items, where the meta data should be
40 * requested. The loading of the meta data is done
41 * asynchronously. The signal loadingFinished() is
42 * emitted, as soon as the loading has been finished.
43 * The meta data can be retrieved by
44 * KFileMetaDataProvider::data() afterwards. The label for
45 * each item can be retrieved by KFileMetaDataProvider::label().
46 */
47 void setItems(const KFileItemList &items);
48 KFileItemList items() const;
49
50 /**
51 * If set to true, data such as the comment, tag or rating cannot be changed by the user.
52 * Per default read-only is disabled. The method readOnlyChanged() can be overwritten
53 * to react on the change.
54 */
55 void setReadOnly(bool readOnly);
56 bool isReadOnly() const;
57
58 /**
59 * @return Translated string for the label of the meta data represented
60 * by \p metaDataUri. If no custom translation is provided, the
61 * base implementation must be invoked.
62 */
63 virtual QString label(const QString &metaDataLabel) const;
64
65 /**
66 * Meta data items are sorted alphabetically by their translated
67 * label per default. However it is possible to provide an internal
68 * prefix to the label, so that specific items are grouped together.
69 * For example it makes sense that the meta data for 'width' and 'height'
70 * of an image are shown below each other. By adding a common prefix,
71 * a grouping is done.
72 * @return Returns the name of the group the meta data indicated
73 * by \p label belongs to. Per default an empty string
74 * is returned.
75 */
76 virtual QString group(const QString &label) const;
77
78 /**
79 * @return Meta data for the items that have been set by
80 * KFileMetaDataProvider::setItems(). The method should
81 * be invoked after the signal loadingFinished() has
82 * been received (otherwise no data will be returned).
83 */
84 QVariantMap data() const;
85
87 /**
88 * Emitted once per KFileMetaDataProvider::setItems()
89 * after data loading is finished.
90 */
92
93private:
94 FileMetaDataProviderPrivate *d;
95};
96
97}
98#endif
Provides the data for the MetaDataWidget.
void loadingFinished()
Emitted once per KFileMetaDataProvider::setItems() after data loading is finished.
void setItems(const KFileItemList &items)
Sets the items, where the meta data should be requested.
virtual QString group(const QString &label) const
Meta data items are sorted alphabetically by their translated label per default.
void setReadOnly(bool readOnly)
If set to true, data such as the comment, tag or rating cannot be changed by the user.
virtual QString label(const QString &metaDataLabel) const
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.