49#include "QtLessAnnoyingDoubleSpinBox.hh"
53QtLessAnnoyingDoubleSpinBox::QtLessAnnoyingDoubleSpinBox(QWidget* _qwidget ) : QDoubleSpinBox(_qwidget)
57QValidator::State QtLessAnnoyingDoubleSpinBox::validate(QString& text,
int&)
const
59 QString copy = strip_prefix_suffix(text) +
"0";
64 return QValidator::Acceptable;
66 return QValidator::Invalid;
69double QtLessAnnoyingDoubleSpinBox::valueFromText(
const QString &text)
const
71 QString copy = strip_prefix_suffix(text);
74 double value = copy.toDouble(&ok);
76 double factor = std::pow(10.0, decimals() );
77 value = double(
long(value *
double(factor) + 0.5) ) / factor;
85QString QtLessAnnoyingDoubleSpinBox::strip_prefix_suffix(
const QString& text)
const
87 int lenpre = prefix().length();
88 int lensuf = suffix().length();
90 return text.mid( lenpre, text.length() - lenpre -lensuf ).simplified();