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 #include <unity/util/DefinesPtrs.h>
22 #include <unity/scopes/Location.h>
23 
24 #include <QtCore/QString>
25 #include <QtCore/QVariantMap>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 namespace qt
34 {
35 
36 namespace internal
37 {
38 class QSearchMetadataImpl;
39 }
40 
44 class QSearchMetadata final
45 {
46 public:
48  UNITY_DEFINES_PTRS(QSearchMetadata);
50 
56  QSearchMetadata(QString const& locale, QString const& form_factor);
57 
64  QSearchMetadata(int cardinality, QString const& locale, QString const& form_factor);
65 
69  //{@
70  QSearchMetadata(QSearchMetadata const& other);
72 
73  QSearchMetadata& operator=(QSearchMetadata const& other);
74  QSearchMetadata& operator=(QSearchMetadata&&);
76 
78  ~QSearchMetadata();
80 
85  void set_cardinality(int cardinality);
86 
91  int cardinality() const;
92 
97  void set_location(Location const& location);
98 
104  Location location() const;
105 
110  bool has_location() const;
111 
118  void set_hint(QString const& key, QVariant const& value);
119 
126  QVariantMap hints() const;
127 
133  bool contains_hint(QString const& key) const;
134 
144  QVariant& operator[](QString const& key);
145 
155  QVariant const& operator[](QString const& key) const;
156 
157 private:
159  std::unique_ptr<internal::QSearchMetadataImpl> p;
160  friend class internal::QSearchMetadataImpl;
162 };
163 
164 } // namespace qt
165 
166 } // namespace scopes
167 
168 } // namespace unity
void set_cardinality(int cardinality)
Set cardinality.
QVariantMap hints() const
Get all hints.
Location location() const
Get location.
Definition: HttpAsyncReader.h:45
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.
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:44