Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 #ifndef UNITY_SCOPES_RATINGFILTER_H
20 #define UNITY_SCOPES_RATINGFILTER_H
21 
22 #include <unity/scopes/FilterBase.h>
23 #include <unity/scopes/FilterOption.h>
24 
25 namespace unity
26 {
27 
28 namespace scopes
29 {
30 
31 class FilterState;
32 
33 namespace internal
34 {
35 
36 class RatingFilterImpl;
37 
38 }
39 
50 class UNITY_API RatingFilter : public FilterBase
51 {
52 public:
54  UNITY_DEFINES_PTRS(RatingFilter);
56 
65  static RatingFilter::UPtr create(std::string const& id, std::string const& label);
66 
81  static RatingFilter::UPtr create(std::string const& id, std::string const& label, int top_rating);
82 
90  FilterOption::SCPtr add_option(std::string const& id, std::string const& label);
91 
99  void set_on_icon(std::string const& on_icon);
100 
108  void set_off_icon(std::string const& off_icon);
109 
114  std::string label() const;
115 
123  std::string on_icon() const;
124 
132  std::string off_icon() const;
133 
138  std::list<FilterOption::SCPtr> options() const;
139 
145  bool has_active_rating(FilterState const& filter_state) const;
146 
151  FilterOption::SCPtr active_rating(FilterState const& filter_state) const;
152 
160  void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const;
161 
168  static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value);
169 
170 private:
171  RatingFilter(internal::RatingFilterImpl*);
172  internal::RatingFilterImpl* fwd() const;
173  friend class internal::RatingFilterImpl;
174 };
175 
176 } // namespace scopes
177 
178 } // namespace unity
179 
180 #endif
A filter that allows for rating-based selection.
Definition: RatingFilter.h:50
Base class for all implementations of filters.
Definition: FilterBase.h:47
Captures state of multiple filters.
Definition: FilterState.h:47