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 * Cancel data loading if it's in progress
52 */
53 void cancel();
54
55 /**
56 * Refresh data with latest info from storage
57 */
58 void refresh();
59
60 /**
61 * If set to true, data such as the comment, tag or rating cannot be changed by the user.
62 * Per default read-only is disabled. The method readOnlyChanged() can be overwritten
63 * to react on the change.
64 */
65 void setReadOnly(bool readOnly);
66 bool isReadOnly() const;
67
68 /**
69 * @return Translated string for the label of the meta data represented
70 * by \p metaDataUri. If no custom translation is provided, the
71 * base implementation must be invoked.
72 */
73 virtual QString label(const QString &metaDataLabel) const;
74
75 /**
76 * Meta data items are sorted alphabetically by their translated
77 * label per default. However it is possible to provide an internal
78 * prefix to the label, so that specific items are grouped together.
79 * For example it makes sense that the meta data for 'width' and 'height'
80 * of an image are shown below each other. By adding a common prefix,
81 * a grouping is done.
82 * @return Returns the name of the group the meta data indicated
83 * by \p label belongs to. Per default an empty string
84 * is returned.
85 */
86 virtual QString group(const QString &label) const;
87
88 /**
89 * @return Meta data for the items that have been set by
90 * KFileMetaDataProvider::setItems(). The method should
91 * be invoked after the signal loadingFinished() has
92 * been received (otherwise no data will be returned).
93 */
94 QVariantMap data() const;
95
97 /**
98 * Emitted once per KFileMetaDataProvider::setItems()
99 * after data loading is finished.
100 */
102
103private:
104 FileMetaDataProviderPrivate *d;
105};
106
107}
108#endif
Provides the data for the MetaDataWidget.
void refresh()
Refresh data with latest info from storage.
void loadingFinished()
Emitted once per KFileMetaDataProvider::setItems() after data loading is finished.
void cancel()
Cancel data loading if it's in progress.
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 Sat Dec 21 2024 16:57:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.