Unity Scopes Qt library
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 #include <unity/util/DefinesPtrs.h>
22 #include <unity/util/NonCopyable.h>
23 
24 #include <unity/scopes/PreviewQueryBase.h>
25 #include <unity/scopes/PreviewReplyProxyFwd.h>
26 #include <unity/scopes/qt/QPreviewQueryBase.h>
27 
28 #include <QtCore/QObject>
29 
30 class QCoreApplication;
31 
32 namespace unity
33 {
34 
35 namespace scopes
36 {
37 
38 class Result;
39 class ActionMetadata;
40 
41 namespace qt
42 {
43 
44 namespace internal
45 {
46 class QScopeBaseAPIImpl;
47 }
48 
49 class QScopeBase;
50 class QScopeBaseAPI;
51 
63 class QPreviewQueryBaseAPI : public QObject, public unity::scopes::PreviewQueryBase
64 {
65  Q_OBJECT
66 public:
68  NONCOPYABLE(QPreviewQueryBaseAPI);
69  UNITY_DEFINES_PTRS(QPreviewQueryBaseAPI);
70 
71  virtual ~QPreviewQueryBaseAPI();
72 
73 protected:
74  QPreviewQueryBaseAPI(std::shared_ptr<QCoreApplication> qtapp,
75  QScopeBase& qtscope,
76  unity::scopes::Result const& result,
77  unity::scopes::ActionMetadata const& metadata,
78  QObject* parent = 0);
79 
80  bool event(QEvent* e) override;
82 
100  virtual void run(unity::scopes::PreviewReplyProxy const& reply) final;
101 
112  virtual void cancelled() final; // Originator cancelled the query
113 
115  std::shared_ptr<QCoreApplication> qtapp_;
116  std::unique_ptr<QPreviewQueryBase> qtquery_;
117  QScopeBase& qtscope_;
118 
119  friend internal::QScopeBaseAPIImpl;
121 };
122 
123 } // namespace qt
124 
125 } // namespace scopes
126 
127 } // namespace unity
virtual void cancelled() final
Called by the scopes run time when the query originator cancels a query.
Definition: HttpAsyncReader.h:39
virtual void run(unity::scopes::PreviewReplyProxy const &reply) final
Called by scopes run time to start the query.
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:63
Base class for a scope implementation.
Definition: QScopeBase.h:113