From 50346cccbcfdc67df3b15345a24587b5ade76f81 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 10 Dec 2010 14:41:13 +0000 Subject: [PATCH] Issue 0021101 [CEA 439] QtxSpinBox in scientific notation --- src/Qtx/QtxDoubleSpinBox.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Qtx/QtxDoubleSpinBox.cxx b/src/Qtx/QtxDoubleSpinBox.cxx index 50717e4f9..9c508ebd5 100644 --- a/src/Qtx/QtxDoubleSpinBox.cxx +++ b/src/Qtx/QtxDoubleSpinBox.cxx @@ -258,13 +258,19 @@ QString QtxDoubleSpinBox::removeTrailingZeroes( const QString& src ) const QString iPart = src.left( idx ); QString fPart = src.mid( idx + 1 ); + QString ePart = ""; + int idx1 = fPart.lastIndexOf( QRegExp( "e[+|-]?[0-9]+" ) ); + if ( idx1 >= 0 ) { + ePart = fPart.mid( idx1 ); + fPart = fPart.left( idx1 ); + } - while ( !fPart.isEmpty() && fPart.at( fPart.length() - 1 ) == '0' ) - fPart.remove( fPart.length() - 1, 1 ); + fPart.remove( QRegExp( "0+$" ) ); QString res = iPart; if ( !fPart.isEmpty() ) res += delim + fPart; + res += ePart; return res; } @@ -316,9 +322,8 @@ QValidator::State QtxDoubleSpinBox::validate( QString& str, int& pos ) const v.setNotation( myPrecision >= 0 ? QDoubleValidator::StandardNotation : QDoubleValidator::ScientificNotation ); - if ( overhead == 0 ) { + if ( overhead == 0 ) state = v.validate( str, pos ); - } else { if ( str.length() >= overhead && str.startsWith( pref ) && -- 2.39.2