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 #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/util/NonCopyable.h>
27 #include <unity/scopes/SearchListenerBase.h>
28 #include <unity/scopes/QueryCtrlProxyFwd.h>
29 
30 #include <unity/scopes/qt/QSearchReplyProxy.h>
31 #include <unity/scopes/qt/QCannedQuery.h>
32 
33 #include <QtCore/QObject>
34 
35 namespace unity
36 {
37 
38 namespace scopes
39 {
40 
41 class SearchMetadata;
42 class CannedQuery;
43 
44 namespace qt
45 {
46 
47 namespace internal
48 {
49 class QSearchQueryBaseImpl;
50 }
51 
52 class QSearchQueryBaseAPI;
53 
62 class QSearchQueryBase : public QObject
63 {
64  Q_OBJECT
65 public:
67  NONCOPYABLE(QSearchQueryBase);
68  UNITY_DEFINES_PTRS(QSearchQueryBase);
70 
71  virtual ~QSearchQueryBase();
72 
79  QCannedQuery query() const;
80 
87 
99  //{@
100  QueryCtrlProxy subsearch(ScopeProxy const& scope,
101  std::string const& query_string,
102  SearchListenerBase::SPtr const& reply);
103  QueryCtrlProxy subsearch(ScopeProxy const& scope,
104  std::string const& query_string,
105  FilterState const& filter_state,
106  SearchListenerBase::SPtr const& reply);
107  QueryCtrlProxy subsearch(ScopeProxy const& scope,
108  std::string const& query_string,
109  std::string const& department_id,
110  FilterState const& filter_state,
111  SearchListenerBase::SPtr const& reply);
112  QueryCtrlProxy subsearch(ScopeProxy const& scope,
113  std::string const& query_string,
114  std::string const& department_id,
115  FilterState const& filter_state,
116  SearchMetadata const& hints,
117  SearchListenerBase::SPtr const& reply);
118 
119 public Q_SLOTS:
137  virtual void run(QSearchReplyProxy const& reply) = 0;
138 
149  virtual void cancelled() = 0; // Originator cancelled the query
150 
151 protected:
153  QSearchQueryBase(QObject* parent = 0);
154 
155 private:
156  void init(QSearchQueryBaseAPI* query_api);
157 
158  std::unique_ptr<internal::QSearchQueryBaseImpl> p;
159  friend class QSearchQueryBaseAPI;
161 };
162 
163 } // namespace qt
164 
165 } // namespace scopes
166 
167 } // namespace unity
std::shared_ptr< Scope > ScopeProxy
Convenience type definition.
Definition: ScopeProxyFwd.h:34
Metadata passed with search requests.
Definition: SearchMetadata.h:45
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:58
Abstract base class to represent a particular query.
Definition: QSearchQueryBaseAPI.h:68
Definition: ActionMetadata.h:31
Abstract base class to represent a particular query.
Definition: QSearchQueryBase.h:62
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