Baloo Widgets

filemetadatawidget.h
1 /*
2  <one line to give the library's name and an idea of what it does.>
3  Copyright (C) 2012-2013 Vishesh Handa <[email protected]>
4 
5  Adapted from KFileMetadataWidget
6  Copyright (C) 2008 by Sebastian Trueg <[email protected]>
7  Copyright (C) 2009-2010 by Peter Penz <[email protected]>
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 
25 #ifndef _BALOO_FILE_METADATAWIDGET_H
26 #define _BALOO_FILE_METADATAWIDGET_H
27 
28 #include <QWidget>
29 #include <QUrl>
30 
31 #include <KFileItem>
32 #include <QLocale>
33 
34 #include "widgets_export.h"
35 
36 namespace Baloo {
37 
38 /**
39  * Modify format of date display
40  */
41 enum class DateFormats {
42  LongFormat = QLocale::LongFormat, ///< @see QLocale::LongFormat
43  ShortFormat = QLocale::ShortFormat ///< @see QLocale::ShortFormat
44 };
45 
46 enum class ConfigurationMode {
47  ReStart = 0, /**< Switch into configuration mode. The selection is
48  * initialized with the current configuration.
49  * In case the widget is in configuration mode already,
50  * the changes are discarded, and the mode is kept.
51  */
52  Accept, /**< Save any changes, switch to regular mode */
53  Cancel /**< Discard any changes, switch to regular mode */
54 };
55 
56 class BALOO_WIDGETS_EXPORT FileMetaDataWidget : public QWidget
57 {
58  Q_OBJECT
59  Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
60  Q_PROPERTY(DateFormats dateFormat READ dateFormat WRITE setDateFormat)
61 
62 public:
63  explicit FileMetaDataWidget(QWidget* parent = nullptr);
64  ~FileMetaDataWidget() override;
65 
66  /**
67  * Sets the items for which the meta data should be shown.
68  * The signal metaDataRequestFinished() will be emitted,
69  * as soon as the meta data for the items has been received.
70  */
71  void setItems(const KFileItemList& items);
72  KFileItemList items() const;
73 
74  /**
75  * If set to true, data such as the comment, tag or rating cannot be
76  * changed by the user. Per default read-only is disabled.
77  */
78  void setReadOnly(bool readOnly);
79  bool isReadOnly() const;
80 
81  /**
82  * Set date display format.
83  * Per Default format is Long = @see QLocale::LongFormat
84  */
85  void setDateFormat(const DateFormats format);
86  DateFormats dateFormat() const;
87 
88  /** @see QWidget::sizeHint() */
89  QSize sizeHint() const override;
90 
91  /**
92  * Switch between regular (view) and configuration mode.
93  * @since 19.08.00
94  */
95  void setConfigurationMode(ConfigurationMode mode);
96 
97 Q_SIGNALS:
98  /**
99  * Is emitted, if a meta data represents an URL that has
100  * been clicked by the user.
101  */
102  void urlActivated(const QUrl& url);
103 
104  /**
105  * Is emitted after the meta data has been received for the items
106  * set by KFileMetaDataWidget::setItems().
107  * @since 4.6
108  */
109  void metaDataRequestFinished(const KFileItemList& items);
110 
111 private:
112  class Private;
113  Private* d;
114 
115  Q_PRIVATE_SLOT(d, void slotLoadingFinished())
116  Q_PRIVATE_SLOT(d, void slotLinkActivated(QString))
117  Q_PRIVATE_SLOT(d, void slotDataChangeStarted())
118  Q_PRIVATE_SLOT(d, void slotDataChangeFinished())
119 };
120 
121 }
122 Q_DECLARE_METATYPE(Baloo::DateFormats)
123 
124 #endif // _BALOO_FILE_METADATAWIDGET_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:07:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.