Unity Scopes API
QSearchQueryBaseAPI.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 
24 #include <unity/scopes/SearchQueryBase.h>
25 #include <unity/scopes/qt/QSearchQueryBase.h>
26 
27 #include <QtCore/QObject>
28 
29 class QCoreApplication;
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 namespace qt
38 {
39 
40 namespace internal
41 {
42 class QScopeBaseAPIImpl;
43 }
44 
45 class QScopeBase;
46 class QScopeBaseAPI;
47 
60 {
61  Q_OBJECT
62 public:
64  NONCOPYABLE(QSearchQueryBaseAPI);
65  UNITY_DEFINES_PTRS(QSearchQueryBaseAPI);
66 
67  virtual ~QSearchQueryBaseAPI();
68 
69 protected:
70  QSearchQueryBaseAPI(std::shared_ptr<QCoreApplication> qtapp,
71  QScopeBase& qtscope,
73  unity::scopes::SearchMetadata const& metadata,
74  QObject* parent = 0);
75 
76  bool event(QEvent* e) override;
78 
96  virtual void run(SearchReplyProxy const& reply) final;
97 
108  virtual void cancelled() final; // Originator cancelled the query
109 
111  std::shared_ptr<QCoreApplication> qtapp_;
112  std::unique_ptr<QSearchQueryBase> qtquery_;
113  QScopeBase& qtscope_;
114 
115  friend internal::QScopeBaseAPIImpl;
116 
117 Q_SIGNALS:
118  void run_signal(QSearchReplyProxy const&);
120 };
121 
122 } // namespace qt
123 
124 } // namespace scopes
125 
126 } // namespace unity
Definition: HttpAsyncReader.h:45
Metadata passed with search requests.
Definition: SearchMetadata.h:43
Top-level namespace for all things Unity-related.
Definition: Version.h:49
virtual void run(SearchReplyProxy const &reply) final
Called by scopes run time to start the query.
Abstract base class to represent a particular query.
Definition: QSearchQueryBaseAPI.h:59
Definition: ActionMetadata.h:31
Parameters of a search query.
Definition: CannedQuery.h:45
Abstract base class to represent a particular query.
Definition: SearchQueryBase.h:63
Base class for a scope implementation.
Definition: QScopeBase.h:113
std::shared_ptr< SearchReply > SearchReplyProxy
Convenience type definition.
Definition: SearchReplyProxyFwd.h:34
virtual void cancelled() final
Called by the scopes run time when the query originator cancels a query.
CannedQuery query() const
Get a canned query for this search request.