unity.scopes.ValueSliderFilter

A value slider filter that allows for selecting a value within a given range. More...

#include <unity/scopes/ValueSliderFilter.h>

Inheritance diagram for unity::scopes::ValueSliderFilter: src="https://assets.ubuntu.com/v1/8bd25e27-classunity_1_1scopes_1_1_value_slider_filter__inherit__graph.png" border="0" alt="Inheritance graph"/>

Public Member Functions

void set_default_value (double val)
 Change the default value of this filter. More...
 
double default_value () const
 Get the default value of this filter. More...
 
double min () const
 Get the minimum allowed value. More...
 
double max () const
 Get the maximum allowed value. More...
 
bool has_value (FilterState const &filter_state) const
 Check if filter state object holds a value of this filter. More...
 
double value (FilterState const &filter_state) const
 Get value of this filter from filter state object. More...
 
ValueSliderLabels const & labels () const
 Get value labeles for this slider filter. More...
 
void update_state (FilterState &filter_state, double value) const
 Sets value of this filter instance in filter state object. More...
 
src="https://assets.ubuntu.com/v1/c6607712-closed.png" alt="-"/> Public Member Functions inherited from unity::scopes::FilterBase
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 ValueSliderFilter::UPtr create (std::string const &id, double min, double max, double default_value, ValueSliderLabels const &value_labels)
 Create ValueSliderFilter. More...
 
static ValueSliderFilter::UPtr create (std::string const &id, double min, double max, double default_value, ValueSliderLabels const &value_labels, FilterGroup::SCPtr const &group)
 Create ValueSliderFilter inside a FilterGroup. More...
 
static void update_state (FilterState &filter_state, std::string const &filter_id, double value)
 Sets value of this filter instance in filter state object, without having an instance of ValueSliderFilter. More...
 

Additional Inherited Members

src="https://assets.ubuntu.com/v1/c6607712-closed.png" alt="-"/> Public Types inherited from unity::scopes::FilterBase
enum  DisplayHints { Default = 0, Primary = 1 }
 Display hints for the Shell UI. More...
 

Detailed Description

A value slider filter that allows for selecting a value within a given range.

The ValueSliderFilter allows for selecting a value within a range defined by minimum and maximum values. Both minimum and maximum values can have labels and, in addition, the scope may provide extra labels to mark other values from that range - these label will serve as a guidance to the user.

Member Function Documentation

ValueSliderFilter::UPtr unity::scopes::ValueSliderFilter::create ( std::string const &  id,
double  min,
double  max,
double  default_value,
ValueSliderLabels const &  value_labels 
)
static

Create ValueSliderFilter.

Creates ValueSliderFilter of ValueSliderFilter::SliderType::LessThan type.

Parameters
idA unique identifier for the filter that can be used to later identify it among several filters.
minThe minimum allowed value
maxThe maximum allowed value
default_valueThe default value of this filter, from the min..max range.
value_labelsThe labels for min and max values as well as optional extra labels.
Returns
Instance of ValueSliderFilter.
Exceptions
unity::LogicExceptionon invalid (min, max) range or erroneous value_labels.
ValueSliderFilter::UPtr unity::scopes::ValueSliderFilter::create ( std::string const &  id,
double  min,
double  max,
double  default_value,
ValueSliderLabels const &  value_labels,
FilterGroup::SCPtr const &  group 
)
static

Create ValueSliderFilter inside a FilterGroup.

Creates ValueSliderFilter of ValueSliderFilter::SliderType::LessThan type.

Parameters
idA unique identifier for the filter that can be used to later identify it among several filters.
minThe minimum allowed value
maxThe maximum allowed value
default_valueThe default value of this filter, from the min..max range.
value_labelsThe labels for min and max values as well as optional extra labels.
groupA filter group this filter should be added to.
Returns
Instance of ValueSliderFilter.
Exceptions
unity::LogicExceptionon invalid (min, max) range or erroneous value_labels.
double unity::scopes::ValueSliderFilter::default_value ( ) const

Get the default value of this filter.

The default value will be used by the shell if no value is present for this filter in the unity::scopes::FilterState (no value has been set by the user).

Returns
The default value
bool unity::scopes::ValueSliderFilter::has_value ( FilterState const &  filter_state) const

Check if filter state object holds a value of this filter.

Returns
true if filter_state has a value of this filter.
ValueSliderLabels const & unity::scopes::ValueSliderFilter::labels ( ) const

Get value labeles for this slider filter.

Returns
the value labels.
double unity::scopes::ValueSliderFilter::max ( ) const

Get the maximum allowed value.

Returns
maximum value
double unity::scopes::ValueSliderFilter::min ( ) const

Get the minimum allowed value.

Returns
mimimum value
void unity::scopes::ValueSliderFilter::set_default_value ( double  val)

Change the default value of this filter.

The default value will be used by the shell if no value is present for this filter in the unity::scopes::FilterState (no value has been set by the user).

Parameters
valThe new default value.
void unity::scopes::ValueSliderFilter::update_state ( FilterState filter_state,
double  value 
) const

Sets value of this filter instance in filter state object.

This is meant to be used to modify a FilterState received with a search request before sending it back to the client (UI shell).

Exceptions
unity::LogicExceptionif value is out of (min, max) range.
void unity::scopes::ValueSliderFilter::update_state ( FilterState filter_state,
std::string const &  filter_id,
double  value 
)
static

Sets value of this filter instance in filter state object, without having an instance of ValueSliderFilter.

Updates an instance of FilterState, without the need for an ValueSliderFilter instance. This is meant to be used when creating a canned Query that references another scope.

double unity::scopes::ValueSliderFilter::value ( FilterState const &  filter_state) const

Get value of this filter from filter state object.

Returns
value of this filter or the default value if value is not present in the filter_state.