Unity Scopes API
QSearchMetadata.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 #include <unity/scopes/Location.h>
27 
28 #include <QtCore/QString>
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
31 #include <QtCore/QVariantMap>
32 #pragma GCC diagnostic pop
33 
34 namespace unity
35 {
36 
37 namespace scopes
38 {
39 
40 namespace qt
41 {
42 
43 namespace internal
44 {
45 class QSearchMetadataImpl;
46 }
47 
51 class QSearchMetadata final
52 {
53 public:
55  UNITY_DEFINES_PTRS(QSearchMetadata);
57 
63  QSearchMetadata(QString const& locale, QString const& form_factor);
64 
71  QSearchMetadata(int cardinality, QString const& locale, QString const& form_factor);
72 
76  //{@
77  QSearchMetadata(QSearchMetadata const& other);
79 
80  QSearchMetadata& operator=(QSearchMetadata const& other);
81  QSearchMetadata& operator=(QSearchMetadata&&);
83 
85  ~QSearchMetadata();
87 
92  void set_cardinality(int cardinality);
93 
98  int cardinality() const;
99 
104  void set_location(Location const& location);
105 
111  Location location() const;
112 
117  bool has_location() const;
118 
124  void remove_location();
125 
132  void set_hint(QString const& key, QVariant const& value);
133 
140  QVariantMap hints() const;
141 
147  bool contains_hint(QString const& key) const;
148 
158  QVariant& operator[](QString const& key);
159 
169  QVariant const& operator[](QString const& key) const;
170 
171 private:
173  std::unique_ptr<internal::QSearchMetadataImpl> p;
175 };
176 
177 } // namespace qt
178 
179 } // namespace scopes
180 
181 } // namespace unity
void set_cardinality(int cardinality)
Set cardinality.
QVariantMap hints() const
Get all hints.
Location location() const
Get location.
int cardinality() const
Get cardinality.
bool contains_hint(QString const &key) const
Check if this SearchMetadata has a hint.
void set_hint(QString const &key, QVariant const &value)
Sets a hint.
void remove_location()
Remove location data entirely.
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
QVariant & operator[](QString const &key)
Returns a reference to a hint.
bool has_location() const
Does the SearchMetadata have a location.
void set_location(Location const &location)
Set location.
QSearchMetadata(QString const &locale, QString const &form_factor)
Create SearchMetadata with the given locale and form factor.
Holds location attributes such as latitude, longitude, etc.
Definition: Location.h:39
Metadata passed with search requests.
Definition: QSearchMetadata.h:51