Unity Scopes API
QSearchQueryBase.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/util/NonCopyable.h>
23 #include <unity/scopes/SearchListenerBase.h>
24 #include <unity/scopes/QueryCtrlProxyFwd.h>
25 
26 #include <unity/scopes/qt/QSearchReplyProxy.h>
27 #include <unity/scopes/qt/QCannedQuery.h>
28 
29 #include <QtCore/QObject>
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 class SearchMetadata;
38 class CannedQuery;
39 
40 namespace qt
41 {
42 
43 namespace internal
44 {
45 class QSearchQueryBaseImpl;
46 }
47 
48 class QSearchQueryBaseAPI;
49 
58 class QSearchQueryBase : public QObject
59 {
60  Q_OBJECT
61 public:
63  NONCOPYABLE(QSearchQueryBase);
64  UNITY_DEFINES_PTRS(QSearchQueryBase);
66 
67  virtual ~QSearchQueryBase();
68 
75  QCannedQuery query() const;
76 
83 
95  //{@
96  QueryCtrlProxy subsearch(ScopeProxy const& scope,
97  std::string const& query_string,
98  SearchListenerBase::SPtr const& reply);
99  QueryCtrlProxy subsearch(ScopeProxy const& scope,
100  std::string const& query_string,
101  FilterState const& filter_state,
102  SearchListenerBase::SPtr const& reply);
103  QueryCtrlProxy subsearch(ScopeProxy const& scope,
104  std::string const& query_string,
105  std::string const& department_id,
106  FilterState const& filter_state,
107  SearchListenerBase::SPtr const& reply);
108  QueryCtrlProxy subsearch(ScopeProxy const& scope,
109  std::string const& query_string,
110  std::string const& department_id,
111  FilterState const& filter_state,
112  SearchMetadata const& hints,
113  SearchListenerBase::SPtr const& reply);
114 
115 public Q_SLOTS:
133  virtual void run(QSearchReplyProxy const& reply) = 0;
134 
145  virtual void cancelled() = 0; // Originator cancelled the query
146 
147 protected:
149  QSearchQueryBase(QObject* parent = 0);
150 
151 private:
152  void init(QSearchQueryBaseAPI* query_api);
153 
154  std::unique_ptr<internal::QSearchQueryBaseImpl> p;
155  friend class internal::QSearchQueryBaseImpl;
156  friend class QSearchQueryBaseAPI;
158 };
159 
160 } // namespace qt
161 
162 } // namespace scopes
163 
164 } // namespace unity
std::shared_ptr< Scope > ScopeProxy
Convenience type definition.
Definition: ScopeProxyFwd.h:34
Definition: HttpAsyncReader.h:45
Metadata passed with search requests.
Definition: SearchMetadata.h:43
virtual void cancelled()=0
Called by the scopes run time when the query originator cancels a query.
virtual void run(QSearchReplyProxy const &reply)=0
Called by scopes run time to start the query.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Parameters of a search query.
Definition: QCannedQuery.h:51
Abstract base class to represent a particular query.
Definition: QSearchQueryBaseAPI.h:59
Definition: ActionMetadata.h:31
Abstract base class to represent a particular query.
Definition: QSearchQueryBase.h:58
Captures state of multiple filters.
Definition: FilterState.h:46
QCannedQuery query() const
Get a canned query for this search request.
unity::scopes::SearchMetadata search_metadata() const
Get metadata for this search request.
std::shared_ptr< QueryCtrl > QueryCtrlProxy
Convenience type definition.
Definition: QueryCtrlProxyFwd.h:33