Unity Scopes API
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 #include <QtCore/QVariantMap>
24 #include <QtCore/QString>
25 #include <QtCore/QSharedPointer>
26 #include <QtCore/QScopedPointer>
27 
28 #include <memory>
29 
30 namespace unity
31 {
32 
33 namespace scopes
34 {
35 
36 namespace qt
37 {
38 
39 class QDepartment;
40 class QCannedQuery;
41 
42 namespace internal
43 {
44 class QDepartmentImpl;
45 class QSearchReplyImpl;
46 }
47 
51 typedef QList<QSharedPointer<QDepartment const>> QDepartmentList;
52 
56 class QDepartment final
57 {
58 public:
60  UNITY_DEFINES_PTRS(QDepartment);
62 
72  static QDepartment::UPtr create(QCannedQuery const& query, QString const& label);
73 
85  static QDepartment::UPtr create(QString const& department_id, QCannedQuery const& query, QString const& label);
86 
90  //{@
91  QDepartment(QDepartment const& other);
93  QDepartment& operator=(QDepartment const& other);
94  QDepartment& operator=(QDepartment&&);
96 
98  ~QDepartment();
100 
105  void set_subdepartments(QDepartmentList const& departments);
106 
111  void add_subdepartment(QDepartment::SCPtr const& department);
112 
121  void set_alternate_label(QString const& label);
122 
135  void set_has_subdepartments(bool subdepartments = true);
136 
141  QString id() const;
142 
147  QString label() const;
148 
159  QString alternate_label() const;
160 
165  QCannedQuery query() const;
166 
171  QDepartmentList subdepartments() const;
172 
177  bool has_subdepartments() const;
178 
180  QVariantMap serialize() const;
182 
183 private:
185  QDepartment(internal::QDepartmentImpl* impl);
186  std::unique_ptr<internal::QDepartmentImpl> p;
187  friend class internal::QDepartmentImpl;
188  friend class internal::QSearchReplyImpl;
190 };
191 
192 } // namespace qt
193 
194 } // namespace scopes
195 
196 } // namespace unity
Definition: HttpAsyncReader.h:45
QString id() const
Get the identifier of this department.
Definition: QDepartment.cpp:91
QDepartmentList subdepartments() const
Get list of sub-departments of this department.
Definition: QDepartment.cpp:116
bool has_subdepartments() const
Check if this department has subdepartments or has_subdepartments flag is set.
Definition: QDepartment.cpp:111
A department with optional sub-departments.
Definition: QDepartment.h:56
QCannedQuery query() const
Get the canned query associated with this department.
Definition: QDepartment.cpp:106
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Parameters of a search query.
Definition: QCannedQuery.h:51
Definition: ActionMetadata.h:31
void add_subdepartment(QDepartment::SCPtr const &department)
Add sub-department to this department.
Definition: QDepartment.cpp:81
QString alternate_label() const
Get the alternate label of this department.
Definition: QDepartment.cpp:101
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.
Definition: QDepartment.cpp:86
void set_subdepartments(QDepartmentList const &departments)
Set sub-departments of this department.
Definition: QDepartment.cpp:76
void set_has_subdepartments(bool subdepartments=true)
Sets has_subdepartments flag of this department.
Definition: QDepartment.cpp:71
QString label() const
Get the label of this department.
Definition: QDepartment.cpp:96