Unity Scopes API
QPreviewQueryBaseAPI.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/PreviewQueryBase.h>
29 #include <unity/scopes/PreviewReplyProxyFwd.h>
30 #include <unity/scopes/qt/QPreviewQueryBase.h>
31 
32 #include <QtCore/QObject>
33 
34 class QCoreApplication;
35 
36 namespace unity
37 {
38 
39 namespace scopes
40 {
41 
42 class Result;
43 class ActionMetadata;
44 
45 namespace qt
46 {
47 
48 namespace tests
49 {
50 class QPreviewQueryBaseAPIMock;
51 }
52 
53 namespace internal
54 {
55 class QScopeBaseAPIImpl;
56 }
57 
58 class QScopeBase;
59 class QScopeBaseAPI;
60 
73 {
74  Q_OBJECT
75 public:
77  NONCOPYABLE(QPreviewQueryBaseAPI);
78  UNITY_DEFINES_PTRS(QPreviewQueryBaseAPI);
79 
80  virtual ~QPreviewQueryBaseAPI();
81 
82 protected:
83  QPreviewQueryBaseAPI(std::shared_ptr<QCoreApplication> qtapp,
84  QScopeBase& qtscope,
86  unity::scopes::ActionMetadata const& metadata,
87  QObject* parent = 0);
88 
89  bool event(QEvent* e) override;
91 
109  virtual void run(unity::scopes::PreviewReplyProxy const& reply) final;
110 
121  virtual void cancelled() final; // Originator cancelled the query
122 
124  std::shared_ptr<QCoreApplication> qtapp_;
125  std::unique_ptr<QPreviewQueryBase> qtquery_;
126  QScopeBase& qtscope_;
127 
128 private:
129  void init();
130 
131  friend internal::QScopeBaseAPIImpl;
132  friend unity::scopes::qt::tests::QPreviewQueryBaseAPIMock;
134 };
135 
136 } // namespace qt
137 
138 } // namespace scopes
139 
140 } // namespace unity
virtual void cancelled() final
Called by the scopes run time when the query originator cancels a query.
Result result() const
Get result for this preview request.
Definition: PreviewQueryBase.cpp:42
Metadata passed to scopes for preview and activation.
Definition: ActionMetadata.h:41
The attributes of a result returned by a Scope.
Definition: Result.h:50
Abstract base class to represent a particular preview.
Definition: PreviewQueryBase.h:57
Top-level namespace for all things Unity-related.
Definition: Version.h:49
virtual void run(unity::scopes::PreviewReplyProxy const &reply) final
Called by scopes run time to start the query.
Definition: ActionMetadata.h:31
std::shared_ptr< PreviewReply > PreviewReplyProxy
Convenience type definition.
Definition: PreviewReplyProxyFwd.h:34
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:72
Base class for a scope implementation.
Definition: QScopeBase.h:115