Unity Scopes API
QActionMetadata.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 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
29 #include <QtCore/QVariantMap>
30 #pragma GCC diagnostic pop
31 
32 namespace unity
33 {
34 
35 namespace scopes
36 {
37 
38 namespace qt
39 {
40 
41 class QPreviewQueryBaseAPI;
42 
43 namespace internal
44 {
45 class QActionMetadataImpl;
46 class QPreviewQueryBaseImpl;
47 }
48 
54 class QActionMetadata final
55 {
56 public:
58  UNITY_DEFINES_PTRS(QActionMetadata);
59 
60  ~QActionMetadata();
62 
68  QActionMetadata(QString const& locale, QString const& form_factor);
69 
74  void set_scope_data(QVariant const& data);
75 
80  QVariant scope_data() const;
81 
85  //{@
86  QActionMetadata(QActionMetadata const& other);
88 
89  QActionMetadata& operator=(QActionMetadata const& other);
90  QActionMetadata& operator=(QActionMetadata&&);
92 
99  void set_hint(QString const& key, QVariant const& value);
100 
107  QVariantMap hints() const;
108 
114  bool contains_hint(QString const& key) const;
115 
125  QVariant& operator[](QString const& key);
126 
136  QVariant const& operator[](QString const& key) const;
137 
138 private:
140  QActionMetadata(internal::QActionMetadataImpl* impl);
141 
142  std::unique_ptr<internal::QActionMetadataImpl> p;
143  friend class internal::QPreviewQueryBaseImpl;
144  friend class QPreviewQueryBaseAPI;
146 };
147 
148 } // namespace qt
149 
150 } // namespace scopes
151 
152 } // namespace unity
Metadata passed to scopes for preview and activation.
Definition: QActionMetadata.h:54
void set_hint(QString const &key, QVariant const &value)
Sets a hint.
QVariant & operator[](QString const &key)
Returns a reference to a hint.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
QVariant scope_data() const
Get data attached to this ActionMetadata.
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:72
void set_scope_data(QVariant const &data)
Attach arbitrary data to this ActionMetadata.
QVariantMap hints() const
Get all hints.
bool contains_hint(QString const &key) const
Check if this SearchMetadata has a hint.
QActionMetadata(QString const &locale, QString const &form_factor)
Create ActionMetadata with the given locale and form factor.