Unity Scopes API
RatingFilter.h
1 /*
2  * Copyright (C) 2014 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 #pragma once
20 
21 #include <unity/scopes/FilterBase.h>
22 #include <unity/scopes/FilterOption.h>
23 
24 namespace unity
25 {
26 
27 namespace scopes
28 {
29 
30 class FilterState;
31 
32 namespace internal
33 {
34 
35 class RatingFilterImpl;
36 
37 }
38 
39 namespace experimental
40 {
41 
52 class UNITY_API RatingFilter : public FilterBase
53 {
54 public:
56  UNITY_DEFINES_PTRS(RatingFilter);
58 
67  static RatingFilter::UPtr create(std::string const& id, std::string const& label);
68 
83  static RatingFilter::UPtr create(std::string const& id, std::string const& label, int top_rating);
84 
92  FilterOption::SCPtr add_option(std::string const& id, std::string const& label);
93 
101  void set_on_icon(std::string const& on_icon);
102 
110  void set_off_icon(std::string const& off_icon);
111 
116  std::string label() const;
117 
125  std::string on_icon() const;
126 
134  std::string off_icon() const;
135 
140  std::list<FilterOption::SCPtr> options() const;
141 
147  bool has_active_rating(FilterState const& filter_state) const;
148 
153  FilterOption::SCPtr active_rating(FilterState const& filter_state) const;
154 
162  void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const;
163 
170  static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value);
171 
172 private:
173  RatingFilter(internal::RatingFilterImpl*);
174  internal::RatingFilterImpl* fwd() const;
175  friend class internal::RatingFilterImpl;
176 };
177 
178 } // namespace experimental
179 
180 } // namespace scopes
181 
182 } // namespace unity
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31