Baloo Widgets

filemetadatawidget.h
1 /*
2  SPDX-FileCopyrightText: 2012-2013 Vishesh Handa <[email protected]>
3 
4  Adapted from KFileMetadataWidget
5  SPDX-FileCopyrightText: 2008 Sebastian Trueg <[email protected]>
6  SPDX-FileCopyrightText: 2009-2010 Peter Penz <[email protected]>
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 
24 namespace Baloo
25 {
26 class FileMetaDataWidgetPrivate;
27 
28 /**
29  * Modify format of date display
30  */
31 enum class DateFormats {
32  LongFormat = QLocale::LongFormat, ///< @see QLocale::LongFormat
33  ShortFormat = QLocale::ShortFormat, ///< @see QLocale::ShortFormat
34 };
35 
36 enum 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 
46 class 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 
52 public:
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 
87 Q_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 
101 private:
102  int getMargin() const;
103  friend class FileMetaDataWidgetPrivate;
104  std::unique_ptr<FileMetaDataWidgetPrivate> const d;
105 
106  Q_PRIVATE_SLOT(d, void slotLoadingFinished())
107  Q_PRIVATE_SLOT(d, void slotLinkActivated(QString))
108  Q_PRIVATE_SLOT(d, void slotDataChangeStarted())
109  Q_PRIVATE_SLOT(d, void slotDataChangeFinished())
110 };
111 
112 }
113 Q_DECLARE_METATYPE(Baloo::DateFormats)
114 
115 #endif // _BALOO_FILE_METADATAWIDGET_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 04:12:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.