Skip to content

Version 6.4.1 du 23/02/24. Correctif Qt*TextField::setRange (T min, T… #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

set (QT_UTIL_MAJOR_VERSION "6")
set (QT_UTIL_MINOR_VERSION "4")
set (QT_UTIL_RELEASE_VERSION "0")
set (QT_UTIL_RELEASE_VERSION "1")
set (QT_UTIL_VERSION ${QT_UTIL_MAJOR_VERSION}.${QT_UTIL_MINOR_VERSION}.${QT_UTIL_RELEASE_VERSION})


9 changes: 3 additions & 6 deletions src/QtUtil/QtColorChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ USING_UTIL
static const Charset charset ("àéèùô");
USE_ENCODING_AUTODETECTION

QtColorChooser::QtColorChooser (
QWidget* parent, const UTF8String& label, const Color& color)
QtColorChooser::QtColorChooser (QWidget* parent, const UTF8String& label, const Color& color)
: QWidget (parent), _colorLabel (0)
{
createGui (label, color);
} // QtColorChooser::QtColorChooser


QtColorChooser::QtColorChooser (
QWidget* parent, const UTF8String& label, const QColor& color)
QtColorChooser::QtColorChooser (QWidget* parent, const UTF8String& label, const QColor& color)
: QWidget (parent), _colorLabel (0)
{
createGui (label, Color (color.red ( ), color.green ( ), color.blue ( )));
Expand Down Expand Up @@ -117,8 +115,7 @@ void QtColorChooser::clickedCallback ( )
{
assert ((0 != _colorLabel) && "QtColorChooser::clickedCallback : null color label.");
const QColor current = getQColor ( );
const QColor color = QColorDialog::getColor (getQColor ( ), this,
"Nouvelle couleur", QColorDialog::DontUseNativeDialog);
const QColor color = QColorDialog::getColor (getQColor ( ), this, "Nouvelle couleur", QColorDialog::DontUseNativeDialog);
if (false == color.isValid ( ))
return;

Expand Down
11 changes: 2 additions & 9 deletions src/QtUtil/QtCoordinatesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String&
connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT(accept ( )));
connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, SLOT(reject ( )));

// 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 :
// 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 :
_closurePanel->getApplyButton ( )->setAutoDefault (false);
_closurePanel->getApplyButton ( )->setDefault (false);
_closurePanel->getCancelButton ( )->setAutoDefault (false);
Expand Down Expand Up @@ -258,12 +256,7 @@ void QtCoordinatesDialog::accept ( )
string title = windowTitle ( ).toStdString ( );
UTF8String message (charset);
message << "Aucune des trois composantes ne sera modifiée. Continuer ?";
if (0 != QtMessageBox::displayWarningMessage (
this, title, message, 100,
"Oui", "Annuler", 0, -1))
/* if (0 != QMessageBox::warning (
this, title, message.iso ( ).c_str ( ),
"Oui", "Annuler", QString::null, 0, -1))*/
if (0 != QtMessageBox::displayWarningMessage (this, title, message, 100, "Oui", "Annuler", 0, -1))
return;
} // if ((false == doX) && (false == doY) && (false == doZ))

Expand Down
12 changes: 4 additions & 8 deletions src/QtUtil/QtCoordinatesTextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ USE_ENCODING_AUTODETECTION
// ===========================================================================

