From fa3d680c554df202d1c10a23196fba5a55884729 Mon Sep 17 00:00:00 2001 From: Chris Esposito Date: Tue, 18 Sep 2018 08:24:13 +1000 Subject: [PATCH] espoSpinBox fixed behaviour when entering negative values --- Desktop_Interface/ui_elements/espospinbox.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Desktop_Interface/ui_elements/espospinbox.cpp b/Desktop_Interface/ui_elements/espospinbox.cpp index 128d9db2..007cf405 100644 --- a/Desktop_Interface/ui_elements/espospinbox.cpp +++ b/Desktop_Interface/ui_elements/espospinbox.cpp @@ -7,36 +7,33 @@ espoSpinBox::espoSpinBox(QWidget *parent) : QDoubleSpinBox(parent) } QString espoSpinBox::textFromValue(double value) const{ - if (value < 0) - return textFromValue(-value).prepend('-'); - QString windowText; if (value == 0){ QTextStream(&windowText) << value; lastValidValue = value; return windowText; } - if (value >= 1000000){ + if (std::abs(value) >= 1000000){ QTextStream(&windowText) << value/1000000 << "M"; lastValidValue = value; return windowText; } - if (value >= 1000){ + if (std::abs(value) >= 1000){ QTextStream(&windowText) << value/1000 << "k"; lastValidValue = value; return windowText; } - if (value >= 1){ + if (std::abs(value) >= 1){ QTextStream(&windowText) << value; lastValidValue = value; return windowText; } - if (value >= 1/1000){ + if (std::abs(value) >= 1/1000){ QTextStream(&windowText) << value * 1000 << "m"; lastValidValue = value; return windowText; } - if (value >= 1/1000000){ + if (std::abs(value) >= 1/1000000){ QTextStream(&windowText) << value * 1000000 << "u"; lastValidValue = value; return windowText;