Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Annotation.h
1 /*
2  * Copyright (C) 2013 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: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_ANNOTATION_H
20 #define UNITY_SCOPES_ANNOTATION_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <unity/scopes/Link.h>
24 #include <unity/util/DefinesPtrs.h>
25 #include <list>
26 #include <memory>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 class CannedQuery;
34 
35 namespace internal
36 {
37 class AnnotationImpl;
38 class ResultReplyObject;
39 }
40 
45 class Annotation final
46 {
47 public:
49  UNITY_DEFINES_PTRS(Annotation);
51 
55  enum Type
56  {
57  Link,
59  };
60 
65  explicit Annotation(Type atype);
66 
70  //{@
71  Annotation(Annotation const &other);
73  Annotation& operator=(Annotation const& other);
74  Annotation& operator=(Annotation&&);
76 
78  virtual ~Annotation();
80 
84  void set_label(std::string const& label);
85 
89  void set_icon(std::string const& icon);
90 
97  void add_link(std::string const& label, CannedQuery const& query);
98 
103  std::string label() const;
104 
109  std::string icon() const;
110 
115  std::list<Link::SCPtr> links() const;
116 
121  Type annotation_type() const;
122 
124  VariantMap serialize() const;
126 
127 private:
128  Annotation(internal::AnnotationImpl* impl);
129  std::unique_ptr<internal::AnnotationImpl> p;
130 
131  friend class internal::ResultReplyObject;
132 };
133 
134 } // namespace scopes
135 
136 } // namespace unity
137 
138 #endif
Query link(s) that result in a new search query when clicked by the user.
Definition: Annotation.h:45
Definition: Annotation.h:57
std::list< Link::SCPtr > links() const
Returns all links assigned to given position of this annotation.
Definition: Annotation.cpp:93
std::string icon() const
Returns icon assigned to this annotation. This currently only makes sense for Type::Link.
Definition: Annotation.cpp:88
Annotation(Type atype)
Creates annotation of given type. The Type imposes attributes that are supported or required by that ...
Definition: Annotation.cpp:29
std::string label() const
Returns label assigned to this annotation. This currently makes sense for Type::GroupedLink only...
Definition: Annotation.cpp:83
Type
Enumeration of supported Annotation types.
Definition: Annotation.h:55
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
void add_link(std::string const &label, CannedQuery const &query)
Adds a link to the annotation. There needs to be exactly one link added for the annotations of type T...
Definition: Annotation.cpp:78
Type annotation_type() const
Returns the type of this annotation.
Definition: Annotation.cpp:98
void set_label(std::string const &label)
Sets a label for an annotation. This currently makes sense for Type::GroupedLink only.
Definition: Annotation.cpp:68
Definition: Annotation.h:58
Parameters of a search query.
Definition: CannedQuery.h:46
void set_icon(std::string const &icon)
Sets an icon for an annotation. This currently makes sense for Type::Link.
Definition: Annotation.cpp:73