/**
* 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
* <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
* classe évalue où est effectuée la modification et retourne
* <I>Intermediate</I> si elle est valide du début à ce point.
* 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
* <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
* classe évalue où est effectuée la modification et retourne <I>Intermediate</I> si elle est valide du début à ce point.
*/
#ifdef QT_5
class QtRegExpValidator : public QRegExpValidator
Expand Down Expand Up @@ -107,8 +104,7 @@ QtCoordinatesTextField::QtCoordinatesTextField (QWidget* parent, double x, doubl
{
setCoordinates (x, y, z);
const string espaces ("[ ]*");
const string doubleExp (
"[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
const string doubleExp ("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
// Semble également OK :
// "[+\\-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?");
UTF8String coordsExp;
Expand Down
96 changes: 19 additions & 77 deletions src/QtUtil/QtDoubleTextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ static const Charset charset ("àéèùô");
USE_ENCODING_AUTODETECTION


QtDoubleTextField::QtDoubleTextField (
QWidget* parent, bool autoValidation, const char* name)
QtDoubleTextField::QtDoubleTextField (QWidget* parent, bool autoValidation, const char* name)
: QtValidatedTextField (parent, autoValidation, name)
{
createGui ( );
} // QtDoubleTextField::QtDoubleTextField


QtDoubleTextField::QtDoubleTextField (
double value, QWidget* parent, bool autoValidation, const char* name)
QtDoubleTextField::QtDoubleTextField (double value, QWidget* parent, bool autoValidation, const char* name)
: QtValidatedTextField (parent, autoValidation, name)
{
createGui ( );
Expand Down Expand Up @@ -76,49 +74,16 @@ double QtDoubleTextField::getValue ( ) const
} // if (false == ok)
if ((dValue < validator.bottom ( )) || (dValue > validator.top ( )))
{
if ((fabs (dValue - validator.bottom ( )) >
NumericServices::doubleMachEpsilon ( )) &&
(fabs (dValue - validator.top ( )) >
NumericServices::doubleMachEpsilon ( )))
if ((fabs (dValue - validator.bottom ( )) > NumericServices::doubleMachEpsilon ( )) &&
(fabs (dValue - validator.top ( )) > NumericServices::doubleMachEpsilon ( )))
{
UTF8String errorMsg (charset);
errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n";
errorMsg << "La valeur doit être comprise entre "
<< NumericConversions::userRepresentation ( // v 2.48.0
validator.bottom ( ),
NumericServices::doubleScientificNotationCharMax, 1)
<< " et " << NumericConversions::userRepresentation (
validator.top ( ),
NumericServices::doubleScientificNotationCharMax, 1)
<< ".";
// << ios_base::fixed << IN_UTIL setprecision (2) // v 2.48.0
// << validator.bottom ( )
// << " et " << validator.top ( ) << ".";
errorMsg << "La valeur doit être comprise entre " << NumericConversions::userRepresentation (validator.bottom ( ), NumericServices::doubleScientificNotationCharMax, 1)
<< " et " << NumericConversions::userRepresentation (validator.top ( ), NumericServices::doubleScientificNotationCharMax, 1) << ".";
throw Exception (errorMsg);
} // if ((dValue < validator.bottom ( )) || ...
} // if ((dValue < validator.bottom ( )) || (dValue > validator.top ( )))
// FIN V 2.44.1
/* V <= 2.44.0
if ((false == ok) ||
(QValidator::Acceptable != validator.validate (tValue, pos)))
{
UTF8String errorMsg (charset);
errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n";

if ((validator.bottom ( ) == -NumericServices::doubleMachMax ( )) &&
(validator.top ( ) == NumericServices::doubleMachMax ( )))
errorMsg << "La valeur doit être de type réel double précision.";
else if ((validator.bottom ( ) == -NumericServices::floatMachMax ( )) &&
(validator.top ( ) == NumericServices::floatMachMax ( )))
errorMsg << "La valeur doit être de type réel simple précision.";
else
errorMsg << "La valeur doit être comprise entre "
<< ios_base::fixed << IN_UTIL setprecision (2)
<< validator.bottom ( )
<< " et " << validator.top ( ) << ".";
throw Exception (errorMsg);
} // if ((false == ok)
*/

return dValue;
} // QtDoubleTextField::getValue
Expand All @@ -130,27 +95,15 @@ void QtDoubleTextField::setValue (double value)
if ((value < validator.bottom ( )) || (value > validator.top ( )))
{
UTF8String errorMsg (charset);
errorMsg << "Erreur : la valeur " << value
<< " est en dehors du domaine autorisé ("
<< NumericConversions::userRepresentation ( // v 2.48.0
validator.bottom ( ),
NumericServices::doubleScientificNotationCharMax, 1)
<< " - "
<< NumericConversions::userRepresentation ( // v 2.48.0
validator.top ( ),
NumericServices::doubleScientificNotationCharMax, 1)
// << ios_base::fixed << IN_UTIL setprecision (2)
// << validator.bottom ( ) << " - " << validator.top ( )
<< ").";
errorMsg << "Erreur : la valeur " << value << " est en dehors du domaine autorisé ("
<< NumericConversions::userRepresentation (validator.bottom ( ), NumericServices::doubleScientificNotationCharMax, 1)
<< " - " << NumericConversions::userRepresentation (validator.top ( ), NumericServices::doubleScientificNotationCharMax, 1) << ").";
throw Exception (errorMsg);
} // if ((value < validator.bottom ( )) || (value > validator.top ( )))

// On évite de perdre des epsilons avec le format d'affichage par défaut des
// streams c++ :
// setText (UTF8TOQSTRING (value));
// On évite de perdre des epsilons avec le format d'affichage par défaut des streams c++ :
UTF8String us;
us << (QDoubleValidator::StandardNotation == getNotation ( ) ?
ios_base::fixed : ios_base::scientific);
us << (QDoubleValidator::StandardNotation == getNotation ( ) ? ios_base::fixed : ios_base::scientific);
us << IN_UTIL setprecision (validator.decimals ( )) << value;
setText (UTF8TOQSTRING (us));
getValue ( );
Expand All @@ -167,20 +120,13 @@ void QtDoubleTextField::getRange (double& min, double& max) const

void QtDoubleTextField::setRange (double min, double max)
{
if (min >= max)
if (min > max)
{
UTF8String errorMsg (charset);
errorMsg << "Domaine de saisie d'un réel invalide : ("
<< NumericConversions::userRepresentation (min,
NumericServices::doubleScientificNotationCharMax, 1)
<< " - "
<< NumericConversions::userRepresentation (max,
NumericServices::doubleScientificNotationCharMax, 1)
// << ios_base::fixed << IN_UTIL setprecision (2)
// << min << " - " << max
<< ").";
errorMsg << "Domaine de saisie d'un réel invalide : (" << NumericConversions::userRepresentation (min, NumericServices::doubleScientificNotationCharMax, 1)
<< " - " << NumericConversions::userRepresentation (max, NumericServices::doubleScientificNotationCharMax, 1) << ").";
throw Exception (errorMsg);
} // if (min >= max)
} // if (min > max)

const QDoubleValidator& old = getValidator ( );
QDoubleValidator* v = cloneValidator ( );
Expand Down Expand Up @@ -252,8 +198,7 @@ void QtDoubleTextField::createGui ( )

const QDoubleValidator& QtDoubleTextField::getValidator ( ) const
{
const QDoubleValidator* v=
dynamic_cast<const QDoubleValidator*>(validator ( ));
const QDoubleValidator* v = dynamic_cast<const QDoubleValidator*>(validator ( ));
if (0 == v)
{
INTERNAL_ERROR (exc, "Absence de validateur.", "QtDoubleTextField::getValidator")
Expand All @@ -267,8 +212,7 @@ const QDoubleValidator& QtDoubleTextField::getValidator ( ) const
QDoubleValidator* QtDoubleTextField::cloneValidator ( )
{
const QDoubleValidator& old = getValidator ( );
QDoubleValidator* v =
new QDoubleValidator (old.bottom( ), old.top( ), old.decimals( ), this);
QDoubleValidator* v = new QDoubleValidator (old.bottom( ), old.top( ), old.decimals( ), this);
v->setNotation (old.notation ( ));

return v;
Expand All @@ -286,16 +230,14 @@ bool QtDoubleTextField::validate ( )
{
setSkin (false);
if (true == QtValidatedTextField::dialogOnError)
QtMessageBox::displayErrorMessage (
this, "Saisie invalide", exc.getFullMessage ( ));
QtMessageBox::displayErrorMessage (this, "Saisie invalide", exc.getFullMessage ( ));
return false;
}
catch (...)
{
setSkin (false);
if (true == QtValidatedTextField::dialogOnError)
QtMessageBox::displayErrorMessage (
this, "Saisie invalide", "Erreur non documentée.");
QtMessageBox::displayErrorMessage (this, "Saisie invalide", "Erreur non documentée.");
return false;
}

Expand Down
30 changes: 10 additions & 20 deletions src/QtUtil/QtIntTextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ static const Charset charset ("àéèùô");
USE_ENCODING_AUTODETECTION


QtIntTextField::QtIntTextField (
QWidget* parent, bool autoValidation, const char* name)
QtIntTextField::QtIntTextField (QWidget* parent, bool autoValidation, const char* name)
: QtValidatedTextField (parent, autoValidation, name)
{
createGui ( );
} // QtIntTextField::QtIntTextField


QtIntTextField::QtIntTextField (
int value, QWidget* parent, bool autoValidation, const char* name)
QtIntTextField::QtIntTextField (int value, QWidget* parent, bool autoValidation, const char* name)
: QtValidatedTextField (parent, autoValidation, name)
{
createGui ( );
Expand Down Expand Up @@ -67,8 +65,7 @@ int QtIntTextField::getValue ( ) const
int iValue = tValue.toInt (&ok);
const QIntValidator& validator = getValidator ( );

if ((false == ok) ||
(QValidator::Acceptable != validator.validate (tValue, pos)))
if ((false == ok) || (QValidator::Acceptable != validator.validate (tValue, pos)))
{
UTF8String errorMsg (charset);
errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n";
Expand Down Expand Up @@ -109,10 +106,7 @@ void QtIntTextField::setValue (int value)
if ((value < validator.bottom ( )) || (value > validator.top ( )))
{
UTF8String errorMsg (charset);
errorMsg << "Erreur : la valeur " << (long)value
<< " est en dehors du domaine autorisé ("
<< (long)validator.bottom ( ) << " - "
<< (long)validator.top ( ) << ").";
errorMsg << "Erreur : la valeur " << (long)value << " est en dehors du domaine autorisé (" << (long)validator.bottom ( ) << " - " << (long)validator.top ( ) << ").";
throw Exception (errorMsg);
} // if ((value < validator.bottom ( )) || (value > validator.top ( )))

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

void QtIntTextField::setRange (int min, int max)
{
if (min >= max)
if (min > max)
{
UTF8String errorMsg (charset);
errorMsg << "Domaine de saisie d'un réel invalide : ("
<< (long)min << " - " << (long)max << ").";
errorMsg << "Domaine de saisie d'un réel invalide : (" << (long)min << " - " << (long)max << ").";
throw Exception (errorMsg);
} // if (min >= max)
} // if (min > max)

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

const QIntValidator& QtIntTextField::getValidator ( ) const
{
const QIntValidator* v=
dynamic_cast<const QIntValidator*>(validator ( ));
const QIntValidator* v = dynamic_cast<const QIntValidator*>(validator ( ));
if (0 == v)
{
INTERNAL_ERROR (exc, "Absence de validateur.", "QtIntTextField::getValidator")
Expand All @@ -177,16 +169,14 @@ bool QtIntTextField::validate ( )
{
setSkin (false);
if (true == QtValidatedTextField::dialogOnError)
QtMessageBox::displayErrorMessage (
this, "Saisie invalide", exc.getFullMessage ( ));
QtMessageBox::displayErrorMessage (this, "Saisie invalide", exc.getFullMessage ( ));
return false;
}
catch (...)
{
setSkin (false);
if (true == QtValidatedTextField::dialogOnError)
QtMessageBox::displayErrorMessage (
this, "Saisie invalide", "Erreur non documentée.");
QtMessageBox::displayErrorMessage (this, "Saisie invalide", "Erreur non documentée.");
return false;
}

Expand Down
6 changes: 2 additions & 4 deletions src/QtUtil/QtMultiLineToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ QtMultiLineToolbar::QtMultiLineToolbar (QWidget* parent)
: QWidget (parent), _iconSize (32, 32)
{
setLayout (new QtFlowLayout (this));
QApplication* app =
dynamic_cast<QApplication*>(QApplication::instance ( ));
QApplication* app = dynamic_cast<QApplication*>(QApplication::instance ( ));
if ((0 != app) && (0 != app->style ( )))
{
int size = app->style ( )->pixelMetric (QStyle::PM_ToolBarIconSize);
Expand Down Expand Up @@ -68,8 +67,7 @@ void QtMultiLineToolbar::addSeparator ( )
{
CHECK_NULL_PTR_ERROR (layout ( ))
QWidget* separator = new QWidget (this);
separator->setFixedSize (
QSize (iconSize ( ).width ( ) / 2, iconSize ( ).height ( ) / 2));
separator->setFixedSize (QSize (iconSize ( ).width ( ) / 2, iconSize ( ).height ( ) / 2));
layout ( )->addWidget (separator);
} // QtMultiLineToolbar::addSeparator

Expand Down
7 changes: 2 additions & 5 deletions src/QtUtil/QtRichTextComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ void QtRichTextComboBox::paintEvent (QPaintEvent*)
#else // QT_5
left = contentsMargins ( ).left ( );
#endif // QT_5
// Pour une raison non élucidée un deltax est esthétiquement
// souhaitable (left et autres sont nuls) :
// Pour une raison non élucidée un deltax est esthétiquement souhaitable (left et autres sont nuls) :
painter.translate (left + QtConfiguration::margin, 0);
textDocument.drawContents (&painter, rect);
} // QtRichTextComboBox::paintEvent
Expand All @@ -127,9 +126,7 @@ QSize QtComboBoxItemDelegate::sizeHint (
} // QtComboBoxItemDelegate::sizeHint


void QtComboBoxItemDelegate::paint (
QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const
void QtComboBoxItemDelegate::paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
painter->save ( );

Expand Down
Loading