mirror of https://github.com/EspoTek/Labrador.git
espoSpinBox fixed behaviour when entering negative values
This commit is contained in:
parent
56468e9917
commit
fa3d680c55
|
@ -7,36 +7,33 @@ espoSpinBox::espoSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString espoSpinBox::textFromValue(double value) const{
|
QString espoSpinBox::textFromValue(double value) const{
|
||||||
if (value < 0)
|
|
||||||
return textFromValue(-value).prepend('-');
|
|
||||||
|
|
||||||
QString windowText;
|
QString windowText;
|
||||||
if (value == 0){
|
if (value == 0){
|
||||||
QTextStream(&windowText) << value;
|
QTextStream(&windowText) << value;
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
}
|
}
|
||||||
if (value >= 1000000){
|
if (std::abs(value) >= 1000000){
|
||||||
QTextStream(&windowText) << value/1000000 << "M";
|
QTextStream(&windowText) << value/1000000 << "M";
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
}
|
}
|
||||||
if (value >= 1000){
|
if (std::abs(value) >= 1000){
|
||||||
QTextStream(&windowText) << value/1000 << "k";
|
QTextStream(&windowText) << value/1000 << "k";
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
}
|
}
|
||||||
if (value >= 1){
|
if (std::abs(value) >= 1){
|
||||||
QTextStream(&windowText) << value;
|
QTextStream(&windowText) << value;
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
}
|
}
|
||||||
if (value >= 1/1000){
|
if (std::abs(value) >= 1/1000){
|
||||||
QTextStream(&windowText) << value * 1000 << "m";
|
QTextStream(&windowText) << value * 1000 << "m";
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
}
|
}
|
||||||
if (value >= 1/1000000){
|
if (std::abs(value) >= 1/1000000){
|
||||||
QTextStream(&windowText) << value * 1000000 << "u";
|
QTextStream(&windowText) << value * 1000000 << "u";
|
||||||
lastValidValue = value;
|
lastValidValue = value;
|
||||||
return windowText;
|
return windowText;
|
||||||
|
|
Loading…
Reference in New Issue