Krita Source Code Documentation
Loading...
Searching...
No Matches
KisDoubleParseSpinBox Class Reference

The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions. More...

#include <kis_double_parse_spin_box.h>

+ Inheritance diagram for KisDoubleParseSpinBox:

Signals

void errorWhileParsing (const QString &expr) const
 signal emitted when the last parsed expression is not valid.
 
void noMoreParsingError () const
 signal emitted when the last parsed expression is valid and the expression before was not valid.
 

Public Member Functions

bool isLastValid () const
 Get if the last expression entered is a valid one.
 
 KisDoubleParseSpinBox (QWidget *parent=0)
 
void setValue (double value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps) override
 This is a reimplementation of QDoubleSpinBox::stepBy that uses setValue.
 
virtual QString veryCleanText () const
 This virtual function is similar to cleanText(). But child classes may reimplement it to further process ("clean up") the expression.
 
 ~KisDoubleParseSpinBox () override
 

Protected Member Functions

QString textFromValue (double value) const override
 
QValidator::State validate (QString &input, int &pos) const override
 
double valueFromText (const QString &text) const override
 

Private Attributes

QScopedPointer< KisParseSpinBoxPrivate< KisDoubleParseSpinBox, QDoubleSpinBox > > d
 

Friends

template<typename SpinBoxTypeTP , typename BaseSpinBoxTypeTP >
class KisParseSpinBoxPrivate
 

Detailed Description

The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.

Use this spinbox instead of the basic one from Qt if you want it to be able to parse arithmetic expressions.

Definition at line 25 of file kis_double_parse_spin_box.h.

Constructor & Destructor Documentation

◆ KisDoubleParseSpinBox()

KisDoubleParseSpinBox::KisDoubleParseSpinBox ( QWidget * parent = 0)

Definition at line 13 of file kis_double_parse_spin_box.cpp.

13 :
14 QDoubleSpinBox(parent),
16{}
QScopedPointer< KisParseSpinBoxPrivate< KisDoubleParseSpinBox, QDoubleSpinBox > > d

◆ ~KisDoubleParseSpinBox()

KisDoubleParseSpinBox::~KisDoubleParseSpinBox ( )
override

Definition at line 18 of file kis_double_parse_spin_box.cpp.

19{}

Member Function Documentation

◆ errorWhileParsing

void KisDoubleParseSpinBox::errorWhileParsing ( const QString & expr) const
signal

signal emitted when the last parsed expression is not valid.

◆ isLastValid()

bool KisDoubleParseSpinBox::isLastValid ( ) const

Get if the last expression entered is a valid one.

Return values
trueif the last expression entered is valid
falseotherwise

Definition at line 31 of file kis_double_parse_spin_box.cpp.

32{
33 return d->isLastValid();
34}

References d.

◆ noMoreParsingError

void KisDoubleParseSpinBox::noMoreParsingError ( ) const
signal

signal emitted when the last parsed expression is valid and the expression before was not valid.

◆ setValue()

void KisDoubleParseSpinBox::setValue ( double value,
bool overwriteExpression = false )

Set the value of the spinbox.

This reimplementation also tries to clear the current expression and warning message whenever possible. This will happen when the new value is different from the current one and the line edit has not the focus or it is read-only. One can force the reset also by passing true to the overwriteExpression parameter.

Parameters
valueThe new value
overwriteExpressionGet if the expression in the edit field (and the warning message) should be reset to reflect the new value. The default is false so that if the user is editing the expression it won't be disrupted by any default call to this function

Definition at line 26 of file kis_double_parse_spin_box.cpp.

27{
28 d->setValue(value, overwriteExpression);
29}
float value(const T *src, size_t ch)

References d, and value().

◆ stepBy()

void KisDoubleParseSpinBox::stepBy ( int steps)
override

This is a reimplementation of QDoubleSpinBox::stepBy that uses setValue.

Parameters
stepsNumber of steps that the value should change

Definition at line 21 of file kis_double_parse_spin_box.cpp.

22{
23 d->stepBy(steps);
24}

References d.

◆ textFromValue()

QString KisDoubleParseSpinBox::textFromValue ( double value) const
overrideprotected

Definition at line 51 of file kis_double_parse_spin_box.cpp.

52{
53 return d->textFromValue(value);
54}

References d, and value().

◆ validate()

QValidator::State KisDoubleParseSpinBox::validate ( QString & input,
int & pos ) const
overrideprotected

Definition at line 41 of file kis_double_parse_spin_box.cpp.

42{
43 return d->validate(input, pos);
44}

References d.

◆ valueFromText()

double KisDoubleParseSpinBox::valueFromText ( const QString & text) const
overrideprotected

Definition at line 46 of file kis_double_parse_spin_box.cpp.

47{
48 return d->valueFromText(text);
49}

References d.

◆ veryCleanText()

QString KisDoubleParseSpinBox::veryCleanText ( ) const
virtual

This virtual function is similar to cleanText(). But child classes may reimplement it to further process ("clean up") the expression.

Returns
The processed expression

Reimplemented in KisDoubleParseUnitSpinBox.

Definition at line 36 of file kis_double_parse_spin_box.cpp.

37{
38 return d->veryCleanText();
39}

References d.

Friends And Related Symbol Documentation

◆ KisParseSpinBoxPrivate

template<typename SpinBoxTypeTP , typename BaseSpinBoxTypeTP >
friend class KisParseSpinBoxPrivate
friend

Definition at line 85 of file kis_double_parse_spin_box.h.

Member Data Documentation

◆ d

QScopedPointer<KisParseSpinBoxPrivate<KisDoubleParseSpinBox, QDoubleSpinBox> > KisDoubleParseSpinBox::d
private

Definition at line 86 of file kis_double_parse_spin_box.h.


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