Adress more comments

This commit is contained in:
Valentin Buira 2025-05-14 10:44:45 +02:00 committed by Nyall Dawson
parent 10897ff3a9
commit f24fb9daf4
3 changed files with 9 additions and 5 deletions

View File

@ -242,8 +242,9 @@ class ModelerDialog(QgsModelDesignerDialog):
self.loadModel(filename)
def repaintModel(self, showControls=True, initialPaint=False):
_oldViewportPolygon = self.view().mapToScene(self.view().viewport().rect())
oldViewportRect = _oldViewportPolygon.boundingRect()
old_viewport_rect = (
self.view().mapToScene(self.view().viewport().rect()).boundingRect()
)
scene = ModelerScene(self)
@ -262,7 +263,8 @@ class ModelerDialog(QgsModelDesignerDialog):
scene.createItems(self.model(), context)
if initialPaint == False:
self.view().fitInView(oldViewportRect, Qt.AspectRatioMode.KeepAspectRatio)
# Restaure the previous viewport rect so the view don't jump around
self.view().fitInView(old_viewport_rect, Qt.AspectRatioMode.KeepAspectRatio)
def create_widget_context(self):
"""

View File

@ -62,7 +62,7 @@ void QgsModelGraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent *event )
void QgsModelGraphicsScene::updateBounds()
{
setSceneRect( modelBounds( 50 ) );
setSceneRect( modelBounds( SCENE_COMPONENT_MARGIN ) );
}
QRectF QgsModelGraphicsScene::modelBounds( double margin ) const
@ -71,7 +71,7 @@ QRectF QgsModelGraphicsScene::modelBounds( double margin ) const
QRectF bounds;
//add all items
const auto constItems = items();
const QList<QGraphicsItem *> constItems = items();
for ( QGraphicsItem *item : constItems )
{
QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( item );

View File

@ -298,6 +298,8 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
QMap<QString, QgsModelComponentGraphicItem *> mGroupBoxItems;
QgsProcessingModelResult mLastResult;
static constexpr int SCENE_COMPONENT_MARGIN = 50;
QgsMessageBar *mMessageBar = nullptr;
};