Unity Scopes Qt library
QResult.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 
23 #include <unity/scopes/ScopeProxyFwd.h>
24 
25 #include <QtCore/QString>
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
28 #include <QtCore/QVariant>
29 #pragma GCC diagnostic pop
30 
31 namespace unity
32 {
33 
34 namespace scopes
35 {
36 
37 class Variant;
38 class Result;
39 
40 namespace qt
41 {
42 
43 class QCategorisedResult;
44 
45 namespace internal
46 {
47 class QResultImpl;
48 class QPreviewQueryBaseImpl;
49 }
50 
59 class QResult
60 {
61 public:
63  UNITY_DEFINES_PTRS(QResult);
65 
66  QResult();
70  //{@
71  QResult(QResult const& other);
72  QResult(QResult&&);
73 
74  QResult& operator=(QResult const& other);
75  QResult& operator=(QResult&&);
77 
81  virtual ~QResult();
82 
95  void store(QResult const& other, bool intercept_activation = false);
96 
101  bool has_stored_result() const;
102 
108  QResult retrieve() const;
109 
113  void set_uri(QString const& uri);
114 
120  void set_title(QString const& title);
126  void set_art(QString const& image);
127 
133  void set_dnd_uri(QString const& dnd_uri);
134 
148 
154  bool direct_activation() const;
155 
164  ScopeProxy target_scope_proxy() const;
165 
176  QVariant& operator[](QString const& key);
177 
187  QVariant const& operator[](QString const& key) const;
188 
196  QString uri() const noexcept;
197 
205  QString title() const noexcept;
206 
214  QString art() const noexcept;
215 
223  QString dnd_uri() const noexcept;
224 
230  bool contains(QString const& key) const;
231 
239  QVariant const& value(QString const& key) const;
240 
245  QVariantMap serialize() const;
246 
247 protected:
249  explicit QResult(const QVariantMap& variant_map);
250  explicit QResult(internal::QResultImpl* impl);
251  explicit QResult(unity::scopes::Result const& result);
252 
253 private:
254  std::unique_ptr<internal::QResultImpl> p;
255 
256  friend class internal::QResultImpl;
257  friend class QCategorisedResult;
258  friend class internal::QPreviewQueryBaseImpl;
259  friend class QPreviewQueryBaseAPI;
261 };
262 
263 } // namespace qt
264 
265 } // namespace scopes
266 
267 } // namespace unity
A result, including the category it belongs to.
Definition: QCategorisedResult.h:43
bool direct_activation() const
Check if this result should be activated directly by the shell because the scope doesn't handle activ...
void set_title(QString const &title)
Set the "title" attribute of this result.
void set_art(QString const &image)
Set the "art" attribute of this result.
bool contains(QString const &key) const
Check if this Result has an attribute.
ScopeProxy target_scope_proxy() const
Get the proxy of a scope that handles activation and preview of this result.
void set_uri(QString const &uri)
Set the "uri" attribute of this result.
QString dnd_uri() const noexcept
Get the "dnd_uri" property of this Result.
QVariant & operator[](QString const &key)
Returns reference of a Result attribute.
QVariant const & value(QString const &key) const
Get the value of an attribute.
QString art() const noexcept
Get the "art" property of this Result.
bool has_stored_result() const
Check if this Result instance has a stored result.
Definition: HttpAsyncReader.h:39
QResult retrieve() const
Get a stored result.
QString title() const noexcept
Get the "title" property of this Result.
void set_intercept_activation()
Indicates to the receiver that this scope should intercept activation requests for this result...
The attributes of a result returned by a Scope.
Definition: QResult.h:59
void set_dnd_uri(QString const &dnd_uri)
Set the "dnd_uri" attribute of this result.
void store(QResult const &other, bool intercept_activation=false)
Stores a Result inside this Result instance.
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:63
QString uri() const noexcept
Get the "uri" property of this Result.
QVariantMap serialize() const
Returns a dictionary of all attributes of this Result instance.