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 #include <unity/util/NonCopyable.h>
22 #include <unity/util/DefinesPtrs.h>
23 
24 #include <QtCore/QVariant>
25 
26 namespace unity
27 {
28 
29 namespace scopes
30 {
31 
32 class PreviewWidget;
33 
34 namespace qt
35 {
36 
37 namespace internal
38 {
39 class QPreviewWidgetImpl;
40 class QPreviewReplyImpl;
41 }
42 
43 class QPreviewWidget;
44 
48 typedef QList<QPreviewWidget> QPreviewWidgetList;
49 
53 class QPreviewWidget final
54 {
55 public:
57  UNITY_DEFINES_PTRS(QPreviewWidget);
59 
65  QPreviewWidget(QString const& id, QString const& widget_type);
66 
94  QPreviewWidget(QString const& definition);
95 
99  //{@
100  QPreviewWidget(QPreviewWidget const& other);
102  virtual ~QPreviewWidget();
103 
104  QPreviewWidget& operator=(QPreviewWidget const& other);
105  QPreviewWidget& operator=(QPreviewWidget&& other);
107 
113  void add_attribute_value(QString const& key, QVariant const& value);
114 
126  void add_attribute_mapping(QString const& key, QString const& field_name);
127 
138  void add_widget(QPreviewWidget const& widget);
139 
144  QString id() const;
145 
150  QString widget_type() const;
151 
158  QMap<QString, QString> attribute_mappings() const;
159 
166  QVariantMap attribute_values() const;
167 
174  QPreviewWidgetList widgets() const;
175 
180  QString data() const;
181 
183  QVariantMap serialize() const;
184 
185 private:
186  std::unique_ptr<internal::QPreviewWidgetImpl> p;
187  QPreviewWidget(internal::QPreviewWidgetImpl* widget);
188 
189  friend class internal::QPreviewWidgetImpl;
190  friend class internal::QPreviewReplyImpl;
192 };
193 
194 } // namespace qt
195 
196 } // namespace scopes
197 
198 } // namespace unity
QString id() const
Get the identifier of this widget.
Definition: HttpAsyncReader.h:45
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:53
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.