Unity Scopes API
QPreviewWidget.h
1 /*
2  * Copyright (C) 2015 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Xavi Garcia <xavi.garcia.mena@canonical.com>
17  */
18 
19 #pragma once
20 
21 #ifndef _ENABLE_QT_EXPERIMENTAL_
22 #error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23 #endif
24 
25 #include <unity/util/NonCopyable.h>
26 #include <unity/util/DefinesPtrs.h>
27 
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
30 #include <QtCore/QVariant>
31 #pragma GCC diagnostic pop
32 
33 namespace unity
34 {
35 
36 namespace scopes
37 {
38 
39 class PreviewWidget;
40 
41 namespace qt
42 {
43 
44 namespace internal
45 {
46 class QPreviewWidgetImpl;
47 class QPreviewReplyImpl;
48 }
49 
50 class QPreviewWidget;
51 
55 typedef QList<QPreviewWidget> QPreviewWidgetList;
56 
60 class QPreviewWidget final
61 {
62 public:
64  UNITY_DEFINES_PTRS(QPreviewWidget);
66 
72  QPreviewWidget(QString const& id, QString const& widget_type);
73 
101  QPreviewWidget(QString const& definition);
102 
106  //{@
107  QPreviewWidget(QPreviewWidget const& other);
109  virtual ~QPreviewWidget();
110 
111  QPreviewWidget& operator=(QPreviewWidget const& other);
112  QPreviewWidget& operator=(QPreviewWidget&& other);
114 
120  void add_attribute_value(QString const& key, QVariant const& value);
121 
133  void add_attribute_mapping(QString const& key, QString const& field_name);
134 
145  void add_widget(QPreviewWidget const& widget);
146 
151  QString id() const;
152 
157  QString widget_type() const;
158 
165  QMap<QString, QString> attribute_mappings() const;
166 
173  QVariantMap attribute_values() const;
174 
181  QPreviewWidgetList widgets() const;
182 
187  QString data() const;
188 
190  QVariantMap serialize() const;
191 
192 private:
193  std::unique_ptr<internal::QPreviewWidgetImpl> p;
194  QPreviewWidget(internal::QPreviewWidgetImpl* widget);
195 
196  friend class internal::QPreviewWidgetImpl;
197  friend class internal::QPreviewReplyImpl;
199 };
200 
201 } // namespace qt
202 
203 } // namespace scopes
204 
205 } // namespace unity
QString id() const
Get the identifier of this widget.
QVariantMap attribute_values() const
Get the attributes of this widget.
void add_attribute_value(QString const &key, QVariant const &value)
Adds an attribute definition and its value.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
QString widget_type() const
Get type name of this widget.
QMap< QString, QString > attribute_mappings() const
Get the components of this widget.
QPreviewWidgetList widgets() const
Get widgets of 'expandable' widget.
void add_attribute_mapping(QString const &key, QString const &field_name)
Adds an attribute definition using a component mapping.
Definition: ActionMetadata.h:31
QString data() const
Get a JSON representation of this widget.
Widget used in Preview.
Definition: QPreviewWidget.h:60
void add_widget(QPreviewWidget const &widget)
Adds a widget into expandable widget.
QPreviewWidget(QString const &id, QString const &widget_type)
Create an empty widget definition with a specific id and type.