Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required (VERSION 3.15) # CMP0094

project (QtPython CXX)

Expand Down
8 changes: 4 additions & 4 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})

9 changes: 5 additions & 4 deletions src/QtPython3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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 :
Expand Down
15 changes: 9 additions & 6 deletions src/QtPython3/QtPythonConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@

#include <QThread>
#include <QPainter>
#ifndef QT_5
#include <QtGui/QAction>
#include <QtGui/QFileDialog>
#include <QtGui/QMenu>
#else // QT_5
#include <QAction>
#include <QFileDialog>
#include <QMenu>
#endif // QT_5

#include <frameobject.h>// PyFrameObject

Expand Down Expand Up @@ -1318,7 +1312,11 @@ void QtPythonConsole::addSwigCompletions (vector<string>& 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)));
Expand Down Expand Up @@ -2722,7 +2720,12 @@ vector<string> QtPythonConsole::getRunnableInstructions (size_t first) const
{
vector<string> 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--)
Expand Down
39 changes: 32 additions & 7 deletions src/QtPython3/QtPythonSyntaxHighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -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

6 changes: 0 additions & 6 deletions src/QtPython3/public/QtPython3/QtPythonConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ typedef struct _object PyObject;

#include <QSettings>
#include <QIcon>
#ifndef QT_5
#include <QtGui/QComboBox>
#include <QtGui/QMainWindow>
#include <QtGui/QToolBar>
#else // QT_5
#include <QComboBox>
#include <QMainWindow>
#include <QToolBar>
#endif // QT_5

#include <fstream>
#include <memory>
Expand Down
11 changes: 9 additions & 2 deletions src/QtPython3/public/QtPython3/QtPythonSyntaxHighlighter.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#define QT_PYTHON_SYNTAX_HIGHLIGHTER_H

#include <QSyntaxHighlighter>

#ifndef QT_5
# include <QRegularExpression>
#endif // QT_5

/**
* Classe permettant la mise en évidence des mots clés du langage python dans
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions versions.txt
Original file line number Diff line number Diff line change
@@ -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
===============

Expand Down