Unity Scopes API
|
A filter that allows for rating-based selection. More...
#include <unity/scopes/RatingFilter.h>
Public Member Functions | |
FilterOption::SCPtr | add_option (std::string const &id, std::string const &label) |
Adds a new option to the filter. More... | |
void | set_on_icon (std::string const &on_icon) |
Set a custom icon for the "on" state. More... | |
void | set_off_icon (std::string const &off_icon) |
Set a custom icon for the "off" state. More... | |
std::string | label () const |
Get the label of this filter. More... | |
std::string | on_icon () const |
Get custom icon for the "on" state. More... | |
std::string | off_icon () const |
Get custom icon for the "off" state. More... | |
std::list< FilterOption::SCPtr > | options () const |
Get all options of this filter, in the order they were added. More... | |
bool | has_active_rating (FilterState const &filter_state) const |
Check if a rating option is active. More... | |
FilterOption::SCPtr | active_rating (FilterState const &filter_state) const |
Get active option from an instance of FilterState 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... | |
![]() | |
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... | |
Static Public Member Functions | |
static RatingFilter::UPtr | create (std::string const &id, std::string const &label) |
Creates RatingFilter widget. More... | |
static RatingFilter::UPtr | create (std::string const &id, std::string const &label, int top_rating) |
Creates RatingFilter widget. 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... | |
Additional Inherited Members | |
![]() | |
enum | DisplayHints { Default = 0, Primary = 1 } |
Display hints for the Shell UI. More... | |
A filter that allows for rating-based selection.
Displays filter with a set of options, where every option has a label and icon. Only one option can be active at a time. The active option uses the icon in "on" state (see unity::scopes::RatingFilter::set_on_icon() ). All other icons are "off" (see unity::scopes::RatingFilter::set_off_icon() ). By default, "on" and "off" icons are bright and dim star respectively.
This filter is best suited for rating-based filtering.
FilterOption::SCPtr unity::scopes::RatingFilter::active_rating | ( | FilterState const & | filter_state | ) | const |
Get active option from an instance of FilterState for this filter.
FilterOption::SCPtr unity::scopes::RatingFilter::add_option | ( | std::string const & | id, |
std::string const & | label | ||
) |
Adds a new option to the filter.
id | A unique identifier of the option. |
label | A display label for the option |
|
static |
Creates RatingFilter widget.
Creates an empty RatingFilter widget. Use unity::scopes::RatingFilter::add_option() to add rating options to it.
id | A unique identifier for the filter that can be used to identify it later among several filters. |
label | A display label for this filter |
|
static |
Creates RatingFilter widget.
Creates a RatingFilter widget and populates it with some standard rating options. This is a convienience factory method, that fills RatingFilter in with options for ratings from 1 up to top_rating. Options are created with identifiers "1", "2" and so on, and labels "1+", "2+" etc., except for that last label, which is just the number (no plus sign). The maximum top_rating allowed is 10.
id | A unique identifier for the filter that can be used to identify it later among several filters. |
label | A display label for this filter |
top_rating | The maximum rating allowed. |
bool unity::scopes::RatingFilter::has_active_rating | ( | FilterState const & | filter_state | ) | const |
Check if a rating option is active.
filter_state | The state of filters |
std::string unity::scopes::RatingFilter::label | ( | ) | const |
Get the label of this filter.
std::string unity::scopes::RatingFilter::off_icon | ( | ) | const |
Get custom icon for the "off" state.
If empty, then the default icon will be used.
std::string unity::scopes::RatingFilter::on_icon | ( | ) | const |
Get custom icon for the "on" state.
If empty, then the default icon will be used.
std::list< FilterOption::SCPtr > unity::scopes::RatingFilter::options | ( | ) | const |
Get all options of this filter, in the order they were added.
void unity::scopes::RatingFilter::set_off_icon | ( | std::string const & | off_icon | ) |
Set a custom icon for the "off" state.
If not set, a dim star icon will be used by default.
off_icon | icon uri |
void unity::scopes::RatingFilter::set_on_icon | ( | std::string const & | on_icon | ) |
Set a custom icon for the "on" state.
If not set, a star icon will be used by default.
on_icon | icon uri |
void unity::scopes::RatingFilter::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). Only one option can be active at a time - marking an option active automatically deactivates any other option.
|
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.