From 4009e6aaab054b1241ef49a8a85daf982e8ace28 Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Sun, 2 Mar 2025 18:56:34 +0100 Subject: [PATCH] simplify and use the same code for Qt5 & Qt6 When reading and comparing Qt5-docs and Qt6-docs, I read, that there are no differences in the functions! So it is not necessary to have the differentiation between the Qt-Versions. Code compiles without errors or warnings for Qt5 and Qt6. --- sources/editor/graphicspart/partarc.cpp | 7 ------- sources/editor/graphicspart/partellipse.cpp | 7 ------- sources/editor/graphicspart/partline.cpp | 7 ------- sources/editor/graphicspart/partrectangle.cpp | 7 ------- sources/editor/graphicspart/partterminal.cpp | 14 ++------------ sources/qetgraphicsitem/terminal.cpp | 14 -------------- 6 files changed, 2 insertions(+), 54 deletions(-) diff --git a/sources/editor/graphicspart/partarc.cpp b/sources/editor/graphicspart/partarc.cpp index ad340da67..dcaaf93d9 100644 --- a/sources/editor/graphicspart/partarc.cpp +++ b/sources/editor/graphicspart/partarc.cpp @@ -61,14 +61,7 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, //Always remove the brush painter -> setBrush(Qt::NoBrush); QPen t = painter -> pen(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - t.setCosmetic(options && options -> levelOfDetail < 1.0); -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0); -#endif painter -> setPen(t); if (isSelected()) diff --git a/sources/editor/graphicspart/partellipse.cpp b/sources/editor/graphicspart/partellipse.cpp index fb9907a95..543ad2e46 100644 --- a/sources/editor/graphicspart/partellipse.cpp +++ b/sources/editor/graphicspart/partellipse.cpp @@ -57,14 +57,7 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio QPen t = painter -> pen(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - t.setCosmetic(options && options -> levelOfDetail < 1.0); -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0); -#endif if (isSelected()) t.setColor(Qt::red); diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp index 3856af0dc..622cc0afa 100644 --- a/sources/editor/graphicspart/partline.cpp +++ b/sources/editor/graphicspart/partline.cpp @@ -81,14 +81,7 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QPen t = painter -> pen(); t.setJoinStyle(Qt::MiterJoin); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - t.setCosmetic(options && options -> levelOfDetail < 1.0); -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0); -#endif if (isSelected()) t.setColor(Qt::red); painter -> setPen(t); diff --git a/sources/editor/graphicspart/partrectangle.cpp b/sources/editor/graphicspart/partrectangle.cpp index 7d4d27f2a..bbdbc12eb 100644 --- a/sources/editor/graphicspart/partrectangle.cpp +++ b/sources/editor/graphicspart/partrectangle.cpp @@ -54,14 +54,7 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt Q_UNUSED(widget); applyStylesToQPainter(*painter); QPen t = painter -> pen(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - t.setCosmetic(options && options -> levelOfDetail < 1.0); -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0); -#endif if (isSelected()) t.setColor(Qt::red); diff --git a/sources/editor/graphicspart/partterminal.cpp b/sources/editor/graphicspart/partterminal.cpp index 8e1a67e00..5f96c3fd2 100644 --- a/sources/editor/graphicspart/partterminal.cpp +++ b/sources/editor/graphicspart/partterminal.cpp @@ -84,18 +84,8 @@ void PartTerminal::paint( QPen t; t.setWidthF(1.0); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - t.setCosmetic(options && options -> levelOfDetail < 1.0); -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif - t.setCosmetic( - options - && options->levelOfDetailFromTransform( - painter->worldTransform()) - < 1.0); -#endif + t.setCosmetic(options && options -> levelOfDetailFromTransform(painter->worldTransform()) < 1.0); + // dessin de la borne en rouge t.setColor(isSelected() ? Terminal::neutralColor : Qt::red); painter -> setPen(t); diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp index b73fe47d7..19e207f7c 100644 --- a/sources/qetgraphicsitem/terminal.cpp +++ b/sources/qetgraphicsitem/terminal.cpp @@ -163,15 +163,8 @@ void Terminal::paint( QWidget *) { // en dessous d'un certain zoom, les bornes ne sont plus dessinees -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - if (options && options -> levelOfDetail < 0.5) return; -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 0.5) return; -#endif painter -> save(); //annulation des renderhints @@ -186,14 +179,7 @@ void Terminal::paint( QPen t; t.setWidthF(1.0); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove - if (options && options -> levelOfDetail < 1.0) -#else -#if TODO_LIST -#pragma message("@TODO remove code for QT 6 or later") -#endif if (options && options->levelOfDetailFromTransform(painter->worldTransform()) < 1.0) -#endif { t.setCosmetic(true); }