Unity Scopes API
QPreviewQueryBase.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/PreviewReplyProxyFwd.h>
25 
26 #include <unity/scopes/qt/QActionMetadata.h>
27 #include <unity/scopes/qt/QCannedQuery.h>
28 #include <unity/scopes/qt/QPreviewReplyProxy.h>
29 #include <unity/scopes/qt/QResult.h>
30 
31 #include <QtCore/QObject>
32 
33 namespace unity
34 {
35 
36 namespace scopes
37 {
38 
39 class SearchMetadata;
40 class CannedQuery;
41 class ActionMetadata;
42 
43 namespace qt
44 {
45 
46 class QResult;
47 
48 namespace internal
49 {
50 class QPreviewQueryBaseImpl;
51 }
52 
53 class QPreviewQueryBaseAPI;
54 
63 class QPreviewQueryBase : public QObject
64 {
65  Q_OBJECT
66 public:
68  NONCOPYABLE(QPreviewQueryBase);
69  UNITY_DEFINES_PTRS(QPreviewQueryBase);
71 
72  virtual ~QPreviewQueryBase();
73 
91  virtual void run(unity::scopes::qt::QPreviewReplyProxy const& reply) = 0;
92 
103  virtual void cancelled() = 0; // Originator cancelled the query
104 
110  QResult result() const;
111 
118 
119 protected:
121  QPreviewQueryBase(QObject* parent = 0);
122 
123 private:
124  void init(QPreviewQueryBaseAPI* query_api);
125 
126  std::unique_ptr<internal::QPreviewQueryBaseImpl> p;
127  friend class internal::QPreviewQueryBaseImpl;
128  friend class QPreviewQueryBaseAPI;
130 };
131 
132 } // namespace qt
133 
134 } // namespace scopes
135 
136 } // namespace unity
virtual void run(unity::scopes::qt::QPreviewReplyProxy const &reply)=0
Called by scopes run time to start the query.
Definition: HttpAsyncReader.h:45
Metadata passed to scopes for preview and activation.
Definition: QActionMetadata.h:46
Top-level namespace for all things Unity-related.
Definition: Version.h:49
The attributes of a result returned by a Scope.
Definition: QResult.h:56
Definition: ActionMetadata.h:31
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:63
QActionMetadata action_metadata() const
Get metadata for this preview request.
virtual void cancelled()=0
Called by the scopes run time when the query originator cancels a query.
QResult result() const
Get result for this preview request.
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBase.h:63