Unity Scopes API
QCannedQuery.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 #include <unity/scopes/FilterState.h>
27 
28 #include <QtCore/QString>
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
31 #include <QtCore/QVariantMap>
32 #pragma GCC diagnostic pop
33 
34 namespace unity
35 {
36 
37 namespace scopes
38 {
39 
40 class CannedQuery;
41 
42 namespace qt
43 {
44 
45 namespace internal
46 {
47 class QCannedQueryImpl;
48 class QSearchQueryBaseImpl;
49 class QDepartmentImpl;
50 }
51 
58 class QCannedQuery final
59 {
60 public:
62  UNITY_DEFINES_PTRS(QCannedQuery);
64 
68  explicit QCannedQuery(QString const& scope_id);
69 
73  QCannedQuery(QString const& scope_id, QString const& query_str, QString const& department_id);
74 
78  //{@
79  QCannedQuery(QCannedQuery const& other);
81  QCannedQuery& operator=(QCannedQuery const& other);
82  QCannedQuery& operator=(QCannedQuery&&);
84 
86  ~QCannedQuery();
88 
92  void set_department_id(QString const& dep_id);
93 
97  void set_query_string(QString const& query_str);
98 
103 
108  QString scope_id() const;
109 
114  QString department_id() const;
115 
120  QString query_string() const;
121 
123  QVariantMap serialize() const;
125 
130  QString to_uri() const;
131 
139  FilterState filter_state() const;
140 
147  static QCannedQuery from_uri(QString const& uri);
148 
154  bool has_user_data() const;
155 
162  QVariant user_data() const;
163 
164 private:
165  QCannedQuery(internal::QCannedQueryImpl* impl);
166  QCannedQuery(CannedQuery const& api_query);
167  std::unique_ptr<internal::QCannedQueryImpl> p;
168  friend class internal::QCannedQueryImpl;
169  friend class internal::QSearchQueryBaseImpl;
170  friend class internal::QDepartmentImpl;
171 };
172 
173 } // namespace qt
174 
175 } // namespace scopes
176 
177 } // namespace unity
bool has_user_data() const
Checks if user data has been attached to this query.
Definition: QCannedQuery.cpp:120
QString scope_id() const
Returns the scope identifier of this CannedQuery.
Definition: QCannedQuery.cpp:90
QString department_id() const
Returns the department id of this CannedQuery.
Definition: QCannedQuery.cpp:95
void set_department_id(QString const &dep_id)
Sets or updates the department.
Definition: QCannedQuery.cpp:75
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Parameters of a search query.
Definition: QCannedQuery.h:58
void set_filter_state(FilterState const &filter_state)
Sets filter state.
Definition: QCannedQuery.cpp:85
Definition: ActionMetadata.h:31
QString to_uri() const
Returns a string representation of this CannedQuery object as a URI using scope:// schema...
Definition: QCannedQuery.cpp:110
QString query_string() const
Returns the query string of this CannedQuery.
Definition: QCannedQuery.cpp:100
Parameters of a search query.
Definition: CannedQuery.h:49
static QCannedQuery from_uri(QString const &uri)
Recreates a CannedQuery object from a scope:// URI.
Definition: QCannedQuery.cpp:115
Captures state of multiple filters.
Definition: FilterState.h:46
QVariant user_data() const
Get user data attached to this query.
Definition: QCannedQuery.cpp:125
QCannedQuery(QString const &scope_id)
Creates a query for given scope with empty query string.
Definition: QCannedQuery.cpp:28
FilterState filter_state() const
Get state of the filters for this CannedQuery.
Definition: QCannedQuery.cpp:105
void set_query_string(QString const &query_str)
Sets or updates the query string.
Definition: QCannedQuery.cpp:80