Unity Scopes Qt library
QDepartment.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/QVariantMap>
26 #pragma GCC diagnostic pop
27 #include <QtCore/QString>
28 #include <QtCore/QSharedPointer>
29 #include <QtCore/QScopedPointer>
30 
31 #include <memory>
32 
33 namespace unity
34 {
35 
36 namespace scopes
37 {
38 
39 namespace qt
40 {
41 
42 class QDepartment;
43 class QCannedQuery;
44 
45 namespace internal
46 {
47 class QDepartmentImpl;
48 class QSearchReplyImpl;
49 }
50 
54 typedef QList<QSharedPointer<QDepartment const>> QDepartmentList;
55 
59 class QDepartment final
60 {
61 public:
63  UNITY_DEFINES_PTRS(QDepartment);
65 
75  static QDepartment::UPtr create(QCannedQuery const& query, QString const& label);
76 
88  static QDepartment::UPtr create(QString const& department_id, QCannedQuery const& query, QString const& label);
89 
93  //{@
94  QDepartment(QDepartment const& other);
96  QDepartment& operator=(QDepartment const& other);
97  QDepartment& operator=(QDepartment&&);
99 
101  ~QDepartment();
103 
108  void set_subdepartments(QDepartmentList const& departments);
109 
114  void add_subdepartment(QDepartment::SCPtr const& department);
115 
124  void set_alternate_label(QString const& label);
125 
138  void set_has_subdepartments(bool subdepartments = true);
139 
144  QString id() const;
145 
150  QString label() const;
151 
162  QString alternate_label() const;
163 
168  QCannedQuery query() const;
169 
174  QDepartmentList subdepartments() const;
175 
180  bool has_subdepartments() const;
181 
183  QVariantMap serialize() const;
185 
186 private:
188  QDepartment(internal::QDepartmentImpl* impl);
189  std::unique_ptr<internal::QDepartmentImpl> p;
190  friend class internal::QDepartmentImpl;
191  friend class internal::QSearchReplyImpl;
193 };
194 
195 } // namespace qt
196 
197 } // namespace scopes
198 
199 } // namespace unity
QDepartmentList subdepartments() const
Get list of sub-departments of this department.
QCannedQuery query() const
Get the canned query associated with this department.
void set_subdepartments(QDepartmentList const &departments)
Set sub-departments of this department.
QString alternate_label() const
Get the alternate label of this department.
void add_subdepartment(QDepartment::SCPtr const &department)
Add sub-department to this department.
A department with optional sub-departments.
Definition: QDepartment.h:59
void set_has_subdepartments(bool subdepartments=true)
Sets has_subdepartments flag of this department.
Definition: HttpAsyncReader.h:39
Parameters of a search query.
Definition: QCannedQuery.h:54
QString id() const
Get the identifier of this department.
bool has_subdepartments() const
Check if this department has subdepartments or has_subdepartments flag is set.
QString label() const
Get the label of this department.
static QDepartment::UPtr create(QCannedQuery const &query, QString const &label)
Create a department with the given canned query and name.
void set_alternate_label(QString const &label)
Set the alternate label (plural of the normal label) of this department.