Unity Scopes Qt library
QColumnLayout.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/DefinesPtrs.h>
22 
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
25 #include <QtCore/QVariant>
26 #pragma GCC diagnostic pop
27 #include <QtCore/QVector>
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 namespace qt
36 {
37 
38 namespace internal
39 {
40 class QColumnLayoutImpl;
41 class QPreviewReplyImpl;
42 }
43 
54 class QColumnLayout final
55 {
56 public:
58  UNITY_DEFINES_PTRS(QColumnLayout);
60 
66  explicit QColumnLayout(int num_of_columns);
67 
71  //{@
72  QColumnLayout(QColumnLayout const& other);
74  QColumnLayout& operator=(QColumnLayout const& other);
75  QColumnLayout& operator=(QColumnLayout&&);
77 
79  ~QColumnLayout();
81 
91  void add_column(QVector<QString> widget_ids);
92 
97  int size() const noexcept;
98 
103  int number_of_columns() const noexcept;
104 
111  QVector<QString> column(int index) const;
112 
114  QVariantMap serialize() const;
116 
117 private:
118  QColumnLayout(internal::QColumnLayoutImpl* impl);
120  std::unique_ptr<internal::QColumnLayoutImpl> p;
121  friend class internal::QColumnLayoutImpl;
122  friend class internal::QPreviewReplyImpl;
124 };
125 
130 typedef QList<QColumnLayout> QColumnLayoutList;
131 
132 } // namespace qt
133 
134 } // namespace scopes
135 
136 } // namespace unity
int number_of_columns() const noexcept
Get the number of columns expected by this layout as specified in the constructor.
int size() const noexcept
Get the current number of columns in this layout.
Definition: HttpAsyncReader.h:39
QVector< QString > column(int index) const
Retrieve the list of widgets for given column.
void add_column(QVector< QString > widget_ids)
Adds a new column and assigns widgets to it.
QColumnLayout(int num_of_columns)
Creates a layout definition that expects num_of_columns columns to be added with ColumnLayout::add_co...
Represents a column layout.
Definition: QColumnLayout.h:54