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 #ifndef _ENABLE_QT_EXPERIMENTAL_
22 #error You should define _ENABLE_QT_EXPERIMENTAL_ in order to use this experimental header file.
23 #endif
24 
25 #include <unity/util/DefinesPtrs.h>
26 
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
29 #include <QtCore/QVariantMap>
30 #pragma GCC diagnostic pop
31 #include <QtCore/QString>
32 
33 #include <memory>
34 
35 namespace unity
36 {
37 
38 namespace scopes
39 {
40 
41 namespace qt
42 {
43 
44 class QDepartment;
45 class QCannedQuery;
46 
47 namespace internal
48 {
49 class QDepartmentImpl;
50 class QSearchReplyImpl;
51 }
52 
56 typedef QList<std::shared_ptr<QDepartment const>> QDepartmentList;
57 
61 class QDepartment final
62 {
63 public:
65  UNITY_DEFINES_PTRS(QDepartment);
67 
77  static QDepartment::UPtr create(QCannedQuery const& query, QString const& label);
78 
90  static QDepartment::UPtr create(QString const& department_id, QCannedQuery const& query, QString const& label);
91 
95  //{@
96  QDepartment(QDepartment const& other);
98  QDepartment& operator=(QDepartment const& other);
99  QDepartment& operator=(QDepartment&&);
101 
103  ~QDepartment();
105 
110  void set_subdepartments(QDepartmentList const& departments);
111 
116  void add_subdepartment(QDepartment::SCPtr const& department);
117 
126  void set_alternate_label(QString const& label);
127 
140  void set_has_subdepartments(bool subdepartments = true);
141 
146  QString id() const;
147 
152  QString label() const;
153 
164  QString alternate_label() const;
165 
170  QCannedQuery query() const;
171 
176  QDepartmentList subdepartments() const;
177 
182  bool has_subdepartments() const;
183 
185  QVariantMap serialize() const;
187 
188 private:
190  QDepartment(internal::QDepartmentImpl* impl);
191  std::unique_ptr<internal::QDepartmentImpl> p;
192  friend class internal::QDepartmentImpl;
193  friend class internal::QSearchReplyImpl;
195 };
196 
197 } // namespace qt
198 
199 } // namespace scopes
200 
201 } // namespace unity
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:61
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:58
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