Baloo Widgets

filemetadatawidget.h
1/*
2 SPDX-FileCopyrightText: 2012-2013 Vishesh Handa <me@vhanda.in>
3
4 Adapted from KFileMetadataWidget
5 SPDX-FileCopyrightText: 2008 Sebastian Trueg <trueg@kde.org>
6 SPDX-FileCopyrightText: 2009-2010 Peter Penz <peter.penz@gmx.at>
7
8 SPDX-License-Identifier: LGPL-2.1-or-later
9*/
10
11#ifndef _BALOO_FILE_METADATAWIDGET_H
12#define _BALOO_FILE_METADATAWIDGET_H
13
14#include "widgets_export.h"
15
16#include <KFileItem>
17
18#include <QLocale>
19#include <QUrl>
20#include <QWidget>
21
22#include <memory>
23
24namespace Baloo
25{
26class FileMetaDataWidgetPrivate;
27
28/**
29 * Modify format of date display
30 */
31enum class DateFormats {
32 LongFormat = QLocale::LongFormat, ///< @see QLocale::LongFormat
33 ShortFormat = QLocale::ShortFormat, ///< @see QLocale::ShortFormat
34};
35
36enum class ConfigurationMode {
37 ReStart = 0, /**< Switch into configuration mode. The selection is
38 * initialized with the current configuration.
39 * In case the widget is in configuration mode already,
40 * the changes are discarded, and the mode is kept.
41 */
42 Accept, /**< Save any changes, switch to regular mode */
43 Cancel, /**< Discard any changes, switch to regular mode */
44};
45
46class BALOO_WIDGETS_EXPORT FileMetaDataWidget : public QWidget
47{
48 Q_OBJECT
49 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
50 Q_PROPERTY(DateFormats dateFormat READ dateFormat WRITE setDateFormat)
51
52public:
53 explicit FileMetaDataWidget(QWidget *parent = nullptr);
54 ~FileMetaDataWidget() override;
55
56 /**
57 * Sets the items for which the meta data should be shown.
58 * The signal metaDataRequestFinished() will be emitted,
59 * as soon as the meta data for the items has been received.
60 */
61 void setItems(const KFileItemList &items);
62 KFileItemList items() const;
63
64 /**
65 * If set to true, data such as the comment, tag or rating cannot be
66 * changed by the user. Per default read-only is disabled.
67 */
68 void setReadOnly(bool readOnly);
69 bool isReadOnly() const;
70
71 /**
72 * Set date display format.
73 * Per Default format is Long = @see QLocale::LongFormat
74 */
75 void setDateFormat(const DateFormats format);
76 DateFormats dateFormat() const;
77
78 /** @see QWidget::sizeHint() */
79 QSize sizeHint() const override;
80
81 /**
82 * Switch between regular (view) and configuration mode.
83 * @since 19.08.00
84 */
85 void setConfigurationMode(ConfigurationMode mode);
86
87Q_SIGNALS:
88 /**
89 * Is emitted, if a meta data represents an URL that has
90 * been clicked by the user.
91 */
92 void urlActivated(const QUrl &url);
93
94 /**
95 * Is emitted after the meta data has been received for the items
96 * set by KFileMetaDataWidget::setItems().
97 * @since 4.6
98 */
99 void metaDataRequestFinished(const KFileItemList &items);
100
101private:
102 friend class FileMetaDataWidgetPrivate;
103 std::unique_ptr<FileMetaDataWidgetPrivate> const d;
104
105 Q_PRIVATE_SLOT(d, void slotLoadingFinished())
106};
107
108}
109Q_DECLARE_METATYPE(Baloo::DateFormats)
110
111#endif // _BALOO_FILE_METADATAWIDGET_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:00:13 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.