@@ -17,16 +17,14 @@ static const Charset charset ("àéèùô");
1717USE_ENCODING_AUTODETECTION
1818
1919
20- QtDoubleTextField::QtDoubleTextField (
21- QWidget* parent, bool autoValidation, const char * name)
20+ QtDoubleTextField::QtDoubleTextField (QWidget* parent, bool autoValidation, const char * name)
2221 : QtValidatedTextField (parent, autoValidation, name)
2322{
2423 createGui ( );
2524} // QtDoubleTextField::QtDoubleTextField
2625
2726
28- QtDoubleTextField::QtDoubleTextField (
29- double value, QWidget* parent, bool autoValidation, const char * name)
27+ QtDoubleTextField::QtDoubleTextField (double value, QWidget* parent, bool autoValidation, const char * name)
3028 : QtValidatedTextField (parent, autoValidation, name)
3129{
3230 createGui ( );
@@ -76,49 +74,16 @@ double QtDoubleTextField::getValue ( ) const
7674 } // if (false == ok)
7775 if ((dValue < validator.bottom ( )) || (dValue > validator.top ( )))
7876 {
79- if ((fabs (dValue - validator.bottom ( )) >
80- NumericServices::doubleMachEpsilon ( )) &&
81- (fabs (dValue - validator.top ( )) >
82- NumericServices::doubleMachEpsilon ( )))
77+ if ((fabs (dValue - validator.bottom ( )) > NumericServices::doubleMachEpsilon ( )) &&
78+ (fabs (dValue - validator.top ( )) > NumericServices::doubleMachEpsilon ( )))
8379 {
8480 UTF8String errorMsg (charset);
8581 errorMsg << " Valeur " << tValue.toStdString ( ) << " incorrecte.\n " ;
86- errorMsg << " La valeur doit être comprise entre "
87- << NumericConversions::userRepresentation ( // v 2.48.0
88- validator.bottom ( ),
89- NumericServices::doubleScientificNotationCharMax, 1 )
90- << " et " << NumericConversions::userRepresentation (
91- validator.top ( ),
92- NumericServices::doubleScientificNotationCharMax, 1 )
93- << " ." ;
94- // << ios_base::fixed << IN_UTIL setprecision (2) // v 2.48.0
95- // << validator.bottom ( )
96- // << " et " << validator.top ( ) << ".";
82+ errorMsg << " La valeur doit être comprise entre " << NumericConversions::userRepresentation (validator.bottom ( ), NumericServices::doubleScientificNotationCharMax, 1 )
83+ << " et " << NumericConversions::userRepresentation (validator.top ( ), NumericServices::doubleScientificNotationCharMax, 1 ) << " ." ;
9784 throw Exception (errorMsg);
9885 } // if ((dValue < validator.bottom ( )) || ...
9986 } // if ((dValue < validator.bottom ( )) || (dValue > validator.top ( )))
100- // FIN V 2.44.1
101- /* V <= 2.44.0
102- if ((false == ok) ||
103- (QValidator::Acceptable != validator.validate (tValue, pos)))
104- {
105- UTF8String errorMsg (charset);
106- errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n";
107-
108- if ((validator.bottom ( ) == -NumericServices::doubleMachMax ( )) &&
109- (validator.top ( ) == NumericServices::doubleMachMax ( )))
110- errorMsg << "La valeur doit être de type réel double précision.";
111- else if ((validator.bottom ( ) == -NumericServices::floatMachMax ( )) &&
112- (validator.top ( ) == NumericServices::floatMachMax ( )))
113- errorMsg << "La valeur doit être de type réel simple précision.";
114- else
115- errorMsg << "La valeur doit être comprise entre "
116- << ios_base::fixed << IN_UTIL setprecision (2)
117- << validator.bottom ( )
118- << " et " << validator.top ( ) << ".";
119- throw Exception (errorMsg);
120- } // if ((false == ok)
121- */
12287
12388 return dValue;
12489} // QtDoubleTextField::getValue
@@ -130,27 +95,15 @@ void QtDoubleTextField::setValue (double value)
13095 if ((value < validator.bottom ( )) || (value > validator.top ( )))
13196 {
13297 UTF8String errorMsg (charset);
133- errorMsg << " Erreur : la valeur " << value
134- << " est en dehors du domaine autorisé ("
135- << NumericConversions::userRepresentation ( // v 2.48.0
136- validator.bottom ( ),
137- NumericServices::doubleScientificNotationCharMax, 1 )
138- << " - "
139- << NumericConversions::userRepresentation ( // v 2.48.0
140- validator.top ( ),
141- NumericServices::doubleScientificNotationCharMax, 1 )
142- // << ios_base::fixed << IN_UTIL setprecision (2)
143- // << validator.bottom ( ) << " - " << validator.top ( )
144- << " )." ;
98+ errorMsg << " Erreur : la valeur " << value << " est en dehors du domaine autorisé ("
99+ << NumericConversions::userRepresentation (validator.bottom ( ), NumericServices::doubleScientificNotationCharMax, 1 )
100+ << " - " << NumericConversions::userRepresentation (validator.top ( ), NumericServices::doubleScientificNotationCharMax, 1 ) << " )." ;
145101 throw Exception (errorMsg);
146102 } // if ((value < validator.bottom ( )) || (value > validator.top ( )))
147103
148- // On évite de perdre des epsilons avec le format d'affichage par défaut des
149- // streams c++ :
150- // setText (UTF8TOQSTRING (value));
104+ // On évite de perdre des epsilons avec le format d'affichage par défaut des streams c++ :
151105 UTF8String us;
152- us << (QDoubleValidator::StandardNotation == getNotation ( ) ?
153- ios_base::fixed : ios_base::scientific);
106+ us << (QDoubleValidator::StandardNotation == getNotation ( ) ? ios_base::fixed : ios_base::scientific);
154107 us << IN_UTIL setprecision (validator.decimals ( )) << value;
155108 setText (UTF8TOQSTRING (us));
156109 getValue ( );
@@ -167,20 +120,13 @@ void QtDoubleTextField::getRange (double& min, double& max) const
167120
168121void QtDoubleTextField::setRange (double min, double max)
169122{
170- if (min >= max)
123+ if (min > max)
171124 {
172125 UTF8String errorMsg (charset);
173- errorMsg << " Domaine de saisie d'un réel invalide : ("
174- << NumericConversions::userRepresentation (min,
175- NumericServices::doubleScientificNotationCharMax, 1 )
176- << " - "
177- << NumericConversions::userRepresentation (max,
178- NumericServices::doubleScientificNotationCharMax, 1 )
179- // << ios_base::fixed << IN_UTIL setprecision (2)
180- // << min << " - " << max
181- << " )." ;
126+ errorMsg << " Domaine de saisie d'un réel invalide : (" << NumericConversions::userRepresentation (min, NumericServices::doubleScientificNotationCharMax, 1 )
127+ << " - " << NumericConversions::userRepresentation (max, NumericServices::doubleScientificNotationCharMax, 1 ) << " )." ;
182128 throw Exception (errorMsg);
183- } // if (min >= max)
129+ } // if (min > max)
184130
185131 const QDoubleValidator& old = getValidator ( );
186132 QDoubleValidator* v = cloneValidator ( );
@@ -252,8 +198,7 @@ void QtDoubleTextField::createGui ( )
252198
253199const QDoubleValidator& QtDoubleTextField::getValidator ( ) const
254200{
255- const QDoubleValidator* v=
256- dynamic_cast <const QDoubleValidator*>(validator ( ));
201+ const QDoubleValidator* v = dynamic_cast <const QDoubleValidator*>(validator ( ));
257202 if (0 == v)
258203 {
259204 INTERNAL_ERROR (exc, " Absence de validateur." , " QtDoubleTextField::getValidator" )
@@ -267,8 +212,7 @@ const QDoubleValidator& QtDoubleTextField::getValidator ( ) const
267212QDoubleValidator* QtDoubleTextField::cloneValidator ( )
268213{
269214 const QDoubleValidator& old = getValidator ( );
270- QDoubleValidator* v =
271- new QDoubleValidator (old.bottom ( ), old.top ( ), old.decimals ( ), this );
215+ QDoubleValidator* v = new QDoubleValidator (old.bottom ( ), old.top ( ), old.decimals ( ), this );
272216 v->setNotation (old.notation ( ));
273217
274218 return v;
@@ -286,16 +230,14 @@ bool QtDoubleTextField::validate ( )
286230 {
287231 setSkin (false );
288232 if (true == QtValidatedTextField::dialogOnError)
289- QtMessageBox::displayErrorMessage (
290- this , " Saisie invalide" , exc.getFullMessage ( ));
233+ QtMessageBox::displayErrorMessage (this , " Saisie invalide" , exc.getFullMessage ( ));
291234 return false ;
292235 }
293236 catch (...)
294237 {
295238 setSkin (false );
296239 if (true == QtValidatedTextField::dialogOnError)
297- QtMessageBox::displayErrorMessage (
298- this , " Saisie invalide" , " Erreur non documentée." );
240+ QtMessageBox::displayErrorMessage (this , " Saisie invalide" , " Erreur non documentée." );
299241 return false ;
300242 }
301243
0 commit comments