From 10897ff3a9056550bb4c62d0e2bd8ebc820614a3 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Tue, 13 May 2025 22:37:09 +0200 Subject: [PATCH] Adress comments --- .../processing/models/qgsmodelgraphicsscene.sip.in | 10 ++++++---- .../processing/models/qgsmodelgraphicsscene.sip.in | 10 ++++++---- src/gui/processing/models/qgsmodelgraphicsscene.cpp | 7 ++----- src/gui/processing/models/qgsmodelgraphicsscene.h | 8 ++++---- src/gui/processing/models/qgsmodelgraphicsview.cpp | 1 - src/gui/processing/models/qgsmodelgraphicsview.h | 2 -- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/python/PyQt6/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in b/python/PyQt6/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in index b059fe661f0..005642132a1 100644 --- a/python/PyQt6/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in +++ b/python/PyQt6/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in @@ -87,14 +87,16 @@ Returns the current combination of flags set for the scene. virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - QRectF modelBounds( double margin ) const; + QRectF modelBounds( double margin = 0.0 ) const; %Docstring -Calculates the bouding bounds of all components of the model. +Calculates the bounding rectangle of all components of the model. -:param margin: optional marginal ( absolute value in scene coordinate) - to add around items +:param margin: optional margin (absolute value in scene coordinates) to + add around items. :return: model bounds, in scene units. + +.. versionadded:: 3.44 %End diff --git a/python/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in b/python/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in index e6fadb6fcb4..20d2df68a1a 100644 --- a/python/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in +++ b/python/gui/auto_generated/processing/models/qgsmodelgraphicsscene.sip.in @@ -87,14 +87,16 @@ Returns the current combination of flags set for the scene. virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); - QRectF modelBounds( double margin ) const; + QRectF modelBounds( double margin = 0.0 ) const; %Docstring -Calculates the bouding bounds of all components of the model. +Calculates the bounding rectangle of all components of the model. -:param margin: optional marginal ( absolute value in scene coordinate) - to add around items +:param margin: optional margin (absolute value in scene coordinates) to + add around items. :return: model bounds, in scene units. + +.. versionadded:: 3.44 %End diff --git a/src/gui/processing/models/qgsmodelgraphicsscene.cpp b/src/gui/processing/models/qgsmodelgraphicsscene.cpp index aadf48f7a3b..2c8815b3b28 100644 --- a/src/gui/processing/models/qgsmodelgraphicsscene.cpp +++ b/src/gui/processing/models/qgsmodelgraphicsscene.cpp @@ -75,11 +75,8 @@ QRectF QgsModelGraphicsScene::modelBounds( double margin ) const for ( QGraphicsItem *item : constItems ) { QgsModelComponentGraphicItem *componentItem = dynamic_cast( item ); - if ( !componentItem ) - { - continue; - } - bounds = bounds.united( componentItem->sceneBoundingRect() ); + if ( componentItem ) + bounds = bounds.united( componentItem->sceneBoundingRect() ); } if ( bounds.isValid() && margin > 0.0 ) diff --git a/src/gui/processing/models/qgsmodelgraphicsscene.h b/src/gui/processing/models/qgsmodelgraphicsscene.h index 84614cf52b8..37604675c6f 100644 --- a/src/gui/processing/models/qgsmodelgraphicsscene.h +++ b/src/gui/processing/models/qgsmodelgraphicsscene.h @@ -99,12 +99,12 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene void mousePressEvent( QGraphicsSceneMouseEvent *event ) override; /** - * Calculates the bouding bounds of all components of the model. - * \param margin optional marginal ( absolute value in scene coordinate) to add around items + * Calculates the bounding rectangle of all components of the model. + * \param margin optional margin (absolute value in scene coordinates) to add around items. * \returns model bounds, in scene units. - * + * \since QGIS 3.44 */ - QRectF modelBounds( double margin ) const; + QRectF modelBounds( double margin = 0.0 ) const; /** diff --git a/src/gui/processing/models/qgsmodelgraphicsview.cpp b/src/gui/processing/models/qgsmodelgraphicsview.cpp index 6581ca9fa25..48cf392b4ea 100644 --- a/src/gui/processing/models/qgsmodelgraphicsview.cpp +++ b/src/gui/processing/models/qgsmodelgraphicsview.cpp @@ -397,7 +397,6 @@ void QgsModelGraphicsView::setModelScene( QgsModelGraphicsScene *scene ) { setScene( scene ); - mPreviousSceneRect = sceneRect(); // IMPORTANT! // previous snap markers, snap lines are owned by previous layout - so don't delete them here! mSnapMarker = new QgsModelViewSnapMarker(); diff --git a/src/gui/processing/models/qgsmodelgraphicsview.h b/src/gui/processing/models/qgsmodelgraphicsview.h index 8e90b81f821..36652ae9e3a 100644 --- a/src/gui/processing/models/qgsmodelgraphicsview.h +++ b/src/gui/processing/models/qgsmodelgraphicsview.h @@ -244,8 +244,6 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView QgsModelSnapper mSnapper; QgsModelViewSnapMarker *mSnapMarker = nullptr; - - QRectF mPreviousSceneRect; };