Unity Scopes Qt library
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 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
27 #include <QtCore/QVariantMap>
28 #pragma GCC diagnostic pop
29 
30 namespace unity
31 {
32 
33 namespace scopes
34 {
35 
36 class CannedQuery;
37 
38 namespace qt
39 {
40 
41 namespace internal
42 {
43 class QCannedQueryImpl;
44 class QSearchQueryBaseImpl;
45 class QDepartmentImpl;
46 }
47 
54 class QCannedQuery final
55 {
56 public:
58  UNITY_DEFINES_PTRS(QCannedQuery);
60 
64  explicit QCannedQuery(QString const& scope_id);
65 
69  QCannedQuery(QString const& scope_id, QString const& query_str, QString const& department_id);
70 
74  //{@
75  QCannedQuery(QCannedQuery const& other);
77  QCannedQuery& operator=(QCannedQuery const& other);
78  QCannedQuery& operator=(QCannedQuery&&);
80 
82  ~QCannedQuery();
84 
88  void set_department_id(QString const& dep_id);
89 
93  void set_query_string(QString const& query_str);
94 
98  void set_filter_state(FilterState const& filter_state);
99 
104  QString scope_id() const;
105 
110  QString department_id() const;
111 
116  QString query_string() const;
117 
119  QVariantMap serialize() const;
121 
126  QString to_uri() const;
127 
135  FilterState filter_state() const;
136 
143  static QCannedQuery from_uri(QString const& uri);
144 
145 private:
146  QCannedQuery(internal::QCannedQueryImpl* impl);
147  QCannedQuery(CannedQuery const& api_query);
148  std::unique_ptr<internal::QCannedQueryImpl> p;
149  friend class internal::QCannedQueryImpl;
150  friend class internal::QSearchQueryBaseImpl;
151  friend class internal::QDepartmentImpl;
152 };
153 
154 } // namespace qt
155 
156 } // namespace scopes
157 
158 } // namespace unity
void set_filter_state(FilterState const &filter_state)
Sets filter state.
Definition: HttpAsyncReader.h:39
Parameters of a search query.
Definition: QCannedQuery.h:54
QCannedQuery(QString const &scope_id)
Creates a query for given scope with empty query string.
static QCannedQuery from_uri(QString const &uri)
Recreates a CannedQuery object from a scope:// URI.
FilterState filter_state() const
Get state of the filters for this CannedQuery.
QString scope_id() const
Returns the scope identifier of this CannedQuery.
void set_query_string(QString const &query_str)
Sets or updates the query string.
QString department_id() const
Returns the department id of this CannedQuery.
void set_department_id(QString const &dep_id)
Sets or updates the department.
QString to_uri() const
Returns a string representation of this CannedQuery object as a URI using scope:// schema...
QString query_string() const
Returns the query string of this CannedQuery.