17#include <klocalizedstring.h>
26 Private(
double low,
double up,
double step)
41 : QDoubleSpinBox( parent ),
44 QDoubleSpinBox::setDecimals( 2 );
47 setAlignment( Qt::AlignRight );
60 debugWidgets <<
"KoUnitDoubleSpinBox::validate :" << input <<
" at" << pos;
65 QRegExp regexp (
"([ a-zA-Z]+)$");
66 const int res = regexp.indexIn(input);
74 return QValidator::Intermediate;
78 const QString number ( input.left( res ).trimmed() );
79 const QString unitName ( regexp.cap( 1 ).trimmed().toLower() );
82 debugWidgets <<
"Split:" << number <<
":" << unitName <<
":";
98 return QValidator::Intermediate;
104 return QValidator::Invalid;
106 newVal =
d->unit.toUserValuePrecise(newVal);
109 return QValidator::Acceptable;
114 QDoubleSpinBox::setValue(
d->unit.toUserValue( val ) );
126 if (
unit ==
d->unit)
return;
128 double oldvalue =
d->unit.fromUserValue( QDoubleSpinBox::value() );
136 step = qMax(qreal(1.0), step);
139 QDoubleSpinBox::setSingleStep( step );
142 setSuffix(
unit.
symbol().prepend(QLatin1Char(
' ')));
147 return d->unit.fromUserValue( QDoubleSpinBox::value() );
152 d->lowerInPoints = min;
153 QDoubleSpinBox::setMinimum(
d->unit.toUserValue( min ) );
158 d->upperInPoints = max;
159 QDoubleSpinBox::setMaximum(
d->unit.toUserValue( max ) );
165 QDoubleSpinBox::setSingleStep( step );
170 d->stepInPoints = step;
171 QDoubleSpinBox::setSingleStep(
d->unit.toUserValue( step ) );
186 return QLocale().toString(
value,
'f', decimals() );
192 str2.remove(
d->unit.symbol());
193 return QLocale().toDouble(str2);
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
double stepInPoints
step in points
QString textFromValue(double value) const override
virtual void changeValue(double newValue)
void setLineStep(double step)
Set step size in the current unit.
Private(double low, double up, double step)
virtual void setUnit(const KoUnit &)
void valueChangedPt(qreal)
emitted like valueChanged in the parent, but this one emits the point value
double valueFromText(const QString &str) const override
double lowerInPoints
lowest value in points
double upperInPoints
highest value in points
void setMaximum(double max)
Set maximum value in points.
void privateValueChanged()
QValidator::State validate(QString &input, int &pos) const override
reimplemented from superclass, will forward to KoUnitDoubleValidator
void setMinMaxStep(double min, double max, double step)
Set minimum, maximum value and the step size (all in points)
KoUnitDoubleSpinBox(QWidget *parent=0)
void setLineStepPt(double step)
Set step size in points.
void setMinimum(double min)
Set minimum value in points.
~KoUnitDoubleSpinBox() override
qreal fromUserValue(qreal value) const
KoUnit::Type type() const
qreal toUserValuePrecise(const qreal ptValue) const
static KoUnit fromSymbol(const QString &symbol, bool *ok=0)
QString symbol() const
Get the symbol string of the unit.
@ Point
Postscript point, 1/72th of an Inco.
qreal toUserValue(qreal ptValue, bool rounding=true) const