Unity Scopes Qt library
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 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
27 #include <QtCore/QVariantMap>
28 #pragma GCC diagnostic pop
29 
30 namespace unity
31 {
32 
33 namespace scopes
34 {
35 
36 namespace qt
37 {
38 
39 namespace internal
40 {
41 class QSearchMetadataImpl;
42 }
43 
47 class QSearchMetadata final
48 {
49 public:
51  UNITY_DEFINES_PTRS(QSearchMetadata);
53 
59  QSearchMetadata(QString const& locale, QString const& form_factor);
60 
67  QSearchMetadata(int cardinality, QString const& locale, QString const& form_factor);
68 
72  //{@
73  QSearchMetadata(QSearchMetadata const& other);
75 
76  QSearchMetadata& operator=(QSearchMetadata const& other);
77  QSearchMetadata& operator=(QSearchMetadata&&);
79 
81  ~QSearchMetadata();
83 
88  void set_cardinality(int cardinality);
89 
94  int cardinality() const;
95 
100  void set_location(Location const& location);
101 
107  Location location() const;
108 
113  bool has_location() const;
114 
121  void set_hint(QString const& key, QVariant const& value);
122 
129  QVariantMap hints() const;
130 
136  bool contains_hint(QString const& key) const;
137 
147  QVariant& operator[](QString const& key);
148 
158  QVariant const& operator[](QString const& key) const;
159 
160 private:
162  std::unique_ptr<internal::QSearchMetadataImpl> p;
163  friend class internal::QSearchMetadataImpl;
165 };
166 
167 } // namespace qt
168 
169 } // namespace scopes
170 
171 } // 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.
Definition: HttpAsyncReader.h:39
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.
Metadata passed with search requests.
Definition: QSearchMetadata.h:47