Unity Scopes API
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 #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 
27 #include <unity/scopes/ScopeProxyFwd.h>
28 
29 #include <QtCore/QString>
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
32 #include <QtCore/QVariant>
33 #pragma GCC diagnostic pop
34 
35 namespace unity
36 {
37 
38 namespace scopes
39 {
40 
41 class Variant;
42 class Result;
43 
44 namespace qt
45 {
46 
47 class QCategorisedResult;
48 
49 namespace internal
50 {
51 class QResultImpl;
52 class QPreviewQueryBaseImpl;
53 }
54 
63 class QResult
64 {
65 public:
67  UNITY_DEFINES_PTRS(QResult);
69 
73  //{@
74  QResult(QResult const& other);
75  QResult(QResult&&);
76 
77  QResult& operator=(QResult const& other);
78  QResult& operator=(QResult&&);
80 
84  virtual ~QResult();
85 
98  void store(QResult const& other, bool intercept_activation = false);
99 
104  bool has_stored_result() const;
105 
111  QResult retrieve() const;
112 
116  void set_uri(QString const& uri);
117 
123  void set_title(QString const& title);
129  void set_art(QString const& image);
130 
136  void set_dnd_uri(QString const& dnd_uri);
137 
151 
157  bool direct_activation() const;
158 
168 
179  QVariant& operator[](QString const& key);
180 
190  QVariant const& operator[](QString const& key) const;
191 
199  QString uri() const noexcept;
200 
208  QString title() const noexcept;
209 
217  QString art() const noexcept;
218 
226  QString dnd_uri() const noexcept;
227 
233  bool contains(QString const& key) const;
234 
242  QVariant const& value(QString const& key) const;
243 
248  QVariantMap serialize() const;
249 
250 protected:
252  explicit QResult(const QVariantMap& variant_map);
253  explicit QResult(internal::QResultImpl* impl);
254  explicit QResult(unity::scopes::Result const& result);
255 
256 private:
257  std::unique_ptr<internal::QResultImpl> p;
258 
259  friend class internal::QResultImpl;
260  friend class QCategorisedResult;
261  friend class internal::QPreviewQueryBaseImpl;
262  friend class QPreviewQueryBaseAPI;
264 };
265 
266 } // namespace qt
267 
268 } // namespace scopes
269 
270 } // namespace unity
A result, including the category it belongs to.
Definition: QCategorisedResult.h:47
std::shared_ptr< Scope > ScopeProxy
Convenience type definition.
Definition: ScopeProxyFwd.h:34
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.
The attributes of a result returned by a Scope.
Definition: Result.h:50
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.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
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:63
Definition: ActionMetadata.h:31
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:72
QString uri() const noexcept
Get the "uri" property of this Result.
QVariantMap serialize() const
Returns a dictionary of all attributes of this Result instance.