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>
A selection filter that displays a list of choices and allows one or more of them to be selected.
§ active_options()
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).
§ add_option() [1/2]
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.
§ add_option() [2/2]
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.
§ create() [1/2]
OptionSelectorFilter::UPtr unity::scopes::OptionSelectorFilter::create |
( |
std::string const & |
id, |
|
|
std::string const & |
label, |
|
|
bool |
multi_select = false |
|
) |
| |
|
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().
§ create() [2/2]
OptionSelectorFilter::UPtr unity::scopes::OptionSelectorFilter::create |
( |
std::string const & |
id, |
|
|
std::string const & |
label, |
|
|
FilterGroup::SCPtr const & |
group, |
|
|
bool |
multi_select = false |
|
) |
| |
|
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().
§ has_active_option()
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
§ label()
std::string unity::scopes::OptionSelectorFilter::label |
( |
| ) |
const |
Get the label of this filter.
- Returns
- The filter label.
§ multi_select()
bool unity::scopes::OptionSelectorFilter::multi_select |
( |
| ) |
const |
Check if this filter supports multiple options to be selected.
- Returns
- True if multi-selection is enabled.
§ options()
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.
§ update_state() [1/2]
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).
§ update_state() [2/2]
void unity::scopes::OptionSelectorFilter::update_state |
( |
FilterState & |
filter_state, |
|
|
std::string const & |
filter_id, |
|
|
std::string const & |
option_id, |
|
|
bool |
value |
|
) |
| |
|
static |
The documentation for this class was generated from the following files: