OpenHantek
LevelSlider Class Reference

Slider widget for multiple level sliders. These are used for the trigger levels, offsets and so on. More...

#include <levelslider.h>

Inheritance diagram for LevelSlider:

Signals

void valueChanged (int index, double value)
 The value of a slider has changed. More...
 

Public Member Functions

 LevelSlider (Qt::ArrowType direction=Qt::RightArrow, QWidget *parent=nullptr)
 Initializes the slider container. More...
 
 ~LevelSlider ()
 Cleans up the widget. More...
 
QSize sizeHint () const
 Size hint for the widget. More...
 
int preMargin () const
 Return the margin before the slider. More...
 
int postMargin () const
 Return the margin after the slider. More...
 
int addSlider (int index=-1)
 Add a new slider to the slider container. More...
 
int addSlider (const QString &text, int index=-1)
 Add a new slider to the slider container. More...
 
int removeSlider (int index=-1)
 Remove a slider from the slider container. More...
 
const QColor color (int index) const
 Return the color of a slider. More...
 
void setColor (unsigned index, QColor color)
 Set the color of the slider. More...
 
const QString text (int index) const
 Return the text shown beside a slider. More...
 
int setText (int index, const QString &text)
 Set the text for a slider. More...
 
bool visible (int index) const
 Return the visibility of a slider. More...
 
void setIndexVisible (unsigned index, bool visible)
 Set the visibility of a slider. More...
 
double minimum (int index) const
 Return the minimal value of the sliders. More...
 
double maximum (int index) const
 Return the maximal value of the sliders. More...
 
void setLimits (int index, double minimum, double maximum)
 Set the maximal value of the sliders. More...
 
double step (int index) const
 Return the step width of the sliders. More...
 
double setStep (int index, double step)
 Set the step width of the sliders. More...
 
double value (int index) const
 Return the current position of a slider. More...
 
void setValue (int index, double value)
 Set the current position of a slider. More...
 
Qt::ArrowType direction () const
 Return the direction of the sliders. More...
 
int setDirection (Qt::ArrowType direction)
 Set the direction of the sliders. More...
 

Protected Member Functions

void mouseMoveEvent (QMouseEvent *event)
 Move the slider if it's pressed. More...
 
void mousePressEvent (QMouseEvent *event)
 Prepare slider for movement if the left mouse button is pressed. More...
 
void mouseReleaseEvent (QMouseEvent *event)
 Movement is done if the left mouse button is released. More...
 
void paintEvent (QPaintEvent *event)
 Paint the widget. More...
 
void resizeEvent (QResizeEvent *event)
 Resize the widget and adapt the slider positions. More...
 
QRect calculateRect (int sliderId)
 Calculate the drawing area for the slider for it's current value. More...
 
int calculateWidth ()
 Search for the widest slider element. More...
 
void fixValue (int index)
 Fix the value if it's outside the limits. More...
 

Protected Attributes

QList< LevelSliderParameters * > slider
 The parameters for each slider. More...
 
int pressedSlider
 The currently pressed (moved) slider. More...
 
int sliderWidth
 
Qt::ArrowType _direction
 The direction the sliders point to. More...
 
int _preMargin
 The margin before the minimum slider position. More...
 
int _postMargin
 The margin after the maximum slider position. More...
 

Detailed Description

Slider widget for multiple level sliders. These are used for the trigger levels, offsets and so on.

Constructor & Destructor Documentation

◆ LevelSlider()

LevelSlider::LevelSlider ( Qt::ArrowType  direction = Qt::RightArrow,
QWidget *  parent = nullptr 
)

Initializes the slider container.

Parameters
directionThe side on which the sliders are shown.
parentThe parent widget.

◆ ~LevelSlider()

LevelSlider::~LevelSlider ( )

Cleans up the widget.

Member Function Documentation

◆ addSlider() [1/2]

int LevelSlider::addSlider ( int  index = -1)

Add a new slider to the slider container.

Parameters
indexThe index where the slider should be inserted, 0 to append.
Returns
The index of the slider, -1 on error.

◆ addSlider() [2/2]

int LevelSlider::addSlider ( const QString &  text,
int  index = -1 
)

Add a new slider to the slider container.

Parameters
textThe text that will be shown next to the slider.
indexThe index where the slider should be inserted, 0 to append.
Returns
The index of the slider, -1 on error.

◆ calculateRect()

QRect LevelSlider::calculateRect ( int  sliderId)
protected

Calculate the drawing area for the slider for it's current value.

Parameters
sliderIdThe id of the slider whose rect should be calculated.
Returns
The calculated rect.

◆ calculateWidth()

int LevelSlider::calculateWidth ( )
protected

Search for the widest slider element.

Returns
The calculated width of the slider.

◆ color()

const QColor LevelSlider::color ( int  index) const

Return the color of a slider.

Parameters
indexThe index of the slider whose color should be returned.
Returns
The current color of the slider.

◆ direction()

Qt::ArrowType LevelSlider::direction ( ) const

Return the direction of the sliders.

Returns
The side on which the sliders are shown.

◆ fixValue()

void LevelSlider::fixValue ( int  index)
protected

Fix the value if it's outside the limits.

Parameters
indexThe index of the slider who should be fixed.
Returns
0 when ok, -1 on error, 1 when increased and 2 when decreased.

◆ maximum()

double LevelSlider::maximum ( int  index) const

