Skip to content

Commit d1b463e

Browse files
author
Charles PIGNEROL
committed
Version 6.4.1 du 23/02/24. Correctif Qt*TextField::setRange (T min, T max) : min == max accepté.
1 parent 5dba7bb commit d1b463e

14 files changed

+101
-241
lines changed

cmake/version.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
set (QT_UTIL_MAJOR_VERSION "6")
66
set (QT_UTIL_MINOR_VERSION "4")
7-
set (QT_UTIL_RELEASE_VERSION "0")
7+
set (QT_UTIL_RELEASE_VERSION "1")
88
set (QT_UTIL_VERSION ${QT_UTIL_MAJOR_VERSION}.${QT_UTIL_MINOR_VERSION}.${QT_UTIL_RELEASE_VERSION})
99

1010

src/QtUtil/QtColorChooser.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@ USING_UTIL
1616
static const Charset charset ("àéèùô");
1717
USE_ENCODING_AUTODETECTION
1818

19-
QtColorChooser::QtColorChooser (
20-
QWidget* parent, const UTF8String& label, const Color& color)
19+
QtColorChooser::QtColorChooser (QWidget* parent, const UTF8String& label, const Color& color)
2120
: QWidget (parent), _colorLabel (0)
2221
{
2322
createGui (label, color);
2423
} // QtColorChooser::QtColorChooser
2524

2625

27-
QtColorChooser::QtColorChooser (
28-
QWidget* parent, const UTF8String& label, const QColor& color)
26+
QtColorChooser::QtColorChooser (QWidget* parent, const UTF8String& label, const QColor& color)
2927
: QWidget (parent), _colorLabel (0)
3028
{
3129
createGui (label, Color (color.red ( ), color.green ( ), color.blue ( )));
@@ -117,8 +115,7 @@ void QtColorChooser::clickedCallback ( )
117115
{
118116
assert ((0 != _colorLabel) && "QtColorChooser::clickedCallback : null color label.");
119117
const QColor current = getQColor ( );
120-
const QColor color = QColorDialog::getColor (getQColor ( ), this,
121-
"Nouvelle couleur", QColorDialog::DontUseNativeDialog);
118+
const QColor color = QColorDialog::getColor (getQColor ( ), this, "Nouvelle couleur", QColorDialog::DontUseNativeDialog);
122119
if (false == color.isValid ( ))
123120
return;
124121

src/QtUtil/QtCoordinatesDialog.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
186186
connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT(accept ( )));
187187
connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, SLOT(reject ( )));
188188

189-
// Par defaut le bouton OK est artificellement clique par QDialog quand
190-
// l'utilisateur fait return dans un champ de texte => on inhibe ce
191-
// comportement par defaut :
189+
// Par defaut le bouton OK est artificellement clique par QDialog quand l'utilisateur fait return dans un champ de texte => on inhibe ce comportement par defaut :
192190
_closurePanel->getApplyButton ( )->setAutoDefault (false);
193191
_closurePanel->getApplyButton ( )->setDefault (false);
194192
_closurePanel->getCancelButton ( )->setAutoDefault (false);
@@ -258,12 +256,7 @@ void QtCoordinatesDialog::accept ( )
258256
string title = windowTitle ( ).toStdString ( );
259257
UTF8String message (charset);
260258
message << "Aucune des trois composantes ne sera modifiée. Continuer ?";
261-
if (0 != QtMessageBox::displayWarningMessage (
262-
this, title, message, 100,
263-
"Oui", "Annuler", 0, -1))
264-
/* if (0 != QMessageBox::warning (
265-
this, title, message.iso ( ).c_str ( ),
266-
"Oui", "Annuler", QString::null, 0, -1))*/
259+
if (0 != QtMessageBox::displayWarningMessage (this, title, message, 100, "Oui", "Annuler", 0, -1))
267260
return;
268261
} // if ((false == doX) && (false == doY) && (false == doZ))
269262

src/QtUtil/QtCoordinatesTextField.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ USE_ENCODING_AUTODETECTION
3535
// ===========================================================================
3636

