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 #include <unity/util/DefinesPtrs.h>
22 #include <unity/scopes/FilterState.h>
23 
24 #include <QtCore/QString>
25 #include <QtCore/QVariantMap>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 class CannedQuery;
34 
35 namespace qt
36 {
37 
38 namespace internal
39 {
40 class QCannedQueryImpl;
41 class QSearchQueryBaseImpl;
42 class QDepartmentImpl;
43 }
44 
51 class QCannedQuery final
52 {
53 public:
55  UNITY_DEFINES_PTRS(QCannedQuery);
57 
61  explicit QCannedQuery(QString const& scope_id);
62 
66  QCannedQuery(QString const& scope_id, QString const& query_str, QString const& department_id);
67 
71  //{@
72  QCannedQuery(QCannedQuery const& other);
74  QCannedQuery& operator=(QCannedQuery const& other);
75  QCannedQuery& operator=(QCannedQuery&&);
77 
79  ~QCannedQuery();
81 
85  void set_department_id(QString const& dep_id);
86 
90  void set_query_string(QString const& query_str);
91 
96 
101  QString scope_id() const;
102 
107  QString department_id() const;
108 
113  QString query_string() const;
114 
116  QVariantMap serialize() const;
118 
123  QString to_uri() const;
124 
132  FilterState filter_state() const;
133 
140  static QCannedQuery from_uri(QString const& uri);
141 
142 private:
143  QCannedQuery(internal::QCannedQueryImpl* impl);
144  QCannedQuery(CannedQuery const& api_query);
145  std::unique_ptr<internal::QCannedQueryImpl> p;
146  friend class internal::QCannedQueryImpl;
147  friend class internal::QSearchQueryBaseImpl;
148  friend class internal::QDepartmentImpl;
149 };
150 
151 } // namespace qt
152 
153 } // namespace scopes
154 
155 } // namespace unity
Definition: HttpAsyncReader.h:45
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:51
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:45
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
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