diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d1b799..59f5edc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required (VERSION 3.15) # CMP0094 project (QtPython CXX) diff --git a/cmake/version.cmake b/cmake/version.cmake index 00c899e..49bfb6e 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -4,13 +4,13 @@ # Pour la bibliothèque QtPython : set (QT_PYTHON_MAJOR_VERSION "6") -set (QT_PYTHON_MINOR_VERSION "3") -set (QT_PYTHON_RELEASE_VERSION "3") +set (QT_PYTHON_MINOR_VERSION "4") +set (QT_PYTHON_RELEASE_VERSION "0") set (QT_PYTHON_VERSION ${QT_PYTHON_MAJOR_VERSION}.${QT_PYTHON_MINOR_VERSION}.${QT_PYTHON_RELEASE_VERSION}) # Pour la bibliothèque QtPython3 : set (QT_PYTHON_3_MAJOR_VERSION "6") -set (QT_PYTHON_3_MINOR_VERSION "3") -set (QT_PYTHON_3_RELEASE_VERSION "3") +set (QT_PYTHON_3_MINOR_VERSION "4") +set (QT_PYTHON_3_RELEASE_VERSION "0") set (QT_PYTHON_3_VERSION ${QT_PYTHON_3_MAJOR_VERSION}.${QT_PYTHON_3_MINOR_VERSION}.${QT_PYTHON_3_RELEASE_VERSION}) diff --git a/src/QtPython3/CMakeLists.txt b/src/QtPython3/CMakeLists.txt index 2f56bcd..15b8d42 100644 --- a/src/QtPython3/CMakeLists.txt +++ b/src/QtPython3/CMakeLists.txt @@ -5,6 +5,7 @@ find_package (GUIToolkitsVariables) include (${CMAKE_SOURCE_DIR}/cmake/version.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/common.cmake) +include (${GUIToolkitsVariables_CMAKE_DIR}/common_qt.cmake) # QT_MAJOR include (${GUIToolkitsVariables_CMAKE_DIR}/python_binding.cmake) include (${GUIToolkitsVariables_CMAKE_DIR}/workarounds.cmake) @@ -13,7 +14,7 @@ set (QT_PYTHON_SCRIPTS_DIR "${CMAKE_INSTALL_PREFIX}/${PYTHON_BINDING_DIR}") find_package (QtUtil 6 REQUIRED) find_package (PythonUtil 6 REQUIRED) -find_package(Qt5Core NO_CMAKE_SYSTEM_PATH) # In order to enable moc ... +find_package(Qt${QT_MAJOR}Core NO_CMAKE_SYSTEM_PATH) # In order to enable moc ... file (GLOB HEADERS public/${CURRENT_PACKAGE_NAME}/*.h) file (GLOB CPP_SOURCES *.cpp *.qrc) @@ -26,10 +27,10 @@ set_property (TARGET QtPython3 PROPERTY AUTORCC ON) set (ALL_TARGETS QtPython3) set_property (TARGET QtPython3 PROPERTY VERSION ${QT_PYTHON_3_VERSION}) set_property (TARGET QtPython3 PROPERTY SOVERSION ${QT_PYTHON_3_MAJOR_VERSION}) -set (QT_LIB_DEPENDENCIES Qt5::Widgets Qt5::Gui Qt5::Core) -set (QT_INC_DEPENDENCIES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS}) +set (QT_LIB_DEPENDENCIES Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::Gui Qt${QT_MAJOR}::Core) +set (QT_INC_DEPENDENCIES ${Qt${QT_MAJOR}Gui_INCLUDE_DIRS} ${Qt${QT_MAJOR}Core_INCLUDE_DIRS}) # Rem : en Qt v 4.* on utilise -DUSE_QT_WEBKIT -set (QT_PYTHON_3_PUBLIC_FLAGS -DQT_5) +set (QT_PYTHON_3_PUBLIC_FLAGS -DQT_${QT_MAJOR}) set (QT_PYTHON_3_PRIVATE_FLAGS -DQT_PYTHON_VERSION="${QT_PYTHON_3_VERSION}") # REM : on avait historiquement l'instruction suivante, pour contourner un bogue icpc sur plateforme Bull : diff --git a/src/QtPython3/QtPythonConsole.cpp b/src/QtPython3/QtPythonConsole.cpp index 7acac2e..a91761f 100644 --- a/src/QtPython3/QtPythonConsole.cpp +++ b/src/QtPython3/QtPythonConsole.cpp @@ -17,15 +17,9 @@ #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include // PyFrameObject @@ -1318,7 +1312,11 @@ void QtPythonConsole::addSwigCompletions (vector& completions, const str { const string msg = exc.getFullMessage ( ).utf8 ( ); const QString qmsg (msg.c_str ( )); +#ifdef QT_5 QStringList lines = qmsg.split ("\n", QString::KeepEmptyParts); +#else // QT_5 + QStringList lines = qmsg.split ("\n", Qt::KeepEmptyParts); +#endif // QT_5 const size_t num = lines.size ( ); if (1 == num) // On fait comme on peut ... completions.push_back(cppToPython (getSwigCompletion (expression))); @@ -2722,7 +2720,12 @@ vector QtPythonConsole::getRunnableInstructions (size_t first) const { vector instructions; QString text = document ( )->toPlainText ( ); +#ifdef QT_5 QStringList lines = QString (text).split ("\n", QString::KeepEmptyParts); +#else // QT_5 + QStringList lines = QString (text).split ("\n", Qt::KeepEmptyParts); +#endif // QT_5 + // On élimine les lignes blanches finales : size_t last = lines.size ( ); for (size_t i = last; i != 0; i--) diff --git a/src/QtPython3/QtPythonSyntaxHighlighter.cpp b/src/QtPython3/QtPythonSyntaxHighlighter.cpp index 3ee47a6..3325258 100644 --- a/src/QtPython3/QtPythonSyntaxHighlighter.cpp +++ b/src/QtPython3/QtPythonSyntaxHighlighter.cpp @@ -35,38 +35,53 @@ QtPythonSyntaxHighlighter::QtPythonSyntaxHighlighter (QTextDocument* parent) << "\\b__\\*\\b"; foreach (const QString& pattern, keywordPatterns) { +#ifdef QT_5 rule.pattern = QRegExp (pattern); +#else // QT_5 + rule.pattern = QRegularExpression (pattern); +#endif // QT_5 + rule.format = keywordFormat; _highlightingRules.append (rule); } // foreach (const QString& pattern, keywordPatterns) quotationFormat.setForeground (Qt::red); +#ifdef QT_5 rule.pattern = QRegExp ("\".*\""); +#else // QT_5 + rule.pattern = QRegularExpression ("\".*\""); +#endif // QT_5 rule.format = quotationFormat; _highlightingRules.append (rule); quotationFormat.setFontItalic (true); quotationFormat.setForeground (Qt::cyan); +#ifdef QT_5 rule.pattern = QRegExp ("\\b[A-Za-z0-9__]+(?=\\()"); +#else // QT_5 + rule.pattern = QRegularExpression ("\\b[A-Za-z0-9__]+(?=\\()"); +#endif // QT_5 rule.format = functionFormat; _highlightingRules.append (rule); singleLineFormat.setForeground (Qt::blue); +#ifdef QT_5 rule.pattern = QRegExp ("#[^\n]*"); +#else // QT_5 + rule.pattern = QRegularExpression ("#[^\n]*"); +#endif // QT_5 rule.format = singleLineFormat; _highlightingRules.append (rule); } // QtPythonSyntaxHighlighter::QtPythonSyntaxHighlighter -QtPythonSyntaxHighlighter::QtPythonSyntaxHighlighter ( - const QtPythonSyntaxHighlighter&) +QtPythonSyntaxHighlighter::QtPythonSyntaxHighlighter (const QtPythonSyntaxHighlighter&) : QSyntaxHighlighter ((QTextDocument*)0) { assert (0 && "QtPythonSyntaxHighlighter copy constructor is not allowed."); } // QtPythonSyntaxHighlighter::QtPythonSyntaxHighlighter -QtPythonSyntaxHighlighter& QtPythonSyntaxHighlighter::operator = ( - const QtPythonSyntaxHighlighter&) +QtPythonSyntaxHighlighter& QtPythonSyntaxHighlighter::operator = (const QtPythonSyntaxHighlighter&) { assert (0 && "QtPythonSyntaxHighlighter copy constructor is not allowed."); return *this; @@ -82,7 +97,9 @@ void QtPythonSyntaxHighlighter::highlightBlock (const QString& text) { foreach (const HighlightingRule& rule, _highlightingRules) { +#ifdef QT_5 QRegExp expression (rule.pattern); + int index = expression.indexIn (text); while (index >= 0) { @@ -93,12 +110,20 @@ void QtPythonSyntaxHighlighter::highlightBlock (const QString& text) // Sécurité contre une expression mal formulée (=> boucle infinie) : if (length <= 0) { - cerr << __FILE__ << ' ' << __LINE__ - << " Erreur de formulation de l'expression régulière " - << expression.pattern ( ).toStdString ( ) << endl; + cerr << __FILE__ << ' ' << __LINE__ << " Erreur de formulation de l'expression régulière " << expression.pattern ( ).toStdString ( ) << endl; break; } // if (length <= 0) } // while (index >= 0) +#else // QT_5 + QRegularExpression expression (rule.pattern); + + QRegularExpressionMatchIterator it = expression.globalMatch (text); + while (it.hasNext ( )) + { + QRegularExpressionMatch match = it.next ( ); + setFormat (match.capturedStart ( ), match.capturedLength ( ), rule.format); + } // while (it.hasNext ( )) +#endif // QT_5 } // foreach (const HighlightingRule& rule, _highlightingRules) } // QtPythonSyntaxHighlighter::highlightBlock diff --git a/src/QtPython3/public/QtPython3/QtPythonConsole.h b/src/QtPython3/public/QtPython3/QtPythonConsole.h index b4bffd3..13983cd 100644 --- a/src/QtPython3/public/QtPython3/QtPythonConsole.h +++ b/src/QtPython3/public/QtPython3/QtPythonConsole.h @@ -18,15 +18,9 @@ typedef struct _object PyObject; #include #include -#ifndef QT_5 -#include -#include -#include -#else // QT_5 #include #include #include -#endif // QT_5 #include #include diff --git a/src/QtPython3/public/QtPython3/QtPythonSyntaxHighlighter.h b/src/QtPython3/public/QtPython3/QtPythonSyntaxHighlighter.h index 6efc8d6..25a6cb5 100644 --- a/src/QtPython3/public/QtPython3/QtPythonSyntaxHighlighter.h +++ b/src/QtPython3/public/QtPython3/QtPythonSyntaxHighlighter.h @@ -2,7 +2,9 @@ #define QT_PYTHON_SYNTAX_HIGHLIGHTER_H #include - +#ifndef QT_5 +# include +#endif // QT_5 /** * Classe permettant la mise en évidence des mots clés du langage python dans @@ -46,7 +48,12 @@ class QtPythonSyntaxHighlighter : public QSyntaxHighlighter struct HighlightingRule { - QRegExp pattern; +#ifdef QT_5 + QRegExp pattern; +#else // QT_5 + QRegularExpression pattern; +#endif // QT_5 + QTextCharFormat format; }; // struct HighlightingRule diff --git a/versions.txt b/versions.txt index d6d9dd8..cd0b7c6 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/QtUtil v 6.4.0 de la console python 3. La console python 2 est considérée obsolète. + +cmake_minimum_required (VERSION 3.15) # CMP0094 + + Version 6.3.3 : 27/10/23 ===============