Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RadioButtonsFilter.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_RADIOBUTTONSFILTER_H
20 #define UNITY_SCOPES_RADIOBUTTONSFILTER_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 RadioButtonsFilterImpl;
37 
38 }
39 
45 class UNITY_API RadioButtonsFilter : public FilterBase
46 {
47 public:
49  UNITY_DEFINES_PTRS(RadioButtonsFilter);
51 
60  static RadioButtonsFilter::UPtr create(std::string const& id, std::string const& label);
61 
69  FilterOption::SCPtr add_option(std::string const& id, std::string const& label);
70 
75  std::string label() const;
76 
81  FilterOption::SCPtr active_option(FilterState const& filter_state) const;
82 
88  bool has_active_option(FilterState const& filter_state) const;
89 
90 
95  std::list<FilterOption::SCPtr> options() const;
96 
104  void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const;
105 
112  static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value);
113 
114 private:
115  RadioButtonsFilter(internal::RadioButtonsFilterImpl*);
116  internal::RadioButtonsFilterImpl* fwd() const;
117  friend class internal::RadioButtonsFilterImpl;
118 };
119 
120 } // namespace scopes
121 
122 } // namespace unity
123 
124 #endif
Base class for all implementations of filters.
Definition: FilterBase.h:47
A filter that displays mutually exclusive list of options.
Definition: RadioButtonsFilter.h:45
Captures state of multiple filters.
Definition: FilterState.h:47