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 <unity/scopes/FilterGroup.h>
25 #include <string>
26 #include <list>
27 #include <set>
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 class FilterState;
35 
36 namespace internal
37 {
38 class OptionSelectorFilterImpl;
39 class FilterBaseImpl;
40 }
41 
47 {
48 public:
50  UNITY_DEFINES_PTRS(OptionSelectorFilter);
52 
63  static OptionSelectorFilter::UPtr create(std::string const& id, std::string const& label, bool multi_select = false);
64 
69  std::string label() const;
70 
75  bool multi_select() const;
76 
83  FilterOption::SCPtr add_option(std::string const& id, std::string const& label);
84 
89  std::list<FilterOption::SCPtr> options() const;
90 
96  bool has_active_option(FilterState const& filter_state) const;
97 
106  std::set<FilterOption::SCPtr> active_options(FilterState const& filter_state) const;
107 
114  void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const;
115 
122  static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value);
123 
131  FilterOption::SCPtr add_option(std::string const& id, std::string const& label, bool value);
132 
145  static OptionSelectorFilter::UPtr create(std::string const& id, std::string const& label, FilterGroup::SCPtr const& group, bool multi_select = false);
146 
147 private:
148  OptionSelectorFilter(internal::OptionSelectorFilterImpl*);
149  internal::OptionSelectorFilterImpl* fwd() const;
150  friend class internal::OptionSelectorFilterImpl;
151 };
152 
153 } // namespace scopes
154 
155 } // namespace unity
A selection filter that displays a list of choices and allows one or more of them to be selected...
Definition: OptionSelectorFilter.h:46
Base class for all implementations of filters.
Definition: FilterBase.h:47
Top-level namespace for all things Unity-related.
Definition: Version.h:49
Definition: ActionMetadata.h:31
Stores the state of multiple filters.
Definition: FilterState.h:46