Unity Scopes API
QSearchReply.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 #include <unity/scopes/SearchReply.h>
28 #include <unity/scopes/SearchReplyProxyFwd.h>
29 
30 #include <unity/scopes/qt/QCategory.h>
31 #include <unity/scopes/qt/QDepartment.h>
32 
33 #include <QtCore/QString>
34 
35 #include <memory>
36 
37 namespace unity
38 {
39 
40 namespace scopes
41 {
42 
43 namespace qt
44 {
45 class QSearchQueryBase;
46 class QCategorisedResult;
47 
48 namespace internal
49 {
50 class QSearchReplyImpl;
51 }
52 
56 class QSearchReply : public QObject
57 {
58  Q_OBJECT
59 public:
61  NONCOPYABLE(QSearchReply);
62  UNITY_DEFINES_PTRS(QSearchReply);
64 
67  virtual ~QSearchReply();
68 
114  virtual void register_departments(QDepartment::SCPtr const& parent);
115 
127  virtual QCategory::SCPtr register_category(
128  QString const& id,
129  QString const& title,
130  QString const& icon,
132 
144  virtual bool push(QCategorisedResult const& result);
145 
154  virtual void error(std::exception_ptr ex);
155 
156 private:
157  QSearchReply(unity::scopes::SearchReplyProxy& reply, QObject* parent = 0);
158 
159  std::unique_ptr<internal::QSearchReplyImpl> p;
160  friend class QSearchQueryBaseAPI;
161 };
162 
163 } // namespace unity
164 
165 } // namespace scopes
166 
167 } // namespace unity
A result, including the category it belongs to.
Definition: QCategorisedResult.h:47
Allows the results of a search query to be sent to the query source.
Definition: QSearchReply.h:56
virtual QCategory::SCPtr register_category(QString const &id, QString const &title, QString const &icon, unity::scopes::CategoryRenderer const &renderer_template=unity::scopes::CategoryRenderer())
Register new category and send it to the source of the query.
Definition: QSearchReply.cpp:40
A category renderer template in JSON format.
Definition: CategoryRenderer.h:83
virtual bool push(QCategorisedResult const &result)
Sends a single result to the source of a query.
Definition: QSearchReply.cpp:49
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Abstract base class to represent a particular query.
Definition: QSearchQueryBaseAPI.h:68
Definition: ActionMetadata.h:31
virtual void register_departments(QDepartment::SCPtr const &parent)
Register departments for the current search reply and provide the current department.
Definition: QSearchReply.cpp:35
std::shared_ptr< SearchReply > SearchReplyProxy
Convenience type definition.
Definition: SearchReplyProxyFwd.h:34
virtual void error(std::exception_ptr ex)
Informs the source of a query that the query was terminated due to an error.
Definition: QSearchReply.cpp:54
virtual ~QSearchReply()
Destroys a QSearchReply.
Definition: QSearchReply.cpp:31