Unity Scopes Qt library
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 #pragma once
19 
20 #include <unity/util/DefinesPtrs.h>
21 
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
24 #include <QtCore/QVariantMap>
25 #pragma GCC diagnostic pop
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 namespace qt
34 {
35 
36 class QPreviewQueryBaseAPI;
37 
38 namespace internal
39 {
40 class QActionMetadataImpl;
41 class QPreviewQueryBaseImpl;
42 }
43 
49 class QActionMetadata final
50 {
51 public:
53  UNITY_DEFINES_PTRS(QActionMetadata);
54 
55  ~QActionMetadata();
57 
63  QActionMetadata(QString const& locale, QString const& form_factor);
64 
69  void set_scope_data(QVariant const& data);
70 
75  QVariant scope_data() const;
76 
80  //{@
81  QActionMetadata(QActionMetadata const& other);
83 
84  QActionMetadata& operator=(QActionMetadata const& other);
85  QActionMetadata& operator=(QActionMetadata&&);
87 
94  void set_hint(QString const& key, QVariant const& value);
95 
102  QVariantMap hints() const;
103 
109  bool contains_hint(QString const& key) const;
110 
120  QVariant& operator[](QString const& key);
121 
131  QVariant const& operator[](QString const& key) const;
132 
133 private:
135  QActionMetadata(internal::QActionMetadataImpl* impl);
136 
137  std::unique_ptr<internal::QActionMetadataImpl> p;
138  friend class internal::QActionMetadataImpl;
139  friend class internal::QPreviewQueryBaseImpl;
140  friend class QPreviewQueryBaseAPI;
142 };
143 
144 } // namespace qt
145 
146 } // namespace scopes
147 
148 } // namespace unity
Metadata passed to scopes for preview and activation.
Definition: QActionMetadata.h:49
void set_hint(QString const &key, QVariant const &value)
Sets a hint.
QVariant & operator[](QString const &key)
Returns a reference to a hint.
Definition: HttpAsyncReader.h:39
QVariant scope_data() const
Get data attached to this ActionMetadata.
Abstract base class to represent a particular preview.
Definition: QPreviewQueryBaseAPI.h:63
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.