3737
/**
38-
* Classe de validateur de type <I>QRegExp</I> tolérant une évolution de la
39-
* chaîne par son milieu. Par défaut la classe <I>QRegExpValidator</I> retourne
40-
* <I>Intermediate</I> si les modifications sont effectuées en fin de chaîne
41-
* (donc chaîne incomplète), mais pas en cas d'édition en son milieu. Cette
42-
* classe évalue où est effectuée la modification et retourne
43-
* <I>Intermediate</I> si elle est valide du début à ce point.
38+
* Classe de validateur de type <I>QRegExp</I> tolérant une évolution de la chaîne par son milieu. Par défaut la classe <I>QRegExpValidator</I> retourne
39+
* <I>Intermediate</I> si les modifications sont effectuées en fin de chaîne (donc chaîne incomplète), mais pas en cas d'édition en son milieu. Cette
40+
* classe évalue où est effectuée la modification et retourne <I>Intermediate</I> si elle est valide du début à ce point.
4441
*/
4542
#ifdef QT_5
4643
class QtRegExpValidator : public QRegExpValidator
@@ -107,8 +104,7 @@ QtCoordinatesTextField::QtCoordinatesTextField (QWidget* parent, double x, doubl
107104
{
108105
setCoordinates (x, y, z);
109106
const string espaces ("[ ]*");
110-
const string doubleExp (
111-
"[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
107+
const string doubleExp ("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
112108
// Semble également OK :
113109
// "[+\\-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?");
114110
UTF8String coordsExp;

src/QtUtil/QtDoubleTextField.cpp

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ static const Charset charset ("àéèùô");
1717
USE_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

168121
void 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

253199
const 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
267212
QDoubleValidator* 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

src/QtUtil/QtIntTextField.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ static const Charset charset ("àéèùô");
1717
USE_ENCODING_AUTODETECTION
1818

1919

20-
QtIntTextField::QtIntTextField (
21-
QWidget* parent, bool autoValidation, const char* name)
20+
QtIntTextField::QtIntTextField (QWidget* parent, bool autoValidation, const char* name)
2221
: QtValidatedTextField (parent, autoValidation, name)
2322
{
2423
createGui ( );
2524
} // QtIntTextField::QtIntTextField
2625

2726

28-
QtIntTextField::QtIntTextField (
29-
int value, QWidget* parent, bool autoValidation, const char* name)
27+
QtIntTextField::QtIntTextField (int value, QWidget* parent, bool autoValidation, const char* name)
3028
: QtValidatedTextField (parent, autoValidation, name)
3129
{
3230
createGui ( );
@@ -67,8 +65,7 @@ int QtIntTextField::getValue ( ) const
6765
int iValue = tValue.toInt (&ok);
6866
const QIntValidator& validator = getValidator ( );
6967

70-
if ((false == ok) ||
71-
(QValidator::Acceptable != validator.validate (tValue, pos)))
68+
if ((false == ok) || (QValidator::Acceptable != validator.validate (tValue, pos)))
7269
{
7370
UTF8String errorMsg (charset);
7471
errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n";
@@ -109,10 +106,7 @@ void QtIntTextField::setValue (int value)
109106
if ((value < validator.bottom ( )) || (value > validator.top ( )))
110107
{
111108
UTF8String errorMsg (charset);
112-
errorMsg << "Erreur : la valeur " << (long)value
113-
<< " est en dehors du domaine autorisé ("
114-
<< (long)validator.bottom ( ) << " - "
115-
<< (long)validator.top ( ) << ").";
109+
errorMsg << "Erreur : la valeur " << (long)value << " est en dehors du domaine autorisé (" << (long)validator.bottom ( ) << " - " << (long)validator.top ( ) << ").";
116110
throw Exception (errorMsg);
117111
} // if ((value < validator.bottom ( )) || (value > validator.top ( )))
118112

@@ -131,13 +125,12 @@ void QtIntTextField::getRange (int& min, int& max) const
131125

132126
void QtIntTextField::setRange (int min, int max)
133127
{
134-
if (min >= max)
128+
if (min > max)
135129
{
136130
UTF8String errorMsg (charset);
137-
errorMsg << "Domaine de saisie d'un réel invalide : ("
138-
<< (long)min << " - " << (long)max << ").";
131+
errorMsg << "Domaine de saisie d'un réel invalide : (" << (long)min << " - " << (long)max << ").";
139132
throw Exception (errorMsg);
140-
} // if (min >= max)
133+
} // if (min > max)
141134

142135
const QIntValidator& old = getValidator ( );
143136
QIntValidator* v = new QIntValidator (min, max, this);
@@ -154,8 +147,7 @@ void QtIntTextField::createGui ( )
154147

155148
const QIntValidator& QtIntTextField::getValidator ( ) const
156149
{
157-
const QIntValidator* v=
158-
dynamic_cast<const QIntValidator*>(validator ( ));
150+
const QIntValidator* v = dynamic_cast<const QIntValidator*>(validator ( ));
159151
if (0 == v)
160152
{
161153
INTERNAL_ERROR (exc, "Absence de validateur.", "QtIntTextField::getValidator")
@@ -177,16 +169,14 @@ bool QtIntTextField::validate ( )
177169
{
178170
setSkin (false);
179171
if (true == QtValidatedTextField::dialogOnError)
180-
QtMessageBox::displayErrorMessage (
181-
this, "Saisie invalide", exc.getFullMessage ( ));
172+
QtMessageBox::displayErrorMessage (this, "Saisie invalide", exc.getFullMessage ( ));
182173
return false;
183174
}
184175
catch (...)
185176
{
186177
setSkin (false);
187178
if (true == QtValidatedTextField::dialogOnError)
188-
QtMessageBox::displayErrorMessage (
189-
this, "Saisie invalide", "Erreur non documentée.");
179+
QtMessageBox::displayErrorMessage (this, "Saisie invalide", "Erreur non documentée.");
190180
return false;
191181
}
192182

src/QtUtil/QtMultiLineToolbar.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ QtMultiLineToolbar::QtMultiLineToolbar (QWidget* parent)
2121
: QWidget (parent), _iconSize (32, 32)
2222
{
2323
setLayout (new QtFlowLayout (this));
24-
QApplication* app =
25-
dynamic_cast<QApplication*>(QApplication::instance ( ));
24+
QApplication* app = dynamic_cast<QApplication*>(QApplication::instance ( ));
2625
if ((0 != app) && (0 != app->style ( )))
2726
{
2827
int size = app->style ( )->pixelMetric (QStyle::PM_ToolBarIconSize);
@@ -68,8 +67,7 @@ void QtMultiLineToolbar::addSeparator ( )
6867
{
6968
CHECK_NULL_PTR_ERROR (layout ( ))
7069
QWidget* separator = new QWidget (this);
71-
separator->setFixedSize (
72-
QSize (iconSize ( ).width ( ) / 2, iconSize ( ).height ( ) / 2));
70+
separator->setFixedSize (QSize (iconSize ( ).width ( ) / 2, iconSize ( ).height ( ) / 2));
7371
layout ( )->addWidget (separator);
7472
} // QtMultiLineToolbar::addSeparator
7573

src/QtUtil/QtRichTextComboBox.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ void QtRichTextComboBox::paintEvent (QPaintEvent*)
9999
#else // QT_5
100100
left = contentsMargins ( ).left ( );
101101
#endif // QT_5
102-
// Pour une raison non élucidée un deltax est esthétiquement
103-
// souhaitable (left et autres sont nuls) :
102+
// Pour une raison non élucidée un deltax est esthétiquement souhaitable (left et autres sont nuls) :
104103
painter.translate (left + QtConfiguration::margin, 0);
105104
textDocument.drawContents (&painter, rect);
106105
} // QtRichTextComboBox::paintEvent
@@ -127,9 +126,7 @@ QSize QtComboBoxItemDelegate::sizeHint (
127126
} // QtComboBoxItemDelegate::sizeHint
128127

129128

130-
void QtComboBoxItemDelegate::paint (
131-
QPainter* painter, const QStyleOptionViewItem& option,
132-
const QModelIndex& index) const
129+
void QtComboBoxItemDelegate::paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
133130
{
134131
painter->save ( );
135132

0 commit comments

Comments
 (0)