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

A wrapper around KisDoubleParseSpinBox, which is a cleverer doubleSpinBox, able to parse arithmetic expressions. The widget itself is accessed with the widget() function. More...

#include <DoubleParseSpinBox.h>

+ Inheritance diagram for DoubleParseSpinBox:

Public Slots

bool isLastValid () const
 Get if the last expression entered is a valid one.
 
void setValue (double value, bool overwriteExpression=false)
 Set the value of the spinbox.
 
void stepBy (int steps)
 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.
 
QDoubleSpinBox * widget () const
 Get the internal KisDoubleParseSpinBox as a QWidget, so it may be added to a UI.
 

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

 DoubleParseSpinBox ()
 
 ~DoubleParseSpinBox () override
 

Private Attributes

Private *const d
 

Detailed Description

A wrapper around KisDoubleParseSpinBox, which is a cleverer doubleSpinBox, able to parse arithmetic expressions. The widget itself is accessed with the widget() function.

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

Definition at line 23 of file DoubleParseSpinBox.h.

Constructor & Destructor Documentation

◆ DoubleParseSpinBox()

DoubleParseSpinBox::DoubleParseSpinBox ( )
explicit

Definition at line 16 of file DoubleParseSpinBox.cpp.

17 : QObject()
18 , d(new Private)
19{
21
22 // Forward signals from KisDoubleParseSpinBox to DoubleParseSpinBox
23 connect(d->widget, SIGNAL(errorWhileParsing(QString)), this, SIGNAL(errorWhileParsing(QString)));
24 connect(d->widget, SIGNAL(noMoreParsingError()), this, SIGNAL(noMoreParsingError()));
25}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void noMoreParsingError() const
signal emitted when the last parsed expression is valid and the expression before was not valid.
void errorWhileParsing(const QString &expr) const
signal emitted when the last parsed expression is not valid.
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.

References connect(), d, errorWhileParsing(), noMoreParsingError(), and krita::DoubleParseSpinBox::Private::widget.

◆ ~DoubleParseSpinBox()

DoubleParseSpinBox::~DoubleParseSpinBox ( )
override

Definition at line 27 of file DoubleParseSpinBox.cpp.

28{
29 delete d;
30}

References d.

Member Function Documentation

◆ errorWhileParsing

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

signal emitted when the last parsed expression is not valid.

◆ isLastValid

bool DoubleParseSpinBox::isLastValid ( ) const
slot

Get if the last expression entered is a valid one.

Return values
trueif the last expression entered is valid
falseotherwise

Definition at line 47 of file DoubleParseSpinBox.cpp.

48{
49 return d->widget->isLastValid();
50}
bool isLastValid() const
Get if the last expression entered is a valid one.

References d, KisDoubleParseSpinBox::isLastValid(), and krita::DoubleParseSpinBox::Private::widget.

◆ noMoreParsingError

void DoubleParseSpinBox::noMoreParsingError ( ) const
signal

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

◆ setValue

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

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 42 of file DoubleParseSpinBox.cpp.

43{
44 d->widget->setValue(value, overwriteExpression);
45}
float value(const T *src, size_t ch)
void setValue(double value, bool overwriteExpression=false)
Set the value of the spinbox.

References d, KisDoubleParseSpinBox::setValue(), value(), and krita::DoubleParseSpinBox::Private::widget.

◆ stepBy

void DoubleParseSpinBox::stepBy ( int steps)
slot

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

Parameters
stepsNumber of steps that the value should change

Definition at line 37 of file DoubleParseSpinBox.cpp.

38{
39 d->widget->stepBy(steps);
40}
void stepBy(int steps) override
This is a reimplementation of QDoubleSpinBox::stepBy that uses setValue.

References d, KisDoubleParseSpinBox::stepBy(), and krita::DoubleParseSpinBox::Private::widget.

◆ veryCleanText

QString DoubleParseSpinBox::veryCleanText ( ) const
virtualslot

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

Returns
The processed expression

Definition at line 52 of file DoubleParseSpinBox.cpp.

53{
54 return d->widget->veryCleanText();
55}
virtual QString veryCleanText() const
This virtual function is similar to cleanText(). But child classes may reimplement it to further proc...

References d, KisDoubleParseSpinBox::veryCleanText(), and krita::DoubleParseSpinBox::Private::widget.

◆ widget

QDoubleSpinBox * DoubleParseSpinBox::widget ( ) const
slot

Get the internal KisDoubleParseSpinBox as a QWidget, so it may be added to a UI.

Returns
the internal KisDoubleParseSpinBox as a QWidget

Definition at line 32 of file DoubleParseSpinBox.cpp.

33{
34 return d->widget;
35}

References d, and krita::DoubleParseSpinBox::Private::widget.

Member Data Documentation

◆ d

Private* const DoubleParseSpinBox::d
private

Definition at line 92 of file DoubleParseSpinBox.h.


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