From dc5526ba88fb1164a146f2610934b2f760fed97e Mon Sep 17 00:00:00 2001 From: Charles PIGNEROL <> Date: Wed, 13 Dec 2023 15:02:26 +0100 Subject: [PATCH] Version 6.4.0. Porting Qt 6. --- CMakeLists.txt | 2 +- cmake/version.cmake | 2 +- src/QtUtil/CMakeLists.txt | 41 +++--- src/QtUtil/Qt3DDataPanel.cpp | 5 - src/QtUtil/QtAboutDialog.cpp | 9 +- src/QtUtil/QtAutoWaitingCursor.cpp | 4 - src/QtUtil/QtColorChooser.cpp | 17 ++- src/QtUtil/QtCoordinatesDialog.cpp | 34 +++-- src/QtUtil/QtCoordinatesTextField.cpp | 68 ++++++---- src/QtUtil/QtDlgClosurePanel.cpp | 5 - src/QtUtil/QtExclusiveActionGroup.cpp | 4 - src/QtUtil/QtExtMessageBox.cpp | 18 ++- src/QtUtil/QtExternalLinkDialog.cpp | 6 - src/QtUtil/QtFlowLayout.cpp | 13 +- src/QtUtil/QtFontPanel.cpp | 5 - src/QtUtil/QtGroupBox.cpp | 19 ++- src/QtUtil/QtLogsView.cpp | 4 - src/QtUtil/QtMatrixDialog.cpp | 13 +- src/QtUtil/QtMessageBox.cpp | 119 ++++++------------ src/QtUtil/QtMultiLineToolbar.cpp | 5 - src/QtUtil/QtPenPanel.cpp | 6 - src/QtUtil/QtRichTextComboBox.cpp | 18 ++- src/QtUtil/QtRotationDialog.cpp | 16 +-- src/QtUtil/QtScientificTextDialog.cpp | 4 + src/QtUtil/QtStringHelper.cpp | 99 ++++++++------- src/QtUtil/QtStringListSelectionPanel.cpp | 8 -- src/QtUtil/QtStringPanel.cpp | 6 +- src/QtUtil/QtTextDialog.cpp | 39 ++---- src/QtUtil/QtTextEditor.cpp | 66 ++++------ src/QtUtil/QtTextField.cpp | 37 ++++-- src/QtUtil/QtValidatedTextField.cpp | 65 +++++----- src/QtUtil/QtWebBrowser.cpp | 13 -- src/QtUtil/QtWidgetAction.cpp | 4 - src/QtUtil/cmake/QtUtilConfig.cmake.in | 10 +- src/QtUtil/public/QtUtil/QtAboutDialog.h | 7 +- src/QtUtil/public/QtUtil/QtActionAutoLock.h | 4 - .../public/QtUtil/QtAutoWaitingCursor.h | 4 - .../public/QtUtil/QtCoordinatesDialog.h | 5 - .../public/QtUtil/QtCoordinatesTextField.h | 4 +- src/QtUtil/public/QtUtil/QtDlgClosurePanel.h | 5 - .../public/QtUtil/QtExclusiveActionGroup.h | 5 - src/QtUtil/public/QtUtil/QtExtMessageBox.h | 8 +- .../public/QtUtil/QtExternalLinkDialog.h | 4 - src/QtUtil/public/QtUtil/QtFlowLayout.h | 6 - src/QtUtil/public/QtUtil/QtFontPanel.h | 7 -- src/QtUtil/public/QtUtil/QtGroupBox.h | 6 - src/QtUtil/public/QtUtil/QtLogsView.h | 6 - src/QtUtil/public/QtUtil/QtMatrixDialog.h | 6 +- src/QtUtil/public/QtUtil/QtMessageBox.h | 16 +-- .../public/QtUtil/QtMinMaxDialog_impl.h | 29 ++--- src/QtUtil/public/QtUtil/QtMultiLineToolbar.h | 5 +- src/QtUtil/public/QtUtil/QtPenPanel.h | 6 - src/QtUtil/public/QtUtil/QtRichTextComboBox.h | 5 - src/QtUtil/public/QtUtil/QtRotationDialog.h | 5 - .../public/QtUtil/QtScientificTextDialog.h | 4 - .../public/QtUtil/QtStatusLogOutputStream.h | 4 - .../QtUtil/QtStringListSelectionPanel.h | 5 - .../QtUtil/QtStringNumberFormatComboBox.h | 4 - src/QtUtil/public/QtUtil/QtTextDialog.h | 6 - src/QtUtil/public/QtUtil/QtTextEditor.h | 6 +- src/QtUtil/public/QtUtil/QtTextField.h | 4 - src/QtUtil/public/QtUtil/QtWebBrowser.h | 10 +- src/QtUtil/public/QtUtil/QtWidgetAction.h | 4 - src/QtUtil/public/QtUtil/QtWidgetAutoLock.h | 5 +- src/encoding/CMakeLists.txt | 3 +- src/encoding/QtEncodingMainWindow.h | 10 +- src/flow/CMakeLists.txt | 3 +- src/flow/main.cpp | 6 +- src/flow/window.cpp | 7 +- src/flow/window.h | 6 +- src/tests/CMakeLists.txt | 3 +- src/tests/QtAboutMainWindow.cpp | 14 +-- src/tests/QtAboutMainWindow.h | 9 +- src/tests/about_dlg.cpp | 14 +-- versions.txt | 8 ++ 75 files changed, 416 insertions(+), 646 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ec7f2e..f520e25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.15) project (QtUtil CXX) diff --git a/cmake/version.cmake b/cmake/version.cmake index a2461c5..3c0d708 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -3,7 +3,7 @@ # set (QT_UTIL_MAJOR_VERSION "6") -set (QT_UTIL_MINOR_VERSION "3") +set (QT_UTIL_MINOR_VERSION "4") set (QT_UTIL_RELEASE_VERSION "0") set (QT_UTIL_VERSION ${QT_UTIL_MAJOR_VERSION}.${QT_UTIL_MINOR_VERSION}.${QT_UTIL_RELEASE_VERSION}) diff --git a/src/QtUtil/CMakeLists.txt b/src/QtUtil/CMakeLists.txt index b0c2110..1ee4405 100644 --- a/src/QtUtil/CMakeLists.txt +++ b/src/QtUtil/CMakeLists.txt @@ -5,11 +5,12 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) find_package (TkUtil 6 REQUIRED) -find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) -find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}PrintSupport ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) # # Aide hypertexte avec navigateur web. Le navigateur utilisant sur le QtWebEngine qui repose sur Chromium est nettement mieux # que le QtTextBrowser, mais son installation est très délicate et incertaine ... @@ -21,29 +22,29 @@ find_package (Qt5PrintSupport 5 REQUIRED NO_CMAKE_SYSTEM_PATH) # if ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER)) message (STATUS "--> Aide hypertexte : tentative d'utiliser QtWebEngine (meilleur) ...") - find_package (Qt5WebEngineWidgets 5 NO_CMAKE_SYSTEM_PATH) - if (Qt5WebEngineWidgets_FOUND) + find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} NO_CMAKE_SYSTEM_PATH) + if (Qt${QT_MAJOR}WebEngineWidgets_FOUND) message (STATUS "--> QtWebEngine trouvé et utilisé.") set (USE_QT_WEB_ENGINE ON) - else (Qt5WebEngineWidgets_FOUND) + else (Qt${QT_MAJOR}WebEngineWidgets_FOUND) message (STATUS "--> QtWebEngine non trouvé : tentative d'utiliser QtWebKit en remplacement ...") - find_package (Qt5WebKitWidgets NO_CMAKE_SYSTEM_PATH) - if (Qt5WebKitWidgets_FOUND) + find_package (Qt${QT_MAJOR}WebKitWidgets NO_CMAKE_SYSTEM_PATH) + if (Qt${QT_MAJOR}WebKitWidgets_FOUND) message (STATUS "--> QtWebKit trouvé et utilisé.") set (USE_QT_WEBKIT ON) - else (Qt5WebKitWidgets_FOUND) + else (Qt${QT_MAJOR}WebKitWidgets_FOUND) message (STATUS "--> QtWebKit non trouvé : utilisation par défaut de QtTextBrowser pour l'aide hypertexte.") set (USE_QT_TEXT_BROWSER ON) - endif (Qt5WebKitWidgets_FOUND) - endif (Qt5WebEngineWidgets_FOUND) + endif (Qt${QT_MAJOR}WebKitWidgets_FOUND) + endif (Qt${QT_MAJOR}WebEngineWidgets_FOUND) endif ((NOT USE_QT_WEB_ENGINE) AND (NOT USE_QT_WEBKIT) AND (NOT USE_QT_TEXT_BROWSER)) if (USE_QT_WEB_ENGINE) - find_package (Qt5WebView 5 REQUIRED NO_CMAKE_SYSTEM_PATH) - find_package (Qt5WebEngineWidgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) + find_package (Qt${QT_MAJOR}WebView ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) + find_package (Qt${QT_MAJOR}WebEngineWidgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) endif (USE_QT_WEB_ENGINE) if (USE_QT_WEBKIT) - find_package (Qt5WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH) + find_package (Qt${QT_MAJOR}WebKitWidgets REQUIRED NO_CMAKE_SYSTEM_PATH) endif (USE_QT_WEBKIT) file (GLOB HEADERS public/${CURRENT_PACKAGE_NAME}/*.h) @@ -57,9 +58,9 @@ set (ALL_TARGETS QtUtil) set_property (TARGET QtUtil PROPERTY VERSION ${QT_UTIL_VERSION}) set_property (TARGET QtUtil PROPERTY SOVERSION ${QT_UTIL_MAJOR_VERSION}) -set (QT_UTIL_PUBLIC_FLAGS -DQT_5) -set (QT_LIB_DEPENDENCIES Qt5::Widgets Qt5::Gui Qt5::PrintSupport Qt5::Core) -set (QT_INC_DEPENDENCIES ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS}) +set (QT_UTIL_PUBLIC_FLAGS -DQT_${QT_MAJOR}) +set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::Gui Qt${QT_MAJOR}::PrintSupport Qt${QT_MAJOR}::Core) +set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}Widgets_INCLUDE_DIRS} ${Qt${QT_MAJOR}Gui_INCLUDE_DIRS} ${Qt${QT_MAJOR}PrintSupport_INCLUDE_DIRS} ${Qt${QT_MAJOR}Core_INCLUDE_DIRS}) set (QtWebEngine_ENABLED OFF) # Pour find_dependcy set (QtWebKit_ENABLED OFF) # Pour find_dependcy if (USE_QT_TEXT_BROWSER) @@ -70,13 +71,13 @@ else (USE_QT_TEXT_BROWSER) # => QtWebEngine message (STATUS "==> Utilisation de QtWebKit") set (QtWebKit_ENABLED ON) list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBKIT) - set (QT_LIB_DEPENDENCIES Qt5::WebKitWidgets) + set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebKitWidgets) else (USE_QT_WEBKIT) message (STATUS "==> Utilisation de QtWebEngine") set (QtWebEngine_ENABLED ON) list (APPEND QT_UTIL_PUBLIC_FLAGS -DUSE_QT_WEBENGINE) - set (QT_LIB_DEPENDENCIES Qt5::WebEngineWidgets Qt5::WebView) - set (QT_INC_DEPENDENCIES ${Qt5WebEngineWidgets_INCLUDE_DIRS} ${Qt5WebView_INCLUDE_DIRS}) + set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::WebEngineWidgets Qt${QT_MAJOR}::WebView) + set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}WebEngineWidgets_INCLUDE_DIRS} ${Qt${QT_MAJOR}WebView_INCLUDE_DIRS}) endif (USE_QT_WEBKIT) endif (USE_QT_TEXT_BROWSER) set (QT_UTIL_PRIVATE_FLAGS -DQT_UTIL_VERSION="${QT_UTIL_VERSION}") @@ -87,7 +88,7 @@ target_compile_definitions (QtUtil PRIVATE ${QT_UTIL_PRIVATE_FLAGS}) target_compile_options (QtUtil PRIVATE ${SHARED_CFLAGS}) # Requested by Qt ... target_include_directories (QtUtil PUBLIC ${QT_INC_DEPENDENCIES}) target_link_libraries (QtUtil PUBLIC TkUtil::TkUtil ${QT_LIB_DEPENDENCIES}) -# Etre capable une fois installée de retrouver TkUtil, Qt5*, ... : +# Etre capable une fois installée de retrouver TkUtil, Qt${QT_MAJOR}*, ... : # (Rem : en son absence on a Set runtime path of "/tmp/pignerol/install/lib/libQtUtil.so.5.0.0" to "") ... set_target_properties (QtUtil PROPERTIES INSTALL_RPATH_USE_LINK_PATH 1) # Inefficace ici : CMAKE_AUTOMOC => dans le CMakeLists.txt racine diff --git a/src/QtUtil/Qt3DDataPanel.cpp b/src/QtUtil/Qt3DDataPanel.cpp index 5dd9cfc..f3331bf 100644 --- a/src/QtUtil/Qt3DDataPanel.cpp +++ b/src/QtUtil/Qt3DDataPanel.cpp @@ -6,13 +6,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 USING_STD diff --git a/src/QtUtil/QtAboutDialog.cpp b/src/QtUtil/QtAboutDialog.cpp index ec4cf24..89432df 100644 --- a/src/QtUtil/QtAboutDialog.cpp +++ b/src/QtUtil/QtAboutDialog.cpp @@ -5,17 +5,10 @@ #include "QtUtil/QtUnicodeHelper.h" -#ifndef QT_5 -#include -#include -#include -#include -#else // QT_5 #include #include #include #include -#endif // QT_5 #include #include @@ -235,9 +228,11 @@ void QtAboutDialog::showEvent (QShowEvent* event) connect (closeButton, SIGNAL(clicked ( )), this, SLOT(accept ( ))); setLayout (_layout); +#ifdef QT_5 _layout->activate ( ); setFixedSize (sizeHint ( )); updateGeometry ( ); +#endif // QT_5 } // if (0 == _layout) QDialog::showEvent (event); diff --git a/src/QtUtil/QtAutoWaitingCursor.cpp b/src/QtUtil/QtAutoWaitingCursor.cpp index b39635e..27c15b2 100644 --- a/src/QtUtil/QtAutoWaitingCursor.cpp +++ b/src/QtUtil/QtAutoWaitingCursor.cpp @@ -5,11 +5,7 @@ using namespace std; #include #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 QtAutoWaitingCursor::QtAutoWaitingCursor (bool s) diff --git a/src/QtUtil/QtColorChooser.cpp b/src/QtUtil/QtColorChooser.cpp index f1e2290..c0285dc 100644 --- a/src/QtUtil/QtColorChooser.cpp +++ b/src/QtUtil/QtColorChooser.cpp @@ -61,10 +61,15 @@ void QtColorChooser::createGui (const UTF8String& label, const Color& color) layout->addWidget (button); _colorLabel = new QLabel (" ", this); _colorLabel->setAutoFillBackground (true); - QPalette palette (_colorLabel->palette ( )); QColor qcolor (color.getRed( ), color.getGreen( ), color.getBlue( )); +#ifdef QT_5 + QPalette palette (_colorLabel->palette ( )); palette.setBrush (QPalette::Background, qcolor); _colorLabel->setPalette (palette); +#else // QT_5 + QString backgroundLabel ("background-color:"); + _colorLabel->setStyleSheet (backgroundLabel + qcolor.name ( )); // => background-color:#RRGGBB +#endif // QT_5 layout->addWidget (_colorLabel ); connect (button, SIGNAL (clicked (bool)), this, SLOT (clickedCallback ( ))); @@ -83,9 +88,14 @@ QColor QtColorChooser::getQColor ( ) const void QtColorChooser::setQColor (const QColor& color) { assert ((0 != _colorLabel) && "QtColorChooser::setQColor : null color label."); +#ifdef QT_5 QPalette palette (_colorLabel->palette ( )); palette.setBrush (QPalette::Background, color); _colorLabel->setPalette (palette); +#else // QT_5 + QString backgroundLabel ("background-color:"); + _colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB +#endif // QT_5 } // QtColorChooser::setQColor @@ -115,9 +125,14 @@ void QtColorChooser::clickedCallback ( ) if (current == color) return; +#ifdef QT_5 QPalette palette (_colorLabel->palette ( )); palette.setBrush (QPalette::Background, color); _colorLabel->setPalette (palette); +#else // QT_5 + QString backgroundLabel ("background-color:"); + _colorLabel->setStyleSheet (backgroundLabel + color.name ( )); // => background-color:#RRGGBB +#endif // QT_5 emit (colorChanged (color)); } // QtColorChooser::clickedCallback diff --git a/src/QtUtil/QtCoordinatesDialog.cpp b/src/QtUtil/QtCoordinatesDialog.cpp index 16ecf72..7c3e08e 100644 --- a/src/QtUtil/QtCoordinatesDialog.cpp +++ b/src/QtUtil/QtCoordinatesDialog.cpp @@ -5,17 +5,12 @@ #include "QtUtil/QtMessageBox.h" #include +#include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include @@ -35,7 +30,8 @@ QtCoordinatesDialog::QtCoordinatesDialog ( : QDialog (parent, QtConfiguration::modalDialogWFlags), _xTextField (0), _yTextField (0), _zTextField (0), _modifyXCheckBox (0), _modifyYCheckBox (0), _modifyZCheckBox (0), _closurePanel (0) { - createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0 +// createGui (title, xLabel, yLabel, zLabel, x, y, z, 1., -1., 1., -1., 1., -1., checkboxesEnabled, xEnabled, yEnabled, zEnabled, helpURL, helpTag); // v 6.3.0 + createGui (title, xLabel, yLabel, zLabel, x, y, z, checkboxesEnabled, xEnabled, yEnabled, zEnabled, -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), -NumericServices::doubleMachMax ( ), NumericServices::doubleMachMax ( ), helpURL, helpTag); } // QtCoordinatesDialog::QtCoordinatesDialog @@ -61,20 +57,33 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String& // Creation de l'ihm : QVBoxLayout* layout = new QVBoxLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); - + // Le panneau : QtGroupBox* groupBox = new QtGroupBox ("Composantes", this); groupBox->setSpacing (QtConfiguration::spacing); +#ifdef QT_5 groupBox->setMargin (QtConfiguration::margin); +#else // => Qt6 + groupBox->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 + layout->addWidget (groupBox); QVBoxLayout* coordsLayout = new QVBoxLayout (groupBox); groupBox->setLayout (coordsLayout); // Ligne 1 : X QWidget* hbox = new QWidget (groupBox); QHBoxLayout* hboxLayout = new QHBoxLayout ( ); +#ifdef QT_5 hboxLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 hboxLayout->setSpacing (QtConfiguration::spacing); hbox->setLayout (hboxLayout); coordsLayout->addWidget (hbox); @@ -102,7 +111,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String& // Ligne 2 : Y hbox = new QWidget (groupBox); hboxLayout = new QHBoxLayout ( ); +#ifdef QT_5 hboxLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 hboxLayout->setSpacing (QtConfiguration::spacing); hbox->setLayout (hboxLayout); coordsLayout->addWidget (hbox); @@ -130,7 +143,11 @@ void QtCoordinatesDialog::createGui (const UTF8String& title, const UTF8String& // Ligne 3 : Y hbox = new QWidget (groupBox); hboxLayout = new QHBoxLayout ( ); +#ifdef QT_5 hboxLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 hboxLayout->setSpacing (QtConfiguration::spacing); hbox->setLayout (hboxLayout); coordsLayout->addWidget (hbox); @@ -205,6 +222,7 @@ void QtCoordinatesDialog::getCoordinates (double& x, double& y, double& z) const assert (0 != _xTextField); assert (0 != _yTextField); assert (0 != _zTextField); + bool xOk = true, yOk = true, zOk = true; x = _xTextField->text ( ).toDouble (&xOk); y = _yTextField->text ( ).toDouble (&yOk); diff --git a/src/QtUtil/QtCoordinatesTextField.cpp b/src/QtUtil/QtCoordinatesTextField.cpp index 6eff93d..be0e914 100644 --- a/src/QtUtil/QtCoordinatesTextField.cpp +++ b/src/QtUtil/QtCoordinatesTextField.cpp @@ -14,7 +14,11 @@ #include #include -#include +#ifdef QT_5 +# include +#else // QT_5 +# include +#endif // QT_5 #include #include @@ -38,22 +42,36 @@ USE_ENCODING_AUTODETECTION * classe évalue où est effectuée la modification et retourne * Intermediate si elle est valide du début à ce point. */ +#ifdef QT_5 class QtRegExpValidator : public QRegExpValidator +#else // QT_5 +class QtRegExpValidator : QRegularExpressionValidator +#endif // QT_5 { public : QtRegExpValidator (QObject* parent) +#ifdef QT_5 : QRegExpValidator (parent) +#else // QT_5 + : QRegularExpressionValidator (parent) +#endif // QT_5 { } +#ifdef QT_5 QtRegExpValidator (const QRegExp& exp, QObject* parent) : QRegExpValidator (exp, parent) +#else // QT_5 + QtRegExpValidator (const QRegularExpression& exp, QObject* parent) + : QRegularExpressionValidator (exp, parent) +#endif // QT_5 { } virtual ~QtRegExpValidator ( ) { } virtual QValidator::State validate (QString& input, int& pos ) const { - if (regExp ( ).exactMatch(input)) +#ifdef QT_5 + if (regExp ( ).exactMatch (input)) return Acceptable; else { @@ -65,8 +83,15 @@ class QtRegExpValidator : public QRegExpValidator pos = input.size(); return Invalid; } - } - + } // else +#else // QT_5 + QRegularExpressionMatch match = regularExpression ( ).match (input); + + if (false == match.hasMatch ( )) + return QValidator::Invalid; + + return true == match.hasPartialMatch ( ) ? QValidator::Intermediate : QValidator::Acceptable; +#endif // QT_5 } // QValidator::State @@ -77,8 +102,7 @@ class QtRegExpValidator : public QRegExpValidator }; // class QtRegExpValidator -QtCoordinatesTextField::QtCoordinatesTextField ( - QWidget* parent, double x, double y, double z, unsigned short precision) +QtCoordinatesTextField::QtCoordinatesTextField (QWidget* parent, double x, double y, double z, unsigned short precision) : QtValidatedTextField (parent, false), _precision (precision) { setCoordinates (x, y, z); @@ -91,8 +115,14 @@ QtCoordinatesTextField::QtCoordinatesTextField ( coordsExp << "\\(" << espaces << doubleExp << espaces << "[,]" << espaces << doubleExp << espaces << "[,]" << espaces << doubleExp << espaces << "\\)"; +#ifdef QT_5 QRegExp expression (coordsExp.iso ( ).c_str ( )); QtRegExpValidator* validator = new QtRegExpValidator (expression, this); +#else // QT_5 + QRegularExpression expression (coordsExp.iso ( ).c_str ( )); + QRegularExpressionValidator* validator = new QRegularExpressionValidator (expression, this); + +#endif // QT_5 setValidator (validator); } // QtCoordinatesTextField::QtCoordinatesTextField @@ -104,8 +134,7 @@ QtCoordinatesTextField::QtCoordinatesTextField (const QtCoordinatesTextField&) } // QtCoordinatesTextField::QtCoordinatesTextField -QtCoordinatesTextField& QtCoordinatesTextField::operator = ( - const QtCoordinatesTextField&) +QtCoordinatesTextField& QtCoordinatesTextField::operator = (const QtCoordinatesTextField&) { assert (0 && "QtCoordinatesTextField assignment operator is not allowed."); return *this; @@ -117,8 +146,7 @@ QtCoordinatesTextField::~QtCoordinatesTextField () } // QtCoordinatesTextField::~QtCoordinatesTextField -void QtCoordinatesTextField::getCoordinates ( - double& x, double& y, double& z) const +void QtCoordinatesTextField::getCoordinates (double& x, double& y, double& z) const { const string coords = text ( ).toStdString ( ); const string::size_type beg = coords.find ("("); @@ -126,8 +154,7 @@ void QtCoordinatesTextField::getCoordinates ( if ((string::npos == beg) || (string::npos == end)) { UTF8String error (charset); - error << "Erreur lors de l'extraction des composantes des coordonnées\n" - << coords; + error << "Erreur lors de l'extraction des composantes des coordonnées\n" << coords; throw Exception (error); } // if ((string::npos == beg) || (string::npos == end)) @@ -137,8 +164,7 @@ void QtCoordinatesTextField::getCoordinates ( if ((string::npos == c1) || (string::npos == c2)) { UTF8String error (charset); - error << "Erreur lors de l'extraction des composantes des coordonnées\n" - << coords; + error << "Erreur lors de l'extraction des composantes des coordonnées\n" << coords; throw Exception (error); } // if ((string::npos == beg) || (string::npos == end)) const string xVal = values.substr (0, c1 - 1); @@ -190,12 +216,8 @@ bool QtCoordinatesTextField::validate ( ) if (QValidator::Acceptable != v->validate (tValue, pos)) { UTF8String errorMsg (charset); - errorMsg << "Valeur " - << tValue.toStdString ( ) - << " incorrecte. La valeur doit être du type (x, y, z)" - << "\n" - << "où x, y et z sont des réels en notation scientifique (" - << "ex : 0.123, -1.4e-2, ...)."; + errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte. La valeur doit être du type (x, y, z)\n" + << "où x, y et z sont des réels en notation scientifique (ex : 0.123, -1.4e-2, ...)."; throw Exception (errorMsg); } // if (QValidator::Acceptable != v->validate (tValue, pos)) setSkin (true); @@ -204,16 +226,14 @@ bool QtCoordinatesTextField::validate ( ) { setSkin (false); if (true == dialogOnError) - QtMessageBox::displayErrorMessage ( - this, "Saisie invalide", exc.getFullMessage ( )); + QtMessageBox::displayErrorMessage (this, "Saisie invalide", exc.getFullMessage ( )); return false; } catch (...) { setSkin (false); if (true == dialogOnError) - QtMessageBox::displayErrorMessage ( - this, "Saisie invalide", "Erreur non documentée."); + QtMessageBox::displayErrorMessage (this, "Saisie invalide", "Erreur non documentée."); return false; } diff --git a/src/QtUtil/QtDlgClosurePanel.cpp b/src/QtUtil/QtDlgClosurePanel.cpp index 5134f22..318ad97 100644 --- a/src/QtUtil/QtDlgClosurePanel.cpp +++ b/src/QtUtil/QtDlgClosurePanel.cpp @@ -3,13 +3,8 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 USING_STD diff --git a/src/QtUtil/QtExclusiveActionGroup.cpp b/src/QtUtil/QtExclusiveActionGroup.cpp index 21f6a0f..6b59773 100644 --- a/src/QtUtil/QtExclusiveActionGroup.cpp +++ b/src/QtUtil/QtExclusiveActionGroup.cpp @@ -1,11 +1,7 @@ #include "QtUtil/QtExclusiveActionGroup.h" #include "TkUtil/Exception.h" -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtExtMessageBox.cpp b/src/QtUtil/QtExtMessageBox.cpp index 999b72a..0cc9a01 100644 --- a/src/QtUtil/QtExtMessageBox.cpp +++ b/src/QtUtil/QtExtMessageBox.cpp @@ -5,15 +5,9 @@ static const TkUtil::Charset charset ("àéèùô"); USE_ENCODING_AUTODETECTION -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include #include @@ -88,7 +82,11 @@ void QtExtMessageBox::createGui ( labelsbox->setLayout (labelsLayout); vboxLayout->addWidget (labelsbox); labelsLayout->setSpacing (QtConfiguration::spacing); +#ifdef QT_5 labelsLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + labelsLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 QLabel* iconLabel = new QLabel (labelsbox); iconLabel->setPixmap (QMessageBox::standardIcon (icon)); QLabel* label = new QLabel (UTF8TOQSTRING (text), labelsbox); @@ -106,7 +104,11 @@ void QtExtMessageBox::createGui ( buttonsbox->setLayout (buttonsLayout); vboxLayout->addWidget (buttonsbox); buttonsLayout->setSpacing (QtConfiguration::spacing); +#ifdef QT_5 buttonsLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + buttonsLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 _buttons [0] = true == button1.empty ( ) ? 0 : new QPushButton (UTF8TOQSTRING (button1), buttonsbox); _buttons [1] = true == button2.empty ( ) ? @@ -127,7 +129,11 @@ void QtExtMessageBox::createGui ( _buttons [defaultButton - 1]->setDefault (true); vboxLayout->setSpacing (QtConfiguration::spacing); +#ifdef QT_5 vboxLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + vboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 vbox->setFixedSize (vbox->sizeHint ( )); } // QtExtMessageBox::createGui diff --git a/src/QtUtil/QtExternalLinkDialog.cpp b/src/QtUtil/QtExternalLinkDialog.cpp index 5fb917b..a4be6a7 100644 --- a/src/QtUtil/QtExternalLinkDialog.cpp +++ b/src/QtUtil/QtExternalLinkDialog.cpp @@ -9,15 +9,9 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtFlowLayout.cpp b/src/QtUtil/QtFlowLayout.cpp index 94415a6..fc0a724 100644 --- a/src/QtUtil/QtFlowLayout.cpp +++ b/src/QtUtil/QtFlowLayout.cpp @@ -39,11 +39,7 @@ ****************************************************************************/ #include -#ifndef QT_5 -#include // requested by Qt 5.8.0 -#else // QT_5 -#include // requested by Qt 5.8.0 -#endif // QT_5 +#include #include "QtUtil/QtFlowLayout.h" //! [1] @@ -119,7 +115,7 @@ QLayoutItem *QtFlowLayout::takeAt(int index) //! [6] Qt::Orientations QtFlowLayout::expandingDirections() const { - return 0; + return Qt::Horizontal; } //! [6] @@ -155,7 +151,12 @@ QSize QtFlowLayout::minimumSize() const foreach (item, itemList) size = size.expandedTo(item->minimumSize()); +#ifdef QT_5 size += QSize(2*margin(), 2*margin()); +#else // QT_5 + const QMargins margins = contentsMargins ( ); + size += QSize (margins.left ( ) + margins.right ( ), margins.top ( ) + margins.bottom ( )); +#endif // QT_5 return size; } //! [8] diff --git a/src/QtUtil/QtFontPanel.cpp b/src/QtUtil/QtFontPanel.cpp index 1384e68..4019d1e 100644 --- a/src/QtUtil/QtFontPanel.cpp +++ b/src/QtUtil/QtFontPanel.cpp @@ -4,13 +4,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtGroupBox.cpp b/src/QtUtil/QtGroupBox.cpp index 75f83f9..446c5d9 100644 --- a/src/QtUtil/QtGroupBox.cpp +++ b/src/QtUtil/QtGroupBox.cpp @@ -55,7 +55,11 @@ void QtGroupBox::setMargin (int margin) QFontMetrics metrics = fontMetrics ( ); int fontHeight = metrics.ascent ( ) + metrics.descent ( ); +#ifdef QT_5 _layout->setMargin (margin + fontHeight); +#else // QT_5 + _layout->setContentsMargins (margin + fontHeight, margin + fontHeight, margin + fontHeight, margin + fontHeight); +#endif // QT_5 } // QtGroupBox::setMargin @@ -75,15 +79,18 @@ QSize QtGroupBox::sizeHint ( ) const else { // getLayout ( )->activate ( ); // Risque de boucle Qt infinie. - int left = 0, right = 0, top = 0, bottom = 0, framew = 0; + int left = 0, right = 0, top = 0, bottom = 0, framew = 0; +#ifdef QT_5 getContentsMargins (&left, &top, &right, &bottom); - int marg = left; + const int marg = left; +#else // QT_5 + const int marg = contentsMargins ( ).left ( ); +#endif // QT_5 + // On tient compte de la marge et de l'epaisseur du frame : - int width = _layout->sizeHint ( ).width ( ) + - 2 * marg + 2 * framew; - int height = _layout->sizeHint ( ).height ( ) + - 2 * marg + 2 * framew; + int width = _layout->sizeHint ( ).width ( ) + 2 * marg + 2 * framew; + int height = _layout->sizeHint ( ).height ( ) + 2 * marg + 2 * framew; return QSize (width, height); } // else if (0 == getLayout ( )) diff --git a/src/QtUtil/QtLogsView.cpp b/src/QtUtil/QtLogsView.cpp index b67684f..9a0ea90 100644 --- a/src/QtUtil/QtLogsView.cpp +++ b/src/QtUtil/QtLogsView.cpp @@ -5,11 +5,7 @@ #include #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtMatrixDialog.cpp b/src/QtUtil/QtMatrixDialog.cpp index 3a370e8..fad812d 100644 --- a/src/QtUtil/QtMatrixDialog.cpp +++ b/src/QtUtil/QtMatrixDialog.cpp @@ -6,13 +6,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 #include @@ -36,14 +31,22 @@ QtMatrixDialog::QtMatrixDialog ( // Creation de l'ihm : QVBoxLayout* vLayout = new QVBoxLayout (this); +#ifdef QT_5 vLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + vLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 vLayout->setSizeConstraint (QLayout::SetMinimumSize); // Le panneau : QtGroupBox* panel = new QtGroupBox ("Matrice de transformation", this); vLayout->addWidget (panel); QGridLayout* layout = new QGridLayout (panel); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSpacing (QtConfiguration::spacing); layout->setSizeConstraint (QLayout::SetMinimumSize); panel->setLayout (layout); diff --git a/src/QtUtil/QtMessageBox.cpp b/src/QtUtil/QtMessageBox.cpp index 0d3c2a0..3df38cd 100644 --- a/src/QtUtil/QtMessageBox.cpp +++ b/src/QtUtil/QtMessageBox.cpp @@ -8,15 +8,14 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include +#ifdef QT_5 #include -#include +#else // QT_5 +#include +#include #endif // QT_5 +#include USING_UTIL @@ -61,40 +60,31 @@ USE_ENCODING_AUTODETECTION #include "QtUtil/QtConfiguration.h" -#ifndef QT_5 -#include -#include -#include -#include -#else // QT_5 -#include -#include -#include -#include -#endif // QT_5 +#include +#include +#include +#include -QtMessageDialog::QtMessageDialog ( - QMessageBox::Icon icon, QWidget* parent, - const QString& title, const QString& text, int columns, - const char* button1, const char* button2, const char* button3, - int defaultButton) +QtMessageDialog::QtMessageDialog (QMessageBox::Icon icon, QWidget* parent, const QString& title, const QString& text, int columns, const char* button1, const char* button2, const char* button3, int defaultButton) : QDialog (parent) { setWindowTitle (title); QVBoxLayout* mainLayout = new QVBoxLayout (this); mainLayout->setSpacing (QtConfiguration::spacing); +#ifdef QT_5 mainLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + mainLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 QHBoxLayout* hboxLayout = new QHBoxLayout ( ); mainLayout->addLayout (hboxLayout); QLabel* iconLabel = new QLabel (this); iconLabel->setPixmap (QMessageBox::standardIcon (icon)); hboxLayout->addWidget (iconLabel); - QString formattedText = - UTF8TOQSTRING ( - QtUnicodeHelper::qstringToUTF8String (text).format (columns)); + QString formattedText = UTF8TOQSTRING (QtUnicodeHelper::qstringToUTF8String (text).format (columns)); QTextEdit* textEdit = new QTextEdit (this); textEdit->setReadOnly (true); textEdit->setLineWrapMode (QTextEdit::NoWrap); @@ -116,8 +106,7 @@ QtMessageDialog::QtMessageDialog ( if (0 != _buttons [i]) { hboxLayout->addWidget (_buttons [i]); - connect (_buttons [i], SIGNAL(clicked ( )), this, - SLOT (buttonClicked ( ))); + connect (_buttons [i], SIGNAL(clicked ( )), this, SLOT (buttonClicked ( ))); _buttons [i]->setDefault (defaultButton == i ? true : false); _buttons [i]->setAutoDefault (defaultButton == i ? true : false); } @@ -133,6 +122,7 @@ QtMessageDialog::QtMessageDialog ( int height = (int)textEdit->document ( )->size ( ).height ( ); height += 2 * QtConfiguration::margin; // Les dimensions calculées sont elles acceptables ? +#ifdef QT_5 QDesktopWidget* desktop = QApplication::desktop ( ); if (0 != desktop) { @@ -142,6 +132,17 @@ QtMessageDialog::QtMessageDialog ( if (2 * height > screenSize.height ( )) height = screenSize.height ( ) / 2; } // if (0 != desktop) +#else // QT_5 + QScreen* screen = QGuiApplication::primaryScreen ( ); + if (0 != screen) + { + const QRect screenSize = screen->virtualGeometry ( ); + if (2 * width > screenSize.width ( )) + width = screenSize.width ( ) / 2; + if (2 * height > screenSize.height ( )) + height = screenSize.height ( ) / 2; + } // if (0 != screen) +#endif // QT_5 textEdit->setMinimumSize (QSize (width, height)); textEdit->setFixedSize (QSize (width, height)); setMinimumSize (sizeHint ( )); @@ -208,20 +209,13 @@ QtMessageBox::~QtMessageBox ( ) } // QtMessageBox::~QtMessageBox -void QtMessageBox::displayInformationMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum) +void QtMessageBox::displayInformationMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum) { displayInformationMessage (parent, title, message, columnNum, "OK"); } // QtMessageBox::displayInformationMessage -int QtMessageBox::displayInformationMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum, - const char* button0Text, const char* button1Text, - const char* button2Text, int defaultButtonNumber - ) +int QtMessageBox::displayInformationMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum, const char* button0Text, const char* button1Text, const char* button2Text, int defaultButtonNumber) { QApplication::setOverrideCursor (QCursor (Qt::ArrowCursor)); @@ -229,11 +223,7 @@ int QtMessageBox::displayInformationMessage ( BEGIN_TRY_CATCH_BLOCK - QtMessageDialog dialog ( - QMessageBox::Information, parent, - UTF8TOQSTRING (title), - UTF8TOQSTRING (message), columnNum, - button0Text, button1Text, button2Text, defaultButtonNumber); + QtMessageDialog dialog (QMessageBox::Information, parent, UTF8TOQSTRING (title), UTF8TOQSTRING (message), columnNum, button0Text, button1Text, button2Text, defaultButtonNumber); button = (QMessageBox::StandardButton)dialog.exec ( ); COMPLETE_TRY_CATCH_BLOCK @@ -243,20 +233,13 @@ int QtMessageBox::displayInformationMessage ( } // QtMessageBox::displayInformationMessage -void QtMessageBox::displayWarningMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum) +void QtMessageBox::displayWarningMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum) { displayWarningMessage (parent, title, message, columnNum, "OK"); } // QtMessageBox::displayWarningMessage -int QtMessageBox::displayWarningMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum, - const char* button0Text, const char* button1Text, - const char* button2Text, int defaultButtonNumber - ) +int QtMessageBox::displayWarningMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum, const char* button0Text, const char* button1Text, const char* button2Text, int defaultButtonNumber) { QApplication::setOverrideCursor (QCursor (Qt::ArrowCursor)); @@ -264,11 +247,7 @@ int QtMessageBox::displayWarningMessage ( BEGIN_TRY_CATCH_BLOCK - QtMessageDialog dialog ( - QMessageBox::Warning, parent, - UTF8TOQSTRING (title), - UTF8TOQSTRING (message), columnNum, - button0Text, button1Text, button2Text, defaultButtonNumber); + QtMessageDialog dialog (QMessageBox::Warning, parent, UTF8TOQSTRING (title), UTF8TOQSTRING (message), columnNum, button0Text, button1Text, button2Text, defaultButtonNumber); button = (QMessageBox::StandardButton)dialog.exec ( ); COMPLETE_TRY_CATCH_BLOCK @@ -279,20 +258,13 @@ int QtMessageBox::displayWarningMessage ( } // QtMessageBox::displayWarningMessage -void QtMessageBox::displayErrorMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum) +void QtMessageBox::displayErrorMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum) { displayErrorMessage (parent, title, message, columnNum, "OK"); } // QtMessageBox::displayErrorMessage -int QtMessageBox::displayErrorMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum, - const char* button0Text, const char* button1Text, - const char* button2Text, int defaultButtonNumber - ) +int QtMessageBox::displayErrorMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum, const char* button0Text, const char* button1Text, const char* button2Text, int defaultButtonNumber) { QApplication::setOverrideCursor (QCursor (Qt::ArrowCursor)); @@ -300,11 +272,7 @@ int QtMessageBox::displayErrorMessage ( BEGIN_TRY_CATCH_BLOCK - QtMessageDialog dialog ( - QMessageBox::Critical, parent, - UTF8TOQSTRING (title), - UTF8TOQSTRING (message), columnNum, - button0Text, button1Text, button2Text, defaultButtonNumber); + QtMessageDialog dialog (QMessageBox::Critical, parent, UTF8TOQSTRING (title),UTF8TOQSTRING (message), columnNum, button0Text, button1Text, button2Text, defaultButtonNumber); button = (QMessageBox::StandardButton)dialog.exec ( ); COMPLETE_TRY_CATCH_BLOCK @@ -315,12 +283,7 @@ int QtMessageBox::displayErrorMessage ( } // QtMessageBox::displayErrorMessage -int QtMessageBox::displayQuestionMessage ( - QWidget* parent, const UTF8String& title, - const UTF8String& message, size_t columnNum, - const char* button0Text, const char* button1Text, - const char* button2Text, int defaultButtonNumber - ) +int QtMessageBox::displayQuestionMessage (QWidget* parent, const UTF8String& title, const UTF8String& message, size_t columnNum,const char* button0Text, const char* button1Text, const char* button2Text, int defaultButtonNumber) { QApplication::setOverrideCursor (QCursor (Qt::ArrowCursor)); @@ -328,11 +291,7 @@ int QtMessageBox::displayQuestionMessage ( BEGIN_TRY_CATCH_BLOCK - QtMessageDialog dialog ( - QMessageBox::Question, parent, - UTF8TOQSTRING (title), - UTF8TOQSTRING (message), columnNum, - button0Text, button1Text, button2Text, defaultButtonNumber); + QtMessageDialog dialog (QMessageBox::Question, parent, UTF8TOQSTRING (title), UTF8TOQSTRING (message), columnNum, button0Text, button1Text, button2Text, defaultButtonNumber); button = (QMessageBox::StandardButton)dialog.exec ( ); COMPLETE_TRY_CATCH_BLOCK diff --git a/src/QtUtil/QtMultiLineToolbar.cpp b/src/QtUtil/QtMultiLineToolbar.cpp index 07c2b00..b1b4063 100644 --- a/src/QtUtil/QtMultiLineToolbar.cpp +++ b/src/QtUtil/QtMultiLineToolbar.cpp @@ -11,13 +11,8 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtPenPanel.cpp b/src/QtUtil/QtPenPanel.cpp index 61e1256..da2e3d7 100644 --- a/src/QtUtil/QtPenPanel.cpp +++ b/src/QtUtil/QtPenPanel.cpp @@ -6,15 +6,9 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include diff --git a/src/QtUtil/QtRichTextComboBox.cpp b/src/QtUtil/QtRichTextComboBox.cpp index cc2c899..d31212f 100644 --- a/src/QtUtil/QtRichTextComboBox.cpp +++ b/src/QtUtil/QtRichTextComboBox.cpp @@ -7,15 +7,9 @@ #include #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include @@ -47,10 +41,16 @@ QSize QtRichTextComboBox::sizeHint ( ) const height = height > size.height ( ) ? height : size.height ( ); } // for (int i = 0; i < count ( ); i++) +#ifdef QT_5 int left = 0, right = 0, top = 0, bottom = 0; getContentsMargins (&left, &top, &right, &bottom); width += left + right; height += top + bottom; +#else // QT_5 + const QMargins margins = contentsMargins ( ); + width += margins.left ( ) + margins.right ( ); + height += margins.top ( ) + margins.bottom ( ); +#endif // QT_5 // Pour une raison non élucidée un deltax est esthétiquement souhaitable : // width += 2 * QtConfiguration::margin; @@ -61,7 +61,9 @@ QSize QtRichTextComboBox::sizeHint ( ) const QStyleOptionComboBox opt; initStyleOption (&opt); size = cbStyle->sizeFromContents (QStyle::CT_ComboBox, &opt, size, this); +#ifdef QT_5 size = size.expandedTo (QApplication::globalStrut ( )); +#endif // QT_5 return size; } // sizeHint @@ -92,7 +94,11 @@ void QtRichTextComboBox::paintEvent (QPaintEvent*) QRectF rect (0, 0, 0, 0); rect.setSize (sizeHint ( )); int left = 0, right = 0, top = 0, bottom = 0; +#ifdef QT_5 getContentsMargins (&left, &top, &right, &bottom); +#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) : painter.translate (left + QtConfiguration::margin, 0); diff --git a/src/QtUtil/QtRotationDialog.cpp b/src/QtUtil/QtRotationDialog.cpp index 03fd4b1..bf0bc23 100644 --- a/src/QtUtil/QtRotationDialog.cpp +++ b/src/QtUtil/QtRotationDialog.cpp @@ -7,19 +7,11 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#include -#include -#else // QT_5 #include #include #include #include #include -#endif // QT_5 #include @@ -50,7 +42,11 @@ QtRotationDialog::QtRotationDialog ( // Creation de l'ihm : QVBoxLayout* layout = new QVBoxLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); // Le panneau : @@ -85,7 +81,11 @@ QtRotationDialog::QtRotationDialog ( QWidget* hbox = new QWidget (this); QHBoxLayout* hboxLayout = new QHBoxLayout ( ); hbox->setLayout (hboxLayout); +#ifdef QT_5 hboxLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + hboxLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 hboxLayout->setSpacing (QtConfiguration::spacing); layout->addWidget (hbox); QLabel* label = new QLabel ("Angle : ", hbox); diff --git a/src/QtUtil/QtScientificTextDialog.cpp b/src/QtUtil/QtScientificTextDialog.cpp index b68fa29..dfae45e 100644 --- a/src/QtUtil/QtScientificTextDialog.cpp +++ b/src/QtUtil/QtScientificTextDialog.cpp @@ -102,7 +102,11 @@ void QtScientificTextDialog::createGui (bool editable) getCentralLayout ( ).addWidget (_greekPanel); QGridLayout* gridLayout = new QGridLayout (_greekPanel); _greekPanel->setLayout (gridLayout); +#ifdef QT_5 gridLayout->setMargin (QtConfiguration::margin); +#else // => Qt6 + gridLayout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 gridLayout->setSpacing (QtConfiguration::spacing); gridLayout->setSizeConstraint (QLayout::SetFixedSize); diff --git a/src/QtUtil/QtStringHelper.cpp b/src/QtUtil/QtStringHelper.cpp index fcdac0f..61306f9 100644 --- a/src/QtUtil/QtStringHelper.cpp +++ b/src/QtUtil/QtStringHelper.cpp @@ -44,59 +44,58 @@ static const Charset charset ("àéèùô"); USE_ENCODING_AUTODETECTION -// Les positions des caractères grecs dans la table de caractères ISO 8859 -// (partie 7). Les majuscules et minuscules sont contigues. +// Les positions des caractères grecs dans la table de caractères ISO 8859 (partie 7). Les majuscules et minuscules sont contigues. static const unsigned int alphaMajPos = 913; static const unsigned int alphaMinPos = alphaMajPos + 32; -static const QChar alphaMinArray [1] = {alphaMinPos}; -static const QChar alphaMajArray [1] = {alphaMajPos}; -static const QChar betaMinArray [1] = {alphaMinPos + 1}; -static const QChar betaMajArray [1] = {alphaMajPos + 1}; -static const QChar gammaMinArray [1] = {alphaMinPos + 2}; -static const QChar gammaMajArray [1] = {alphaMajPos + 2}; -static const QChar deltaMinArray [1] = {alphaMinPos + 3}; -static const QChar deltaMajArray [1] = {alphaMajPos + 3}; -static const QChar epsilonMinArray [1] = {alphaMinPos + 4}; -static const QChar epsilonMajArray [1] = {alphaMajPos + 4}; -static const QChar dzetaMinArray [1] = {alphaMinPos + 5}; -static const QChar dzetaMajArray [1] = {alphaMajPos + 5}; -static const QChar etaMinArray [1] = {alphaMinPos + 6}; -static const QChar etaMajArray [1] = {alphaMajPos + 6}; -static const QChar thetaMinArray [1] = {alphaMinPos + 7}; -static const QChar thetaMajArray [1] = {alphaMajPos + 7}; -static const QChar iotaMinArray [1] = {alphaMinPos + 8}; -static const QChar iotaMajArray [1] = {alphaMajPos + 8}; -static const QChar kappaMinArray [1] = {alphaMinPos + 9}; -static const QChar kappaMajArray [1] = {alphaMajPos + 9}; -static const QChar lambdaMinArray [1] = {alphaMinPos + 10}; -static const QChar lambdaMajArray [1] = {alphaMajPos + 10}; -static const QChar muMinArray [1] = {alphaMinPos + 11}; -static const QChar muMajArray [1] = {alphaMajPos + 11}; -static const QChar nuMinArray [1] = {alphaMinPos + 12}; -static const QChar nuMajArray [1] = {alphaMajPos + 12}; -static const QChar xsiMinArray [1] = {alphaMinPos + 13}; -static const QChar xsiMajArray [1] = {alphaMajPos + 13}; -static const QChar omicronnMinArray [1] = {alphaMinPos + 14}; -static const QChar omicronnMajArray [1] = {alphaMajPos + 14}; -static const QChar piMinArray [1] = {alphaMinPos + 15}; -static const QChar piMajArray [1] = {alphaMajPos + 15}; -static const QChar roMinArray [1] = {alphaMinPos + 16}; -static const QChar roMajArray [1] = {alphaMajPos + 16}; -static const QChar sigmaMinArray [1] = {alphaMinPos + 18}; -static const QChar sigmaMajArray [1] = {alphaMajPos + 18}; -static const QChar tauMinArray [1] = {alphaMinPos + 19}; -static const QChar tauMajArray [1] = {alphaMajPos + 19}; -static const QChar upsilonMinArray [1] = {alphaMinPos + 20}; -static const QChar upsilonMajArray [1] = {alphaMajPos + 20}; -static const QChar phiMinArray [1] = {alphaMinPos + 21}; -static const QChar phiMajArray [1] = {alphaMajPos + 21}; -static const QChar khiMinArray [1] = {alphaMinPos + 22}; -static const QChar khiMajArray [1] = {alphaMajPos + 22}; -static const QChar psiMinArray [1] = {alphaMinPos + 23}; -static const QChar psiMajArray [1] = {alphaMajPos + 23}; -static const QChar omegaMinArray [1] = {alphaMinPos + 24}; -static const QChar omegaMajArray [1] = {alphaMajPos + 24}; +static const QChar alphaMinArray [1] = { QChar (alphaMinPos) }; +static const QChar alphaMajArray [1] = { QChar (alphaMajPos) }; +static const QChar betaMinArray [1] = { QChar (alphaMinPos + 1) }; +static const QChar betaMajArray [1] = { QChar (alphaMajPos + 1) }; +static const QChar gammaMinArray [1] = { QChar (alphaMinPos + 2) }; +static const QChar gammaMajArray [1] = { QChar (alphaMajPos + 2) }; +static const QChar deltaMinArray [1] = { QChar (alphaMinPos + 3) }; +static const QChar deltaMajArray [1] = { QChar (alphaMajPos + 3) }; +static const QChar epsilonMinArray [1] = { QChar (alphaMinPos + 4) }; +static const QChar epsilonMajArray [1] = { QChar (alphaMajPos + 4) }; +static const QChar dzetaMinArray [1] = { QChar (alphaMinPos + 5) }; +static const QChar dzetaMajArray [1] = { QChar (alphaMajPos + 5) }; +static const QChar etaMinArray [1] = { QChar (alphaMinPos + 6) }; +static const QChar etaMajArray [1] = { QChar (alphaMajPos + 6) }; +static const QChar thetaMinArray [1] = { QChar (alphaMinPos + 7) }; +static const QChar thetaMajArray [1] = { QChar (alphaMajPos + 7) }; +static const QChar iotaMinArray [1] = { QChar (alphaMinPos + 8) }; +static const QChar iotaMajArray [1] = { QChar (alphaMajPos + 8) }; +static const QChar kappaMinArray [1] = { QChar (alphaMinPos + 9) }; +static const QChar kappaMajArray [1] = { QChar (alphaMajPos + 9) }; +static const QChar lambdaMinArray [1] = { QChar (alphaMinPos + 10) }; +static const QChar lambdaMajArray [1] = { QChar (alphaMajPos + 10) }; +static const QChar muMinArray [1] = { QChar (alphaMinPos + 11) }; +static const QChar muMajArray [1] = { QChar (alphaMajPos + 11) }; +static const QChar nuMinArray [1] = { QChar (alphaMinPos + 12) }; +static const QChar nuMajArray [1] = { QChar (alphaMajPos + 12) }; +static const QChar xsiMinArray [1] = { QChar (alphaMinPos + 13) }; +static const QChar xsiMajArray [1] = { QChar (alphaMajPos + 13) }; +static const QChar omicronnMinArray [1] = { QChar (alphaMinPos + 14) }; +static const QChar omicronnMajArray [1] = { QChar (alphaMajPos + 14) }; +static const QChar piMinArray [1] = { QChar (alphaMinPos + 15) }; +static const QChar piMajArray [1] = { QChar (alphaMajPos + 15) }; +static const QChar roMinArray [1] = { QChar (alphaMinPos + 16) }; +static const QChar roMajArray [1] = { QChar (alphaMajPos + 16) }; +static const QChar sigmaMinArray [1] = { QChar (alphaMinPos + 18) }; +static const QChar sigmaMajArray [1] = { QChar (alphaMajPos + 18) }; +static const QChar tauMinArray [1] = { QChar (alphaMinPos + 19) }; +static const QChar tauMajArray [1] = { QChar (alphaMajPos + 19) }; +static const QChar upsilonMinArray [1] = { QChar (alphaMinPos + 20) }; +static const QChar upsilonMajArray [1] = { QChar (alphaMajPos + 20) }; +static const QChar phiMinArray [1] = { QChar (alphaMinPos + 21) }; +static const QChar phiMajArray [1] = { QChar (alphaMajPos + 21) }; +static const QChar khiMinArray [1] = { QChar (alphaMinPos + 22) }; +static const QChar khiMajArray [1] = { QChar (alphaMajPos + 22) }; +static const QChar psiMinArray [1] = { QChar (alphaMinPos + 23) }; +static const QChar psiMajArray [1] = { QChar (alphaMajPos + 23) }; +static const QChar omegaMinArray [1] = { QChar (alphaMinPos + 24) }; +static const QChar omegaMajArray [1] = { QChar (alphaMajPos + 24) }; QString QtStringHelper::_alphaMin (alphaMinArray, 1); QString QtStringHelper::_alphaMaj (alphaMajArray, 1); diff --git a/src/QtUtil/QtStringListSelectionPanel.cpp b/src/QtUtil/QtStringListSelectionPanel.cpp index dd73869..f1933b7 100644 --- a/src/QtUtil/QtStringListSelectionPanel.cpp +++ b/src/QtUtil/QtStringListSelectionPanel.cpp @@ -2,19 +2,11 @@ #include "QtUtil/QtConfiguration.h" #include "QtUtil/QtUnicodeHelper.h" -#ifndef QT_5 -#include -#include -#include -#include -#include -#else // QT_5 #include #include #include #include #include -#endif // QT_5 #include #include diff --git a/src/QtUtil/QtStringPanel.cpp b/src/QtUtil/QtStringPanel.cpp index 5b1d66e..b825e52 100644 --- a/src/QtUtil/QtStringPanel.cpp +++ b/src/QtUtil/QtStringPanel.cpp @@ -6,13 +6,9 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 + USING_STD USING_UTIL diff --git a/src/QtUtil/QtTextDialog.cpp b/src/QtUtil/QtTextDialog.cpp index 2e92c7a..6aec68c 100644 --- a/src/QtUtil/QtTextDialog.cpp +++ b/src/QtUtil/QtTextDialog.cpp @@ -3,11 +3,7 @@ #include "QtUtil/QtUnicodeHelper.h" #include "QtUtil/QtGroupBox.h" -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include @@ -17,20 +13,14 @@ USING_STD USING_UTIL -QtTextDialog::QtTextDialog ( - QWidget* parent, const UTF8String& title, - const UTF8String& text, bool editable) - : QDialog (parent, QtConfiguration::modalDialogWFlags), - _centralLayout (0), _textWindow (0), _closurePanel (0), _modified (false) +QtTextDialog::QtTextDialog (QWidget* parent, const UTF8String& title, const UTF8String& text, bool editable) + : QDialog (parent, QtConfiguration::modalDialogWFlags), _centralLayout (0), _textWindow (0), _closurePanel (0), _modified (false) { createGui (title, text, editable); } // QtTextDialog::QtTextDialog -QtTextDialog::QtTextDialog ( - QWidget* parent, const UTF8String& title, const UTF8String& text, - bool editable, const QFont& font, const QColor& foreground, - const QColor& background) +QtTextDialog::QtTextDialog (QWidget* parent, const UTF8String& title, const UTF8String& text, bool editable, const QFont& font, const QColor& foreground, const QColor& background) { createGui (title, "", editable); assert (0 != _textWindow); @@ -143,44 +133,41 @@ QTextEdit& QtTextDialog::getTextEditor ( ) } // QtTextDialog::getTextEditor -void QtTextDialog::createGui ( - const UTF8String & title, const UTF8String & text, bool editable) +void QtTextDialog::createGui (const UTF8String & title, const UTF8String & text, bool editable) { setModal (true); setWindowTitle (UTF8TOQSTRING (title)); // Creation de l'ihm : QVBoxLayout* layout = new QVBoxLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); _centralLayout = new QVBoxLayout ( ); _centralLayout->setSizeConstraint (QLayout::SetMinimumSize); layout->addLayout (_centralLayout); _textWindow = new QTextEdit (this); _textWindow->setText (UTF8TOQSTRING (text)); - connect (_textWindow, SIGNAL(textChanged ( )), this, - SLOT (textModified ( ))); + connect (_textWindow, SIGNAL(textChanged ( )), this, SLOT (textModified ( ))); _centralLayout->addWidget (_textWindow); _textWindow->setMinimumSize (_textWindow->sizeHint ( )); layout->addWidget (new QLabel (" ", this)); - _closurePanel = - new QtDlgClosurePanel (this, false, "Appliquer", "", "Fermer", "", ""); + _closurePanel = new QtDlgClosurePanel (this, false, "Appliquer", "", "Fermer", "", ""); layout->addWidget (_closurePanel); _closurePanel->setMinimumSize (_closurePanel->sizeHint ( )); - // 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->getApplyButton ( )->setEnabled (false); _closurePanel->getCancelButton ( )->setAutoDefault (false); _closurePanel->getCancelButton ( )->setDefault (false); - connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, - SLOT(apply ( ))); - connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, - SLOT(reject ( ))); + connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT(apply ( ))); + connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, SLOT(reject ( ))); layout->activate ( ); setMinimumSize (layout->sizeHint ( )); diff --git a/src/QtUtil/QtTextEditor.cpp b/src/QtUtil/QtTextEditor.cpp index 3cc187d..f1340aa 100644 --- a/src/QtUtil/QtTextEditor.cpp +++ b/src/QtUtil/QtTextEditor.cpp @@ -6,13 +6,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 #include #include @@ -37,16 +32,14 @@ QtTextEditor::QtLineNumberArea::QtLineNumberArea (QtTextEditor& editor) } // QtLineNumberArea::QtLineNumberArea -QtTextEditor::QtLineNumberArea::QtLineNumberArea ( - const QtTextEditor::QtLineNumberArea&) +QtTextEditor::QtLineNumberArea::QtLineNumberArea (const QtTextEditor::QtLineNumberArea&) : QWidget (0) { assert (0 && "QtLineNumberArea copy constructor is not allowed."); } // QtLineNumberArea::QtLineNumberArea -QtTextEditor::QtLineNumberArea& QtTextEditor::QtLineNumberArea::operator = ( - const QtTextEditor::QtLineNumberArea&) +QtTextEditor::QtLineNumberArea& QtTextEditor::QtLineNumberArea::operator = (const QtTextEditor::QtLineNumberArea&) { assert (0 && "QtLineNumberArea assignment operator = is not allowed."); return *this; @@ -99,17 +92,13 @@ void QtTextEditor::QtLineNumberArea::paintEvent (QPaintEvent* event) // ============================================================================= QtTextEditor::QtTextEditor (QWidget* parent, bool displayLinesNumbers) - : QPlainTextEdit (parent), - _lineNumberArea (0), _displayLinesNumbers (displayLinesNumbers) + : QPlainTextEdit (parent), _lineNumberArea (0), _displayLinesNumbers (displayLinesNumbers) { _lineNumberArea = new QtTextEditor::QtLineNumberArea (*this); - connect (this, SIGNAL (blockCountChanged (int)), this, - SLOT (updateLineNumberAreaWidthCallback (int))); - connect (this, SIGNAL (updateRequest (QRect, int)), this, - SLOT (updateLineNumberAreaWidthCallback (QRect, int))); - connect (this, SIGNAL (cursorPositionChanged ( )), this, - SLOT (cursorPositionCallback ( ))); + connect (this, SIGNAL (blockCountChanged (int)), this, SLOT (updateLineNumberAreaWidthCallback (int))); + connect (this, SIGNAL (updateRequest (QRect, int)), this, SLOT (updateLineNumberAreaWidthCallback (QRect, int))); + connect (this, SIGNAL (cursorPositionChanged ( )), this, SLOT (cursorPositionCallback ( ))); updateLineNumberAreaWidthCallback (0); cursorPositionCallback ( ); @@ -165,7 +154,11 @@ int QtTextEditor::lineNumberAreaWidth ( ) const digits += 1; } // while (max >= 10) +#ifdef QT_5 const int space = 3 + digits * fontMetrics ( ).width (QLatin1Char ('9')); +#else // QT_5 + const int space = 3 + digits * fontMetrics ( ).horizontalAdvance (QLatin1Char ('9')); +#endif // QT_5 return space; } // QtTextEditor::lineNumberAreaWidth @@ -185,8 +178,7 @@ void QtTextEditor::drawLinesNumbers (const QRect& rect) // On affiche les numéros de lignes correspondant au scroller : QTextBlock block = firstVisibleBlock ( ); int number = block.blockNumber ( ); - int top = - blockBoundingGeometry (block).translated (contentOffset ( )).top( ); + int top = blockBoundingGeometry (block).translated (contentOffset ( )).top( ); int bottom = top + blockBoundingRect (block).height ( ); while ((block.isValid ( )) && (top <= rect.bottom ( ))) @@ -195,8 +187,7 @@ void QtTextEditor::drawLinesNumbers (const QRect& rect) { const QString str = QString::number (number + 1); painter.setPen (Qt::black); - painter.drawText (0, top, getLineNumberArea ( ).width ( ), - fontMetrics ( ).height ( ), Qt::AlignRight, str); + painter.drawText (0, top, getLineNumberArea ( ).width ( ), fontMetrics ( ).height ( ), Qt::AlignRight, str); } // if ((true == block.isVisible ( )) && (bottom >= ... block = block.next ( ); @@ -208,8 +199,7 @@ void QtTextEditor::drawLinesNumbers (const QRect& rect) catch (const Exception& exc) { UTF8String message (charset); - message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " - << exc.getFullMessage ( ); + message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " << exc.getFullMessage ( ); ConsoleOutput::cerr ( ) << message << co_endl; } catch (...) @@ -241,14 +231,12 @@ void QtTextEditor::resizeEvent (QResizeEvent* event) QPlainTextEdit::resizeEvent (event); const QRect rect = contentsRect ( ); - getLineNumberArea ( ).setGeometry (QRect ( - rect.left( ), rect.top( ), lineNumberAreaWidth( ), rect.height( ))); + getLineNumberArea ( ).setGeometry (QRect (rect.left( ), rect.top( ), lineNumberAreaWidth( ), rect.height( ))); } catch (const Exception& exc) { UTF8String message (charset); - message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " - << exc.getFullMessage ( ); + message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " << exc.getFullMessage ( ); ConsoleOutput::cerr ( ) << message << co_endl; } catch (...) @@ -264,8 +252,7 @@ const QtTextEditor::QtLineNumberArea& QtTextEditor::getLineNumberArea ( ) const { if (0 == _lineNumberArea) { - INTERNAL_ERROR (exc, "Zone d'affichage des numéros de ligne nulle.", - "QtTextEditor::getLineNumberArea") + INTERNAL_ERROR (exc, "Zone d'affichage des numéros de ligne nulle.", "QtTextEditor::getLineNumberArea") throw exc; } // if (0 == _lineNumberArea) @@ -277,8 +264,7 @@ QtTextEditor::QtLineNumberArea& QtTextEditor::getLineNumberArea ( ) { if (0 == _lineNumberArea) { - INTERNAL_ERROR (exc, "Zone d'affichage des numéros de ligne nulle.", - "QtTextEditor::getLineNumberArea") + INTERNAL_ERROR (exc, "Zone d'affichage des numéros de ligne nulle.", "QtTextEditor::getLineNumberArea") throw exc; } // if (0 == _lineNumberArea) @@ -294,13 +280,10 @@ QMenu* QtTextEditor::createPopupMenu ( ) { CHECK_NULL_PTR_ERROR (menu) menu->addSeparator ( ); - QAction* linesAction = - new QAction (QSTR ("Afficher les numéros de ligne"), this); + QAction* linesAction = new QAction (QSTR ("Afficher les numéros de ligne"), this); linesAction->setCheckable (true); - linesAction->setChecked ( - true == displayLinesNumbers ( ) ? Qt::Checked : Qt::Unchecked); - connect (linesAction, SIGNAL (toggled (bool)), this, - SLOT (displayLinesNumbersCallback ( ))); + linesAction->setChecked (true == displayLinesNumbers ( ) ? Qt::Checked : Qt::Unchecked); + connect (linesAction, SIGNAL (toggled (bool)), this, SLOT (displayLinesNumbersCallback ( ))); menu->addAction (linesAction); } catch (...) @@ -320,8 +303,7 @@ void QtTextEditor::updateLineNumberAreaWidthCallback (int /* blockCount*/) catch (const Exception& exc) { UTF8String message (charset); - message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " - << exc.getFullMessage ( ); + message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " << exc.getFullMessage ( ); ConsoleOutput::cerr ( ) << message << co_endl; } catch (...) @@ -342,8 +324,7 @@ void QtTextEditor::updateLineNumberAreaWidthCallback (const QRect& rect, int dy) if (0 != dy) getLineNumberArea ( ).scroll (0, dy); else - getLineNumberArea ( ).update ( - 0, rect.y ( ), getLineNumberArea( ).width ( ), rect.height ( )); + getLineNumberArea ( ).update (0, rect.y ( ), getLineNumberArea( ).width ( ), rect.height ( )); if (true == rect.contains (viewport ( )->rect ( ))) updateLineNumberAreaWidthCallback (0); @@ -351,8 +332,7 @@ void QtTextEditor::updateLineNumberAreaWidthCallback (const QRect& rect, int dy) catch (const Exception& exc) { UTF8String message (charset); - message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " - << exc.getFullMessage ( ); + message << __FILE__ << ' ' << (unsigned long)__LINE__ << " Exception levée : " << exc.getFullMessage ( ); ConsoleOutput::cerr ( ) << message << co_endl; } catch (...) diff --git a/src/QtUtil/QtTextField.cpp b/src/QtUtil/QtTextField.cpp index 68bd259..c856de0 100644 --- a/src/QtUtil/QtTextField.cpp +++ b/src/QtUtil/QtTextField.cpp @@ -1,11 +1,10 @@ #include "QtUtil/QtTextField.h" -#ifndef QT_5 -#include -#include -#else // QT_5 #include -#include +#ifdef QT_5 +# include +#else // QT_5 +# include #endif // QT_5 #include @@ -21,8 +20,7 @@ QtTextField::QtTextField (QWidget* parent, const char* name) } // QtTextField::QtTextField -QtTextField::QtTextField (const QString& contents, QWidget* parent, - const char* name) +QtTextField::QtTextField (const QString& contents, QWidget* parent, const char* name) : QLineEdit (contents, parent) { } // QtTextField::QtTextField @@ -81,23 +79,32 @@ void QtTextField::setVisibleColumns (int count) QSize QtTextField::sizeHint ( ) const -{ // L'algo par défaut (cf. QLineEdit::sizeHint de Qt 4.7.4) semble - // pré-programmé pour un champ de 17 caractères visibles. - // QLineEdit::minimumSizeHint retourne la dimension pour un caractère, - // dimension qui contient également les marges. +{ // L'algo par défaut (cf. QLineEdit::sizeHint de Qt 4.7.4) semble pré-programmé pour un champ de 17 caractères visibles. + // QLineEdit::minimumSizeHint retourne la dimension pour un caractère, dimension qui contient également les marges. const int length = maxLength ( ); if (32767 == length) return QLineEdit::sizeHint ( ); int ltm = 0, rtm = 0, ttm = 0, btm = 0; int lcm = 0, rcm = 0, tcm = 0, bcm = 0; +#ifdef QT_5 getTextMargins (<m, &ttm, &rtm, &btm); getContentsMargins (&lcm, &tcm, &rcm, &bcm); +#else // QT_5 + const QMargins tmargins = textMargins ( ); + const QMargins margins = contentsMargins ( ); + ltm = tmargins.left ( ); ttm = tmargins.top ( ); rtm = tmargins.right ( ); btm = tmargins.bottom ( ); + lcm = margins.left ( ); tcm = margins.top ( ); rcm = margins.right ( ); bcm = margins.bottom ( ); +#endif // QT_5 // Code issu des sources de QLineEdit::minimumSizeHint de Qt 4.7.4 : QFontMetrics fm = fontMetrics ( ); // const int charWidth = true == isNumeric ( ) ? fm.width ('0') : fm.maxWidth ( ); // v 5.2.1 +#ifdef QT_5 const int charWidth = true == isNumeric ( ) ? fm.width ('0') : fm.averageCharWidth ( ); // v 5.2.1 (largeur moyenne = 9, largeur max = 53 ...) +#else // QT_5 + const int charWidth = true == isNumeric ( ) ? fm.horizontalAdvance ('0') : fm.averageCharWidth ( ); +#endif // QT_5 int h = fm.height ( ) + qMax (ttm + btm, fm.leading ( )) + tcm + bcm; int w = length * charWidth + lcm + rcm; if (true == isNumeric ( )) @@ -108,9 +115,17 @@ QSize QtTextField::sizeHint ( ) const QSize currentSize = fm.boundingRect (currentText).size ( ); w = w > currentSize.width ( ) ? w : currentSize.width ( ); // v 5.2.1 +#ifdef QT_5 QStyleOptionFrameV2 opt; +#else // QT_5 + QStyleOptionFrame opt; +#endif // QT_5 initStyleOption (&opt); +#ifdef QT_5 return style ( )->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h).expandedTo (QApplication::globalStrut ( )), this); +#else // QT_5 + return style ( )->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h)); +#endif // QT_5 } // QtTextField::sizeHint diff --git a/src/QtUtil/QtValidatedTextField.cpp b/src/QtUtil/QtValidatedTextField.cpp index 4b5b3f6..5061ed0 100644 --- a/src/QtUtil/QtValidatedTextField.cpp +++ b/src/QtUtil/QtValidatedTextField.cpp @@ -6,11 +6,7 @@ #include #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include @@ -29,8 +25,7 @@ QColor QtValidatedTextField::errorBackground = Qt::white; QColor QtValidatedTextField::errorForeground = Qt::red; -QtValidatedTextField::QtValidatedTextField ( - QWidget* parent, bool autoValidation, const char* name) +QtValidatedTextField::QtValidatedTextField (QWidget* parent, bool autoValidation, const char* name) : QtTextField (parent, name), _autoValidation (autoValidation) { } // QtValidatedTextField::QtValidatedTextField @@ -43,8 +38,7 @@ QtValidatedTextField::QtValidatedTextField (const QtValidatedTextField&) } // QtValidatedTextField::QtValidatedTextField (const QtValidatedTextField&) -QtValidatedTextField& QtValidatedTextField::operator = ( - const QtValidatedTextField&) +QtValidatedTextField& QtValidatedTextField::operator = (const QtValidatedTextField&) { assert (0 && "QtValidatedTextField::operator = is not allowed."); return *this; @@ -65,9 +59,21 @@ void QtValidatedTextField::focusInEvent (QFocusEvent* event) void QtValidatedTextField::focusOutEvent (QFocusEvent* event) { +#ifndef QT_5 // Qt 6.6.1 : non réentrant => MessageBox qui n'a de cesse de s'afficher si saisie en erreur :( + static bool validating = false; + if (false == validating) + { + validating = true; +#endif // QT_5 + QtTextField::focusOutEvent (event); if ((true == automaticValidation) || (true == doAutoValidation ( ))) validate ( ); + +#ifndef QT_5 + validating = false; +} // if (false == validating) +#endif // QT_5 } // QtValidatedTextField::focusOutEvent @@ -101,24 +107,25 @@ bool QtValidatedTextField::validate ( ) { UTF8String errorMsg (charset); errorMsg << "Valeur " << tValue.toStdString ( ) << " incorrecte.\n"; - const QDoubleValidator* dv = - dynamic_cast(v); - const QIntValidator* iv = - dynamic_cast(v); - const QRegExpValidator* rev = - dynamic_cast(v); + const QDoubleValidator* dv = dynamic_cast(v); + const QIntValidator* iv = dynamic_cast(v); +#ifdef QT_5 + const QRegExpValidator* rev = dynamic_cast(v); +#else + const QRegularExpressionValidator* rev = dynamic_cast(v); +#endif // QT_5 if (0 != dv) - errorMsg << "La valeur doit être comprise entre " - << ios_base::fixed << IN_UTIL setprecision (2) - << dv->bottom ( ) << " et " << dv->top ( ) << "."; + errorMsg << "La valeur doit être comprise entre " << ios_base::fixed << IN_UTIL setprecision (2) << dv->bottom ( ) << " et " << dv->top ( ) << "."; else if (0 != iv) - errorMsg << "La valeur doit être comprise entre " - << ios_base::fixed << IN_UTIL setprecision (2) - << (long)iv->bottom ( ) << " et " - << (long)iv->top ( ) << "."; + errorMsg << "La valeur doit être comprise entre " << ios_base::fixed << IN_UTIL setprecision (2) << (long)iv->bottom ( ) << " et " << (long)iv->top ( ) << "."; else if (0 != rev) - errorMsg << "La valeur doit être du type " - << rev->regExp ( ).pattern ( ).toStdString ( ) << "."; + { +#ifdef QT_5 + errorMsg << "La valeur doit être du type " << rev->regExp ( ).pattern ( ).toStdString ( ) << "."; +#else + errorMsg << "La valeur doit être du type " << rev->regularExpression ( ).pattern ( ).toStdString ( ) << "."; +#endif // QT_5 + } throw Exception (errorMsg); } // if (QValidator::Acceptable != v->validate (tValue, pos)) setSkin (true); @@ -127,16 +134,14 @@ bool QtValidatedTextField::validate ( ) { setSkin (false); if (true == dialogOnError) - QtMessageBox::displayErrorMessage ( - this, "Saisie invalide", exc.getFullMessage ( )); + QtMessageBox::displayErrorMessage (this, "Saisie invalide", exc.getFullMessage ( )); return false; } catch (...) { setSkin (false); if (true == dialogOnError) - QtMessageBox::displayErrorMessage ( - this, "Saisie invalide", "Erreur non documentée."); + QtMessageBox::displayErrorMessage (this, "Saisie invalide", "Erreur non documentée."); return false; } @@ -157,10 +162,8 @@ void QtValidatedTextField::setSkin (bool normal) first = false; } // if (true == first) - p.setColor (QPalette::Active, - QPalette::Base, true == normal ? defaultBackground : errorBackground); - p.setColor (QPalette::Active, - QPalette::Text, true == normal ? defaultForeground : errorForeground); + p.setColor (QPalette::Active, QPalette::Base, true == normal ? defaultBackground : errorBackground); + p.setColor (QPalette::Active, QPalette::Text, true == normal ? defaultForeground : errorForeground); setPalette (p); } // QtValidatedTextField::setSkin diff --git a/src/QtUtil/QtWebBrowser.cpp b/src/QtUtil/QtWebBrowser.cpp index 01db625..5511eec 100644 --- a/src/QtUtil/QtWebBrowser.cpp +++ b/src/QtUtil/QtWebBrowser.cpp @@ -13,28 +13,15 @@ #include #include #include -#ifndef QT_5 -#include -#include -#include -#include -#include -#include -#else // QT_5 #include #include #include #include #include #include -#endif // QT_5 #ifdef USE_QT_WEBKIT #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include #include #include diff --git a/src/QtUtil/QtWidgetAction.cpp b/src/QtUtil/QtWidgetAction.cpp index 197ed0a..bc1bfed 100644 --- a/src/QtUtil/QtWidgetAction.cpp +++ b/src/QtUtil/QtWidgetAction.cpp @@ -6,11 +6,7 @@ #include "QtUtil/QtWidgetAction.h" -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include diff --git a/src/QtUtil/cmake/QtUtilConfig.cmake.in b/src/QtUtil/cmake/QtUtilConfig.cmake.in index 69d20a7..ad08fd5 100644 --- a/src/QtUtil/cmake/QtUtilConfig.cmake.in +++ b/src/QtUtil/cmake/QtUtilConfig.cmake.in @@ -1,15 +1,15 @@ include(CMakeFindDependencyMacro) find_dependency (TkUtil) -find_dependency (Qt5Widgets) -find_dependency (Qt5PrintSupport) +find_dependency (Qt@QT_MAJOR@Widgets) +find_dependency (Qt@QT_MAJOR@PrintSupport) set (QtWebEngine_FOUND "@QtWebEngine_ENABLED@") if (QtWebEngine_FOUND) - find_dependency (Qt5WebView) - find_dependency (Qt5WebEngineWidgets) + find_dependency (Qt@QT_MAJOR@WebView) + find_dependency (Qt@QT_MAJOR@WebEngineWidgets) endif (QtWebEngine_FOUND) set (QtWebKit_FOUND "@QtWebKit_ENABLED@") if (QtWebKit_FOUND) - find_dependency (Qt5WebKitWidgets) + find_dependency (Qt@QT_MAJOR@WebKitWidgets) endif (QtWebKit_FOUND) @PACKAGE_INIT@ diff --git a/src/QtUtil/public/QtUtil/QtAboutDialog.h b/src/QtUtil/public/QtUtil/QtAboutDialog.h index 28dce99..0e66b10 100644 --- a/src/QtUtil/public/QtUtil/QtAboutDialog.h +++ b/src/QtUtil/public/QtUtil/QtAboutDialog.h @@ -1,13 +1,10 @@ #ifndef QT_ABOUT_DIALOG_H #define QT_ABOUT_DIALOG_H -#ifndef QT_5 -#include -#include -#else // QT_5 + #include #include -#endif // QT_5 + #include diff --git a/src/QtUtil/public/QtUtil/QtActionAutoLock.h b/src/QtUtil/public/QtUtil/QtActionAutoLock.h index 0def9f5..5ddfc5a 100644 --- a/src/QtUtil/public/QtUtil/QtActionAutoLock.h +++ b/src/QtUtil/public/QtUtil/QtActionAutoLock.h @@ -1,11 +1,7 @@ #ifndef QT_ACTION_AUTO_LOCK_H #define QT_ACTION_AUTO_LOCK_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 /** Classe permettant de verrouiller l'emission de signaux d'une action. diff --git a/src/QtUtil/public/QtUtil/QtAutoWaitingCursor.h b/src/QtUtil/public/QtUtil/QtAutoWaitingCursor.h index eff7673..2c56d36 100644 --- a/src/QtUtil/public/QtUtil/QtAutoWaitingCursor.h +++ b/src/QtUtil/public/QtUtil/QtAutoWaitingCursor.h @@ -1,11 +1,7 @@ #ifndef QT_AUTO_WAITING_CURSOR_H #define QT_AUTO_WAITING_CURSOR_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include diff --git a/src/QtUtil/public/QtUtil/QtCoordinatesDialog.h b/src/QtUtil/public/QtUtil/QtCoordinatesDialog.h index fcce8f5..f5611fd 100644 --- a/src/QtUtil/public/QtUtil/QtCoordinatesDialog.h +++ b/src/QtUtil/public/QtUtil/QtCoordinatesDialog.h @@ -6,13 +6,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 /** Classe de boite de dialogue modale de saisie de coordonnées 3D. diff --git a/src/QtUtil/public/QtUtil/QtCoordinatesTextField.h b/src/QtUtil/public/QtUtil/QtCoordinatesTextField.h index c3f9f41..15eb515 100644 --- a/src/QtUtil/public/QtUtil/QtCoordinatesTextField.h +++ b/src/QtUtil/public/QtUtil/QtCoordinatesTextField.h @@ -25,9 +25,7 @@ class QtCoordinatesTextField : public QtValidatedTextField * utilisée lors de l'affichage des coordonnées initiales, un * objectif étant de faire la ligne la plus courte possible). */ - QtCoordinatesTextField ( - QWidget* parent, double x, double y, double z, - unsigned short precision = 9); + QtCoordinatesTextField (QWidget* parent, double x, double y, double z, unsigned short precision = 9); /** * Destructeur. RAS. diff --git a/src/QtUtil/public/QtUtil/QtDlgClosurePanel.h b/src/QtUtil/public/QtUtil/QtDlgClosurePanel.h index 9465abf..e48b3d6 100644 --- a/src/QtUtil/public/QtUtil/QtDlgClosurePanel.h +++ b/src/QtUtil/public/QtUtil/QtDlgClosurePanel.h @@ -3,13 +3,8 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 #include diff --git a/src/QtUtil/public/QtUtil/QtExclusiveActionGroup.h b/src/QtUtil/public/QtUtil/QtExclusiveActionGroup.h index 86d5908..cc5a7f7 100644 --- a/src/QtUtil/public/QtUtil/QtExclusiveActionGroup.h +++ b/src/QtUtil/public/QtUtil/QtExclusiveActionGroup.h @@ -4,12 +4,7 @@ #ifndef QT_EXCLUSIVE_ACTION_GROUP_H #define QT_EXCLUSIVE_ACTION_GROUP_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 - /** diff --git a/src/QtUtil/public/QtUtil/QtExtMessageBox.h b/src/QtUtil/public/QtUtil/QtExtMessageBox.h index c4a843f..3506a4b 100644 --- a/src/QtUtil/public/QtUtil/QtExtMessageBox.h +++ b/src/QtUtil/public/QtUtil/QtExtMessageBox.h @@ -1,17 +1,11 @@ #ifndef QT_EXT_MESSAGE_BOX_H #define QT_EXT_MESSAGE_BOX_H -#ifndef QT_5 -#include -#include -#include -#include -#else // QT_5 #include #include #include #include -#endif // QT_5 + #include diff --git a/src/QtUtil/public/QtUtil/QtExternalLinkDialog.h b/src/QtUtil/public/QtUtil/QtExternalLinkDialog.h index 4fbfa69..5d346d0 100644 --- a/src/QtUtil/public/QtUtil/QtExternalLinkDialog.h +++ b/src/QtUtil/public/QtUtil/QtExternalLinkDialog.h @@ -8,11 +8,7 @@ #ifndef QT_EXTERNAL_LINK_DIALOG_H #define QT_EXTERNAL_LINK_DIALOG_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 #include diff --git a/src/QtUtil/public/QtUtil/QtFlowLayout.h b/src/QtUtil/public/QtUtil/QtFlowLayout.h index f715725..ecca6a4 100644 --- a/src/QtUtil/public/QtUtil/QtFlowLayout.h +++ b/src/QtUtil/public/QtUtil/QtFlowLayout.h @@ -49,15 +49,9 @@ #define QT_FLOWLAYOUT_H #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 //! [0] class QtFlowLayout : public QLayout diff --git a/src/QtUtil/public/QtUtil/QtFontPanel.h b/src/QtUtil/public/QtUtil/QtFontPanel.h index 44a34d1..c359298 100644 --- a/src/QtUtil/public/QtUtil/QtFontPanel.h +++ b/src/QtUtil/public/QtUtil/QtFontPanel.h @@ -5,17 +5,10 @@ #include "QtUtil/QtIntTextField.h" -#ifndef QT_5 -#include -#include -#include -#include -#else // QT_5 #include #include #include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtGroupBox.h b/src/QtUtil/public/QtUtil/QtGroupBox.h index 038f238..0ff025f 100644 --- a/src/QtUtil/public/QtUtil/QtGroupBox.h +++ b/src/QtUtil/public/QtUtil/QtGroupBox.h @@ -1,15 +1,9 @@ #ifndef QT_GROUP_BOX_H #define QT_GROUP_BOX_H -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 diff --git a/src/QtUtil/public/QtUtil/QtLogsView.h b/src/QtUtil/public/QtUtil/QtLogsView.h index 625c4cd..af12b7d 100644 --- a/src/QtUtil/public/QtUtil/QtLogsView.h +++ b/src/QtUtil/public/QtUtil/QtLogsView.h @@ -5,14 +5,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 - /** diff --git a/src/QtUtil/public/QtUtil/QtMatrixDialog.h b/src/QtUtil/public/QtUtil/QtMatrixDialog.h index c62483b..b741392 100644 --- a/src/QtUtil/public/QtUtil/QtMatrixDialog.h +++ b/src/QtUtil/public/QtUtil/QtMatrixDialog.h @@ -5,13 +5,9 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 + #include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtMessageBox.h b/src/QtUtil/public/QtUtil/QtMessageBox.h index 7530817..f1888d5 100644 --- a/src/QtUtil/public/QtUtil/QtMessageBox.h +++ b/src/QtUtil/public/QtUtil/QtMessageBox.h @@ -5,13 +5,8 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 @@ -171,15 +166,8 @@ class QtMessageBox }; // class QtMessageBox - -#ifndef QT_5 -#include -#include -#else // QT_5 -#include -#include -#endif // QT_5 - +#include +#include class QtMessageDialog : public QDialog { diff --git a/src/QtUtil/public/QtUtil/QtMinMaxDialog_impl.h b/src/QtUtil/public/QtUtil/QtMinMaxDialog_impl.h index 5050f26..64fb927 100644 --- a/src/QtUtil/public/QtUtil/QtMinMaxDialog_impl.h +++ b/src/QtUtil/public/QtUtil/QtMinMaxDialog_impl.h @@ -1,16 +1,9 @@ #include #include - -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include #include @@ -30,7 +23,11 @@ template QtMinMaxDialog::QtMinMaxDialog ( setWindowTitle (QString (title.c_str ( ))); QGridLayout* layout = new QGridLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); int row = 0, col = 0; @@ -56,14 +53,11 @@ template QtMinMaxDialog::QtMinMaxDialog ( row++; col = 0; // La fermeture : - _closurePanel = new QtDlgClosurePanel ( - this, false, "OK", "", "Annuler", helpURL, helpTag); + _closurePanel = new QtDlgClosurePanel (this, false, "OK", "", "Annuler", helpURL, helpTag); layout->addWidget (_closurePanel, row, col, 1, 2); _closurePanel->setMinimumSize (_closurePanel->sizeHint ( )); - connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, - SLOT(accept ( ))); - connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, - SLOT(reject ( ))); + connect (_closurePanel->getApplyButton ( ), SIGNAL(clicked ( )), this, SLOT(accept ( ))); + connect (_closurePanel->getCancelButton ( ), SIGNAL(clicked ( )), this, SLOT(reject ( ))); _closurePanel->getApplyButton ( )->setAutoDefault (false); _closurePanel->getApplyButton ( )->setDefault (false); @@ -75,8 +69,7 @@ template QtMinMaxDialog::QtMinMaxDialog ( } // QtMinMaxDialog::QtMinMaxDialog -template QtMinMaxDialog::QtMinMaxDialog ( - const QtMinMaxDialog& view) +template QtMinMaxDialog::QtMinMaxDialog (const QtMinMaxDialog& view) : QDialog (0), _minTextField (0), _maxTextField (0), _closurePanel (0), _appTitle ( ) { @@ -97,16 +90,14 @@ template QtMinMaxDialog::~QtMinMaxDialog ( ) } // QtMinMaxDialog::~QtMinMaxDialog -template void QtMinMaxDialog ::setMinRange ( - T min, T max) +template void QtMinMaxDialog ::setMinRange (T min, T max) { assert (0 != _minTextField); _minTextField->setRange (min, max); } // QtMinMaxDialog::setMinRange -template void QtMinMaxDialog ::setMaxRange ( - T min, T max) +template void QtMinMaxDialog ::setMaxRange (T min, T max) { assert (0 != _maxTextField); _maxTextField->setRange (min, max); diff --git a/src/QtUtil/public/QtUtil/QtMultiLineToolbar.h b/src/QtUtil/public/QtUtil/QtMultiLineToolbar.h index 8f3ab3a..8a6a23e 100644 --- a/src/QtUtil/public/QtUtil/QtMultiLineToolbar.h +++ b/src/QtUtil/public/QtUtil/QtMultiLineToolbar.h @@ -8,11 +8,8 @@ #ifndef QT_MULTILINE_TOOLBAR_H #define QT_MULTILINE_TOOLBAR_H -#ifndef QT_5 -#include -#else // QT_5 +#include #include -#endif // QT_5 diff --git a/src/QtUtil/public/QtUtil/QtPenPanel.h b/src/QtUtil/public/QtUtil/QtPenPanel.h index 7a7b7d0..5dcbeeb 100644 --- a/src/QtUtil/public/QtUtil/QtPenPanel.h +++ b/src/QtUtil/public/QtUtil/QtPenPanel.h @@ -5,15 +5,9 @@ #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtRichTextComboBox.h b/src/QtUtil/public/QtUtil/QtRichTextComboBox.h index 18e376b..1616873 100644 --- a/src/QtUtil/public/QtUtil/QtRichTextComboBox.h +++ b/src/QtUtil/public/QtUtil/QtRichTextComboBox.h @@ -1,13 +1,8 @@ #ifndef QT_RICH_TEXT_COMBO_BOX_H #define QT_RICH_TEXT_COMBO_BOX_H -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtRotationDialog.h b/src/QtUtil/public/QtUtil/QtRotationDialog.h index 365d278..53e8e97 100644 --- a/src/QtUtil/public/QtUtil/QtRotationDialog.h +++ b/src/QtUtil/public/QtUtil/QtRotationDialog.h @@ -6,13 +6,8 @@ #include #include -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtScientificTextDialog.h b/src/QtUtil/public/QtUtil/QtScientificTextDialog.h index 1ec9191..212c9ae 100644 --- a/src/QtUtil/public/QtUtil/QtScientificTextDialog.h +++ b/src/QtUtil/public/QtUtil/QtScientificTextDialog.h @@ -7,11 +7,7 @@ #include #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 class QtGreekPushButton; diff --git a/src/QtUtil/public/QtUtil/QtStatusLogOutputStream.h b/src/QtUtil/public/QtUtil/QtStatusLogOutputStream.h index cb3af89..ceb22dc 100644 --- a/src/QtUtil/public/QtUtil/QtStatusLogOutputStream.h +++ b/src/QtUtil/public/QtUtil/QtStatusLogOutputStream.h @@ -4,11 +4,7 @@ #include #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 diff --git a/src/QtUtil/public/QtUtil/QtStringListSelectionPanel.h b/src/QtUtil/public/QtUtil/QtStringListSelectionPanel.h index 388651e..3318d85 100644 --- a/src/QtUtil/public/QtUtil/QtStringListSelectionPanel.h +++ b/src/QtUtil/public/QtUtil/QtStringListSelectionPanel.h @@ -5,13 +5,8 @@ #include // MOC_SKIP_BEGIN -#ifndef QT_5 -#include -#include -#else // QT_5 #include #include -#endif // QT_5 // MOC_SKIP_END #include diff --git a/src/QtUtil/public/QtUtil/QtStringNumberFormatComboBox.h b/src/QtUtil/public/QtUtil/QtStringNumberFormatComboBox.h index f5aa1cc..c32d207 100644 --- a/src/QtUtil/public/QtUtil/QtStringNumberFormatComboBox.h +++ b/src/QtUtil/public/QtUtil/QtStringNumberFormatComboBox.h @@ -1,11 +1,7 @@ #ifndef QT_STRING_NUMBER_FORMAT_COMBOBOX_H #define QT_STRING_NUMBER_FORMAT_COMBOBOX_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtTextDialog.h b/src/QtUtil/public/QtUtil/QtTextDialog.h index 7660ef7..b8962ec 100644 --- a/src/QtUtil/public/QtUtil/QtTextDialog.h +++ b/src/QtUtil/public/QtUtil/QtTextDialog.h @@ -5,15 +5,9 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 /** Classe de boite de dialogue modale de saisie d'une page de texte. diff --git a/src/QtUtil/public/QtUtil/QtTextEditor.h b/src/QtUtil/public/QtUtil/QtTextEditor.h index aed03bb..e7fd9b0 100644 --- a/src/QtUtil/public/QtUtil/QtTextEditor.h +++ b/src/QtUtil/public/QtUtil/QtTextEditor.h @@ -1,12 +1,8 @@ #ifndef QT_TEXT_EDITOR_H #define QT_TEXT_EDITOR_H -#ifndef QT_5 -#include -#else // QT_5 -#include // requested by Qt 5.8.0 +#include #include -#endif // QT_5 /** diff --git a/src/QtUtil/public/QtUtil/QtTextField.h b/src/QtUtil/public/QtUtil/QtTextField.h index 4f0d0de..8733bad 100644 --- a/src/QtUtil/public/QtUtil/QtTextField.h +++ b/src/QtUtil/public/QtUtil/QtTextField.h @@ -3,11 +3,7 @@ #include -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 diff --git a/src/QtUtil/public/QtUtil/QtWebBrowser.h b/src/QtUtil/public/QtUtil/QtWebBrowser.h index d912c8f..21d22c8 100644 --- a/src/QtUtil/public/QtUtil/QtWebBrowser.h +++ b/src/QtUtil/public/QtUtil/QtWebBrowser.h @@ -3,25 +3,17 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 + #include #include -#endif // QT_5 #ifdef USE_QT_WEBKIT #include #else // USE_QT_WEBKIT -#ifndef QT_5 -#include -#else // QT_5 #ifdef USE_QT_WEBENGINE #include #else #include #endif // USE_QT_WEBENGINE -#endif // QT_5 #endif // USE_QT_WEBKIT #include diff --git a/src/QtUtil/public/QtUtil/QtWidgetAction.h b/src/QtUtil/public/QtUtil/QtWidgetAction.h index 36d6802..2850b89 100644 --- a/src/QtUtil/public/QtUtil/QtWidgetAction.h +++ b/src/QtUtil/public/QtUtil/QtWidgetAction.h @@ -8,11 +8,7 @@ #ifndef QT_WIDGET_ACTION_H #define QT_WIDGET_ACTION_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 diff --git a/src/QtUtil/public/QtUtil/QtWidgetAutoLock.h b/src/QtUtil/public/QtUtil/QtWidgetAutoLock.h index f88a271..01c7fcf 100644 --- a/src/QtUtil/public/QtUtil/QtWidgetAutoLock.h +++ b/src/QtUtil/public/QtUtil/QtWidgetAutoLock.h @@ -1,11 +1,8 @@ #ifndef QT_WIDGET_AUTO_LOCK_H #define QT_WIDGET_AUTO_LOCK_H -#ifndef QT_5 -#include -#else // QT_5 #include -#endif // QT_5 + /** Classe permettant de verrouiller un widget, par exemple un menu. Le widget diff --git a/src/encoding/CMakeLists.txt b/src/encoding/CMakeLists.txt index 4f35ab7..f3fb925 100644 --- a/src/encoding/CMakeLists.txt +++ b/src/encoding/CMakeLists.txt @@ -3,8 +3,9 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) -find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) add_executable (encoding QtEncodingMainWindow.cpp UTF_8.cpp Iso8859_1.cpp encoding.cpp) set_property (TARGET encoding PROPERTY AUTOMOC ON) diff --git a/src/encoding/QtEncodingMainWindow.h b/src/encoding/QtEncodingMainWindow.h index db2dfd1..11fa52a 100644 --- a/src/encoding/QtEncodingMainWindow.h +++ b/src/encoding/QtEncodingMainWindow.h @@ -1,11 +1,7 @@ #ifndef QT_ENCODING_MAIN_WINDOW_H #define QT_ENCODING_MAIN_WINDOW_H -#ifndef QT_5 -#include -#else // QT_5 -#include -#endif // QT_5 +#include class QtEncodingMainWindow : public QMainWindow { @@ -24,9 +20,7 @@ class QtEncodingMainWindow : public QMainWindow private : -#ifdef QT_4 - QtEncodingMainWindow (const QtEncodingMainWindow&); -#endif // QT_4 + QtEncodingMainWindow& operator = (const QtEncodingMainWindow&); }; // class QtEncodingMainWindow diff --git a/src/flow/CMakeLists.txt b/src/flow/CMakeLists.txt index 39ecb5e..e8d2e87 100644 --- a/src/flow/CMakeLists.txt +++ b/src/flow/CMakeLists.txt @@ -3,8 +3,9 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) -find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) add_executable (flow Flow.qrc window.cpp main.cpp) set_property (TARGET flow PROPERTY AUTOMOC ON) diff --git a/src/flow/main.cpp b/src/flow/main.cpp index bee66ca..18ea39f 100644 --- a/src/flow/main.cpp +++ b/src/flow/main.cpp @@ -1,8 +1,4 @@ -#ifndef QT_5 -#include -#else // QT_5 -#include -#endif // QT_5 +#include #include "window.h" diff --git a/src/flow/window.cpp b/src/flow/window.cpp index c0ec0d2..1253132 100644 --- a/src/flow/window.cpp +++ b/src/flow/window.cpp @@ -3,12 +3,7 @@ #include "QtUtil/QtFlowLayout.h" #include "window.h" -#include -#ifndef QT_5 -#include -#else // QT_5 -#include -#endif // QT_5 +#include #include using namespace std; diff --git a/src/flow/window.h b/src/flow/window.h index dbc9e47..a223812 100644 --- a/src/flow/window.h +++ b/src/flow/window.h @@ -1,11 +1,7 @@ #ifndef WINDOW_H #define WINDOW_H -#ifndef QT_5 -#include -#else // QT_5 -#include -#endif // QT_5 +#include class Window : public QWidget { diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index dfb008e..a6b043c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -3,8 +3,9 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) -find_package (Qt5Widgets 5 REQUIRED NO_CMAKE_SYSTEM_PATH) +find_package (Qt${QT_MAJOR}Widgets ${QT_MAJOR} REQUIRED NO_CMAKE_SYSTEM_PATH) add_executable (qt_tests QtAboutMainWindow.cpp about_dlg.cpp) set_property (TARGET qt_tests PROPERTY AUTOMOC ON) diff --git a/src/tests/QtAboutMainWindow.cpp b/src/tests/QtAboutMainWindow.cpp index 442fb4b..387aa12 100644 --- a/src/tests/QtAboutMainWindow.cpp +++ b/src/tests/QtAboutMainWindow.cpp @@ -22,17 +22,11 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#include -#else // QT_5 #include #include #include #include -#endif // QT_5 + #include "QtUtil/CharToLatinQString.h" @@ -167,7 +161,7 @@ void QtAboutMainWindow::coordinatesCallback ( ) UTF8String message (charset); message << "Choix des coordonnées."; static double x = 0., y = 0., z = 0.; - QtCoordinatesDialog dialog (this, "APP : Choix des coordonnées", "X", "Y", "Z", x, y, z, true, true, true, true); + QtCoordinatesDialog dialog (this, UTF8String ("APP : Choix des coordonnées", charset), "X", "Y", "Z", x, y, z, true, true, true, true); if (QDialog::Accepted != dialog.exec ( )) return; @@ -370,7 +364,11 @@ QStringListDialog::QStringListDialog (QWidget* parent, const vector & un setWindowTitle ("APP"); QVBoxLayout* layout = new QVBoxLayout (this); +#ifdef QT_5 layout->setMargin (QtConfiguration::margin); +#else // => Qt6 + layout->setContentsMargins (QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin, QtConfiguration::margin); +#endif // QT_5 layout->setSizeConstraint (QLayout::SetMinimumSize); _stringListPanel = new QtStringListSelectionPanel (this, unselected, selected); diff --git a/src/tests/QtAboutMainWindow.h b/src/tests/QtAboutMainWindow.h index 128c037..e0095bf 100644 --- a/src/tests/QtAboutMainWindow.h +++ b/src/tests/QtAboutMainWindow.h @@ -9,13 +9,8 @@ #include -#ifndef QT_5 -#include -#include -#else // QT_5 -#include -#include -#endif // QT_5 +#include +#include class QtAboutMainWindow : public QMainWindow diff --git a/src/tests/about_dlg.cpp b/src/tests/about_dlg.cpp index e94f89f..a545663 100644 --- a/src/tests/about_dlg.cpp +++ b/src/tests/about_dlg.cpp @@ -4,12 +4,8 @@ #include -#ifndef QT_5 -#include -#else // QT_5 #include -#include -#endif // QT_5 +//#include USING_UTIL @@ -25,18 +21,14 @@ int main (int argc, char* argv[]) { //QtValidatedTextField::automaticValidation = false; cout << argv [0] << " usage :" << endl - << argv [0] << "[-helpLocation directory][-helpFile htmlFile]" - << "[-webPage url][-webTag tag]" + << argv [0] << "[-helpLocation directory][-helpFile htmlFile][-webPage url][-webTag tag]" << endl; cout << "VERSION DE Qt UTILISEE : " << hex << QT_VERSION << " (" << QT_VERSION_STR << ")" << endl; parseArgs (argc, argv); QApplication app (argc, argv); - QtHelpWindow::initialize ( - QtAboutMainWindow::homeURL, QtAboutMainWindow::indexFile, - "AIDE EN LIGNE", "APP TEST" - ); + QtHelpWindow::initialize (QtAboutMainWindow::homeURL, QtAboutMainWindow::indexFile, "AIDE EN LIGNE", "APP TEST"); QtAboutMainWindow* window = new QtAboutMainWindow (0); window->show ( ); diff --git a/versions.txt b/versions.txt index b163bb6..417df81 100644 --- a/versions.txt +++ b/versions.txt @@ -1,3 +1,11 @@ +Version 6.4.0 : 13/12/23 +=============== + +Portage Qt 6/GUIToolkitsVariables v 1.4.0. + +QtCoordinatesDialog : correctif constructeur sans min/max : extrema initialisés à +- NumericServices::doubleMachMax ( ). + + Version 6.3.0 : 06/09/23 ===============