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 #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 
28 #include <unity/scopes/SearchQueryBase.h>
29 #include <unity/scopes/qt/QSearchQueryBase.h>
30 
31 #include <QtCore/QObject>
32 
33 class QCoreApplication;
34 
35 namespace unity
36 {
37 
38 namespace scopes
39 {
40 
41 namespace qt
42 {
43 
44 namespace tests
45 {
46 class QSearchQueryBaseAPIMock;
47 }
48 
49 namespace internal
50 {
51 class QScopeBaseAPIImpl;
52 }
53 
54 class QScopeBase;
55 class QScopeBaseAPI;
56 
69 {
70  Q_OBJECT
71 public:
73  NONCOPYABLE(QSearchQueryBaseAPI);
74  UNITY_DEFINES_PTRS(QSearchQueryBaseAPI);
75 
76  virtual ~QSearchQueryBaseAPI();
77 
78 protected:
79  QSearchQueryBaseAPI(std::shared_ptr<QCoreApplication> qtapp,
80  QScopeBase& qtscope,
82  unity::scopes::SearchMetadata const& metadata,
83  QObject* parent = 0);
84 
85  bool event(QEvent* e) override;
87 
105  virtual void run(SearchReplyProxy const& reply) final;
106 
117  virtual void cancelled() final; // Originator cancelled the query
118 
120  std::shared_ptr<QCoreApplication> qtapp_;
121  std::unique_ptr<QSearchQueryBase> qtquery_;
122  QScopeBase& qtscope_;
123 
124 private:
125  void init();
126  friend unity::scopes::qt::tests::QSearchQueryBaseAPIMock;
127  friend internal::QScopeBaseAPIImpl;
128 
129 Q_SIGNALS:
130  void run_signal(QSearchReplyProxy const&);
132 };
133 
134 } // namespace qt
135 
136 } // namespace scopes
137 
138 } // namespace unity
Metadata passed with search requests.
Definition: SearchMetadata.h:45
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:68
Definition: ActionMetadata.h:31
Parameters of a search query.
Definition: CannedQuery.h:49
Abstract base class to represent a particular query.
Definition: SearchQueryBase.h:66
Base class for a scope implementation.
Definition: QScopeBase.h:115
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.