Unity Scopes Qt library
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 #include <unity/util/NonCopyable.h>
22 #include <unity/util/DefinesPtrs.h>
23 
24 #pragma GCC diagnostic push
25 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
26 #include <QtCore/QVariant>
27 #pragma GCC diagnostic pop
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 class PreviewWidget;
36 
37 namespace qt
38 {
39 
40 namespace internal
41 {
42 class QPreviewWidgetImpl;
43 class QPreviewReplyImpl;
44 }
45 
46 class QPreviewWidget;
47 
51 typedef QList<QPreviewWidget> QPreviewWidgetList;
52 
56 class QPreviewWidget final
57 {
58 public:
60  UNITY_DEFINES_PTRS(QPreviewWidget);
62 
68  QPreviewWidget(QString const& id, QString const& widget_type);
69 
97  QPreviewWidget(QString const& definition);
98 
102  //{@
103  QPreviewWidget(QPreviewWidget const& other);
105  virtual ~QPreviewWidget();
106 
107  QPreviewWidget& operator=(QPreviewWidget const& other);
108  QPreviewWidget& operator=(QPreviewWidget&& other);
110 
116  void add_attribute_value(QString const& key, QVariant const& value);
117 
129  void add_attribute_mapping(QString const& key, QString const& field_name);
130 
141  void add_widget(QPreviewWidget const& widget);
142 
147  QString id() const;
148 
153  QString widget_type() const;
154 
161  QMap<QString, QString> attribute_mappings() const;
162 
169  QVariantMap attribute_values() const;
170 
177  QPreviewWidgetList widgets() const;
178 
183  QString data() const;
184 
186  QVariantMap serialize() const;
187 
188 private:
189  std::unique_ptr<internal::QPreviewWidgetImpl> p;
190  QPreviewWidget(internal::QPreviewWidgetImpl* widget);
191 
192  friend class internal::QPreviewWidgetImpl;
193  friend class internal::QPreviewReplyImpl;
195 };
196 
197 } // namespace qt
198 
199 } // namespace scopes
200 
201 } // 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.
Definition: HttpAsyncReader.h:39
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.
QString data() const
Get a JSON representation of this widget.
Widget used in Preview.
Definition: QPreviewWidget.h:56
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.