Unity Scopes API
OptionSelectorFilter.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 #pragma once
20 
21 #include <unity/scopes/FilterBase.h>
22 #include <unity/scopes/FilterOption.h>
23 #include <unity/scopes/Variant.h>
24 #include <string>
25 #include <list>
26 #include <set>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 class FilterState;
34 
35 namespace internal
36 {
37 class OptionSelectorFilterImpl;
38 class FilterBaseImpl;
39 }
40 
46 {
47 public:
49  UNITY_DEFINES_PTRS(OptionSelectorFilter);
51 
62  static OptionSelectorFilter::UPtr create(std::string const& id, std::string const& label, bool multi_select = false);
63 
68  std::string label() const;
69 
74  bool multi_select() const;
75 
80  FilterOption::SCPtr add_option(std::string const& id, std::string const& label);
81 
86  std::list<FilterOption::SCPtr> options() const;
87 
93  bool has_active_option(FilterState const& filter_state) const;
94 
99  std::set<FilterOption::SCPtr> active_options(FilterState const& filter_state) const;
100 
107  void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const;
108 
115  static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value);
116 
117 private:
118  OptionSelectorFilter(internal::OptionSelectorFilterImpl*);
119  internal::OptionSelectorFilterImpl* fwd() const;
120  friend class internal::OptionSelectorFilterImpl;
121 };
122 
123 } // namespace scopes
124 
125 } // namespace unity
A selection filter that displays a list of choices and allows one or more of them to be selected...
Definition: OptionSelectorFilter.h:45
Base class for all implementations of filters.
Definition: FilterBase.h:46
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
Captures state of multiple filters.
Definition: FilterState.h:46