unity.scopes.OptionSelectorFilter
A selection filter that displays a list of choices and allows one or more of them to be selected. More...
#include <unity/scopes/OptionSelectorFilter.h>
Inheritance diagram for unity::scopes::OptionSelectorFilter:
src="https://assets.ubuntu.com/v1/200f368f-classunity_1_1scopes_1_1_option_selector_filter__inherit__graph.png" border="0" alt="Inheritance graph"/>
Public Member Functions | |
| std::string | label () const | 
| Get the label of this filter.  More... | |
| bool | multi_select () const | 
| Check if this filter supports multiple options to be selected.  More... | |
| FilterOption::SCPtr | add_option (std::string const &id, std::string const &label) | 
| Add a new option to this filter. The option is 'off' by default.  More... | |
| std::list< FilterOption::SCPtr > | options () const | 
| Get all options of this filter, in the order they were added.  More... | |
| bool | has_active_option (FilterState const &filter_state) const | 
| Check if an option is active for this filter.  More... | |
| std::set< FilterOption::SCPtr > | active_options (FilterState const &filter_state) const | 
| Get the active options from a FilterState instance for this filter.  More... | |
| void | update_state (FilterState &filter_state, FilterOption::SCPtr option, bool active) const | 
| Marks given FilterOption of this filter instance as active (or not active) in a FilterState object.  More... | |
| FilterOption::SCPtr | add_option (std::string const &id, std::string const &label, bool value) | 
| Add a new option to this filter and provide its default value.  More... | |
| void | set_display_hints (int hints) | 
| Sets display hints for the Shell UI.  More... | |
| int | display_hints () const | 
| Get display hints of this filter.  More... | |
| std::string | id () const | 
| Get the identifier of this filter.  More... | |
| std::string | filter_type () const | 
| Get the type name of this filter.  More... | |
| void | set_title (std::string const &title) | 
| Set an optional title of this filter.  More... | |
| std::string | title () const | 
| Get the optional title of this filter.  More... | |
| FilterGroup::SCPtr | filter_group () const | 
| Get the filter group this filter belongs to.  More... | |
Static Public Member Functions | |
| static OptionSelectorFilter::UPtr | create (std::string const &id, std::string const &label, bool multi_select=false) | 
| Creates an OpionSelectorFilter.  More... | |
| static void | update_state (FilterState &filter_state, std::string const &filter_id, std::string const &option_id, bool value) | 
| Marks an option of a filter active/inactive in a FilterState object, without having an instance of OptionSelectorFilter.  More... | |
| static OptionSelectorFilter::UPtr | create (std::string const &id, std::string const &label, FilterGroup::SCPtr const &group, bool multi_select=false) | 
| Creates an OpionSelectorFilter inside a FilterGroup.  More... | |
Additional Inherited Members | |
| enum | DisplayHints { Default = 0, Primary = 1 } | 
| Display hints for the Shell UI.  More... | |
Detailed Description
A selection filter that displays a list of choices and allows one or more of them to be selected.
Member Function Documentation
| std::set< FilterOption::SCPtr > unity::scopes::OptionSelectorFilter::active_options | ( | FilterState const & | filter_state | ) | const | 
Get the active options from a FilterState instance for this filter.
The returned set may be empty if the user de-selected all options. However, if there is no state recorded for this filter in the filter_state instance, then all the options enabled by default are returned.
- Returns
 - The set of selected filter options (or options enabled by default if the filter is not present in the filter_state).
 
| FilterOption::SCPtr unity::scopes::OptionSelectorFilter::add_option | ( | std::string const & | id, | 
| std::string const & | label | ||
| ) | 
Add a new option to this filter. The option is 'off' by default.
- Exceptions
 - 
unity::InvalidArgumentException on invalid id or label  
- Returns
 - The new option instance.
 
| FilterOption::SCPtr unity::scopes::OptionSelectorFilter::add_option | ( | std::string const & | id, | 
| std::string const & | label, | ||
| bool | value | ||
| ) | 
Add a new option to this filter and provide its default value.
- Exceptions
 - 
unity::LogicException if multiple options with value of 'true' are provided for a single-selection OptionSelectorFilter. unity::InvalidArgumentException on invalid id or label  
- Returns
 - The new option instance.
 
  | 
static | 
Creates an OpionSelectorFilter.
- Parameters
 - 
id A unique identifier for the filter that can be used to later identify it among several filters. label A display label for the filter. multi_select If true, the filter permits more than option to be selected; otherwise, only a single option can be selected.  
- Note
 - The multi-selection cannot be combined with unity::scopes::FilterBase::DisplayHints::Primary flag set via unity::scopes::FilterBase::set_display_hints().
 
  | 
static | 
Creates an OpionSelectorFilter inside a FilterGroup.
- Parameters
 - 
id A unique identifier for the filter that can be used to later identify it among several filters. label A display label for the filter. group A filter group this filter should be added to. multi_select If true, the filter permits more than option to be selected; otherwise, only a single option can be selected.  
- Exceptions
 - 
unity::InvalidArgumentException on invalid null group.  
- Note
 - The multi-selection cannot be combined with unity::scopes::FilterBase::DisplayHints::Primary flag set via unity::scopes::FilterBase::set_display_hints().
 
| bool unity::scopes::OptionSelectorFilter::has_active_option | ( | FilterState const & | filter_state | ) | const | 
Check if an option is active for this filter.
- Parameters
 - 
filter_state The state of filters  
- Returns
 - true if an option is active
 
| std::string unity::scopes::OptionSelectorFilter::label | ( | ) | const | 
Get the label of this filter.
- Returns
 - The filter label.
 
| bool unity::scopes::OptionSelectorFilter::multi_select | ( | ) | const | 
Check if this filter supports multiple options to be selected.
- Returns
 - True if multi-selection is enabled.
 
| std::list< FilterOption::SCPtr > unity::scopes::OptionSelectorFilter::options | ( | ) | const | 
Get all options of this filter, in the order they were added.
- Returns
 - The list of options.
 
| void unity::scopes::OptionSelectorFilter::update_state | ( | FilterState & | filter_state, | 
| FilterOption::SCPtr | option, | ||
| bool | active | ||
| ) | const | 
Marks given FilterOption of this filter instance as active (or not active) in a FilterState object.
Records the given FilterOption as "selected" in the FilterState. This is meant to be used to modify a FilterState received with a search request before sending it back to the client (UI shell).
  | 
static | 
Marks an option of a filter active/inactive in a FilterState object, without having an instance of OptionSelectorFilter.
Updates an instance of FilterState, without the need for an OptionSelectorFilter instance. This is meant to be used when creating a canned Query that references another scope.