Fixed espoSpinBox issues

This commit is contained in:
Chris Esposito 2018-09-22 06:04:52 +10:00
parent fa3d680c55
commit c126590a74
2 changed files with 7 additions and 6 deletions

View File

@ -54,15 +54,15 @@ void espoSpinBox::setMin(double newMin){
}
void espoSpinBox::changeStepping(double value){
double roundval = pow(10.0, floor(log10(value))); //http://stackoverflow.com/questions/22491505/how-to-round-down-to-the-nearest-power-of-10
roundval = (roundval == 0) ? 0.1 : roundval/10;
setSingleStep(roundval);
double roundval = pow(10.0, floor(log10(std::abs(value)))); //http://stackoverflow.com/questions/22491505/how-to-round-down-to-the-nearest-power-of-10
double minimumStepSize = pow(10, -1 * decimals());
qDebug() << "roundval" << roundval;
qDebug() << "minimumStepSize" << minimumStepSize;
setSingleStep(std::max(minimumStepSize, roundval/10));
}
QValidator::State espoSpinBox::validate(QString& text, int& pos) const
{
qDebug() << pos;
prefixLength = pos;
return QValidator::State::Acceptable;
}
@ -71,6 +71,8 @@ double espoSpinBox::valueFromText(const QString &text) const
double ret;
bool isValid;
uint32_t prefixLength = text.length() - suffix().length();
qDebug() << text.mid(0, prefixLength - 1) << text.at(prefixLength - 1).toLatin1();
switch (text.at(prefixLength - 1).toLatin1())

View File

@ -19,7 +19,6 @@ public:
private:
QString textFromValue(double value) const override;
double valueFromText(const QString &text) const override;
mutable int prefixLength = -1;
mutable double lastValidValue = -1;
signals: