Unity Scopes Qt library
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 #include <unity/util/DefinesPtrs.h>
22 #include <unity/util/NonCopyable.h>
23 #include <unity/scopes/SearchReply.h>
24 #include <unity/scopes/SearchReplyProxyFwd.h>
25 
26 #include <unity/scopes/qt/QCategory.h>
27 #include <unity/scopes/qt/QDepartment.h>
28 
29 #include <QtCore/QString>
30 
31 #include <memory>
32 
33 namespace unity
34 {
35 
36 namespace scopes
37 {
38 
39 namespace qt
40 {
41 class QSearchQueryBase;
42 class QCategorisedResult;
43 
44 namespace internal
45 {
46 class QSearchReplyImpl;
47 }
48 
52 class QSearchReply : public QObject
53 {
54  Q_OBJECT
55 public:
57  NONCOPYABLE(QSearchReply);
58  UNITY_DEFINES_PTRS(QSearchReply);
60 
63  virtual ~QSearchReply();
64 
110  virtual void register_departments(QDepartment::SCPtr const& parent);
111 
123  virtual QCategory::SCPtr register_category(
124  QString const& id,
125  QString const& title,
126  QString const& icon,
127  unity::scopes::CategoryRenderer const& renderer_template = unity::scopes::CategoryRenderer());
128 
140  virtual bool push(QCategorisedResult const& result);
141 
150  virtual void error(std::exception_ptr ex);
151 
152 private:
153  QSearchReply(unity::scopes::SearchReplyProxy& reply, QObject* parent = 0);
154 
155  std::unique_ptr<internal::QSearchReplyImpl> p;
156  friend class internal::QSearchReplyImpl;
157  friend class QSearchQueryBaseAPI;
158 };
159 
160 } // namespace unity
161 
162 } // namespace scopes
163 
164 } // namespace unity
A result, including the category it belongs to.
Definition: QCategorisedResult.h:43
Allows the results of a search query to be sent to the query source.
Definition: QSearchReply.h:52
virtual bool push(QCategorisedResult const &result)
Sends a single result to the source of a query.
virtual ~QSearchReply()
Destroys a QSearchReply.
virtual void register_departments(QDepartment::SCPtr const &parent)
Register departments for the current search reply and provide the current department.
virtual void error(std::exception_ptr ex)
Informs the source of a query that the query was terminated due to an error.
Definition: HttpAsyncReader.h:39
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.
Abstract base class to represent a particular query.
Definition: QSearchQueryBaseAPI.h:59