From f6ba47277dd5f5e42c5aaa11276e06cf671ff504 Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 2 Oct 2025 21:52:40 +0200 Subject: [PATCH] Minor : revamp Use QGIUtility::drawBoundingRectSelection for draw the selection rect of element instead of a method of the element itself. Less code. --- sources/qetgraphicsitem/element.cpp | 31 ++--------------------------- sources/qetgraphicsitem/element.h | 3 --- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index 5f5315444..0817155ec 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -34,6 +34,7 @@ #include "elementtextitemgroup.h" #include "iostream" #include "../qetxml.h" +#include "qgraphicsitemutility.h" #include #include @@ -242,7 +243,7 @@ void Element::paint( //Draw the selection rectangle if ( isSelected() || m_mouse_over ) { - drawSelection(painter, options); + QGIUtility::drawBoundingRectSelection(this, painter); } } @@ -340,34 +341,6 @@ void Element::drawAxes( /*** Methodes privees ***/ -/** - Dessine le cadre de selection de l'element de maniere systematiquement non antialiasee. - @param painter Le QPainter a utiliser pour dessiner les bornes. - @param options Les options de style a prendre en compte -*/ -void Element::drawSelection( - QPainter *painter, - const QStyleOptionGraphicsItem *options) -{ - Q_UNUSED(options) - painter -> save(); - // Annulation des renderhints - painter -> setRenderHint(QPainter::Antialiasing, false); - painter -> setRenderHint(QPainter::TextAntialiasing, false); - painter -> setRenderHint(QPainter::SmoothPixmapTransform, false); - // Dessin du cadre de selection en gris - QPen t; - t.setColor(Qt::gray); - t.setStyle(Qt::DashDotLine); - t.setCosmetic(true); - painter -> setPen(t); - // Le dessin se fait a partir du rectangle delimitant - painter -> drawRoundedRect(boundingRect().adjusted(1, 1, -1, -1), - 10, - 10); - painter -> restore(); -} - /** Dessine le cadre de selection de l'element de maniere systematiquement non antialiasee. @param painter Le QPainter a utiliser pour dessiner les bornes. diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index 96ba46205..0565ffc01 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -197,9 +197,6 @@ class Element : public QetGraphicsItem void setSize(int, int); private: - void drawSelection( - QPainter *, - const QStyleOptionGraphicsItem *); void drawHighlight( QPainter *, const QStyleOptionGraphicsItem *);