From: vsr Date: Fri, 10 Dec 2010 14:41:13 +0000 (+0000) Subject: Issue 0021101 [CEA 439] QtxSpinBox in scientific notation X-Git-Tag: V6_2_0a2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=50346cccbcfdc67df3b15345a24587b5ade76f81;p=modules%2Fgui.git Issue 0021101 [CEA 439] QtxSpinBox in scientific notation --- 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 ) &&