Return the maximal value of the sliders.

Returns
The value a slider has at the topmost/rightmost position.

◆ minimum()

double LevelSlider::minimum ( int  index) const

Return the minimal value of the sliders.

Returns
The value a slider has at the bottommost/leftmost position.

◆ mouseMoveEvent()

void LevelSlider::mouseMoveEvent ( QMouseEvent *  event)
protected

Move the slider if it's pressed.

Parameters
eventThe mouse event that should be handled.

◆ mousePressEvent()

void LevelSlider::mousePressEvent ( QMouseEvent *  event)
protected

Prepare slider for movement if the left mouse button is pressed.

Parameters
eventThe mouse event that should be handled.

◆ mouseReleaseEvent()

void LevelSlider::mouseReleaseEvent ( QMouseEvent *  event)
protected

Movement is done if the left mouse button is released.

Parameters
eventThe mouse event that should be handled.

◆ paintEvent()

void LevelSlider::paintEvent ( QPaintEvent *  event)
protected

Paint the widget.

Parameters
eventThe paint event that should be handled.

◆ postMargin()

int LevelSlider::postMargin ( ) const

Return the margin after the slider.

Returns
The margin the Slider has at the bottom/right.

◆ preMargin()

int LevelSlider::preMargin ( ) const

Return the margin before the slider.

Returns
The margin the Slider has at the top/left.

◆ removeSlider()

int LevelSlider::removeSlider ( int  index = -1)

Remove a slider from the slider container.

Parameters
indexThe index of the slider that should be removed.
Returns
The index of the removed slider, -1 on error.

◆ resizeEvent()

void LevelSlider::resizeEvent ( QResizeEvent *  event)
protected

Resize the widget and adapt the slider positions.

Parameters
eventThe resize event that should be handled.

◆ setColor()

void LevelSlider::setColor ( unsigned  index,
QColor  color 
)

Set the color of the slider.

Parameters
indexThe index of the slider whose color should be set.
colorThe new color for the slider.
Returns
The index of the slider, -1 on error.

◆ setDirection()

int LevelSlider::setDirection ( Qt::ArrowType  direction)

Set the direction of the sliders.

Parameters
directionThe side on which the sliders are shown.
Returns
The index of the direction, -1 on error.

◆ setIndexVisible()

void LevelSlider::setIndexVisible ( unsigned  index,
bool  visible 
)

Set the visibility of a slider.

Parameters
indexThe index of the slider whose visibility should be set.
visibletrue to show the slider, false to hide it.
Returns
The index of the slider, -1 on error.

◆ setLimits()

void LevelSlider::setLimits ( int  index,
double  minimum,
double  maximum 
)

Set the maximal value of the sliders.

Parameters
indexThe index of the slider whose limits should be set.
minimumThe value a slider has at the bottommost/leftmost position.
maximumThe value a slider has at the topmost/rightmost position.
Returns
-1 on error, fixValue result on success.

◆ setStep()

double LevelSlider::setStep ( int  index,
double  step 
)

Set the step width of the sliders.

Parameters
indexThe index of the slider whose step width should be set.
stepThe distance between the selectable slider positions.
Returns
The new step width.

◆ setText()

int LevelSlider::setText ( int  index,
const QString &  text 
)

Set the text for a slider.

Parameters
indexThe index of the slider whose text should be set.
textThe text shown next to the slider.
Returns
The index of the slider, -1 on error.

◆ setValue()

void LevelSlider::setValue ( int  index,
double  value 
)

Set the current position of a slider.

Parameters
indexThe index of the slider whose value should be set.
valueThe new value of the slider.
Returns
The new value of the slider.

◆ sizeHint()

QSize LevelSlider::sizeHint ( ) const

Size hint for the widget.

Returns
The recommended size for the widget.

◆ step()

double LevelSlider::step ( int  index) const

Return the step width of the sliders.

Parameters
indexThe index of the slider whose step width should be returned.
Returns
The distance between the selectable slider positions.

◆ text()

const QString LevelSlider::text ( int  index) const

Return the text shown beside a slider.

Parameters
indexThe index of the slider whose text should be returned.
Returns
The current text of the slider.

◆ value()

double LevelSlider::value ( int  index) const

Return the current position of a slider.

Parameters
indexThe index of the slider whose value should be returned.
Returns
The value of the slider.

◆ valueChanged

void LevelSlider::valueChanged ( int  index,
double  value 
)
signal

The value of a slider has changed.

◆ visible()

bool LevelSlider::visible ( int  index) const

Return the visibility of a slider.

Parameters
indexThe index of the slider whose visibility should be returned.
Returns
true if the slider is visible, false if it's hidden.

Field Documentation

◆ _direction

Qt::ArrowType LevelSlider::_direction
protected

The direction the sliders point to.

◆ _postMargin

int LevelSlider::_postMargin
protected

The margin after the maximum slider position.

◆ _preMargin

int LevelSlider::_preMargin
protected

The margin before the minimum slider position.

◆ pressedSlider

int LevelSlider::pressedSlider
protected

The currently pressed (moved) slider.

◆ slider

QList<LevelSliderParameters *> LevelSlider::slider
protected

The parameters for each slider.

◆ sliderWidth

int LevelSlider::sliderWidth
protected

The slider width (dimension orthogonal to the sliding direction)


The documentation for this class was generated from the following files: