mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Adress review : add a recursion blocker
This commit is contained in:
parent
b7e655f0ba
commit
c508926c67
@ -57,17 +57,6 @@ widget.
|
||||
void setModelScene( QgsModelGraphicsScene *scene );
|
||||
%Docstring
|
||||
Sets the related ``scene``.
|
||||
%End
|
||||
|
||||
void friendlySetSceneRect();
|
||||
%Docstring
|
||||
Sets the scene rect used for scrollbar without disturbing the user i.e:
|
||||
- We grow the scene rect as the model grows - We shrink only if the
|
||||
model scene rect is outside the current viewed viewport
|
||||
|
||||
Called each time the view viewport moved or the model scene changed
|
||||
|
||||
.. versionadded:: 4.0
|
||||
%End
|
||||
|
||||
QgsModelGraphicsScene *modelScene() const;
|
||||
|
||||
@ -57,17 +57,6 @@ widget.
|
||||
void setModelScene( QgsModelGraphicsScene *scene );
|
||||
%Docstring
|
||||
Sets the related ``scene``.
|
||||
%End
|
||||
|
||||
void friendlySetSceneRect();
|
||||
%Docstring
|
||||
Sets the scene rect used for scrollbar without disturbing the user i.e:
|
||||
- We grow the scene rect as the model grows - We shrink only if the
|
||||
model scene rect is outside the current viewed viewport
|
||||
|
||||
Called each time the view viewport moved or the model scene changed
|
||||
|
||||
.. versionadded:: 4.0
|
||||
%End
|
||||
|
||||
QgsModelGraphicsScene *modelScene() const;
|
||||
|
||||
@ -52,8 +52,8 @@ QgsModelGraphicsView::QgsModelGraphicsView( QWidget *parent )
|
||||
mMidMouseButtonPanTool = new QgsModelViewToolTemporaryMousePan( this );
|
||||
mSpaceZoomTool = new QgsModelViewToolTemporaryKeyZoom( this );
|
||||
|
||||
connect( horizontalScrollBar(), &QScrollBar::sliderReleased, this, [=] { friendlySetSceneRect(); } );
|
||||
connect( verticalScrollBar(), &QScrollBar::sliderReleased, this, [=] { friendlySetSceneRect(); } );
|
||||
connect( horizontalScrollBar(), &QScrollBar::valueChanged, this, [=] { friendlySetSceneRect(); } );
|
||||
connect( verticalScrollBar(), &QScrollBar::valueChanged, this, [=] { friendlySetSceneRect(); } );
|
||||
|
||||
mSnapper.setSnapToGrid( true );
|
||||
}
|
||||
@ -498,6 +498,9 @@ void QgsModelGraphicsView::snapSelected()
|
||||
|
||||
void QgsModelGraphicsView::friendlySetSceneRect()
|
||||
{
|
||||
if ( mBlockScrollbarSignals )
|
||||
return;
|
||||
|
||||
QRectF modelSceneRect = modelScene()->sceneRect();
|
||||
QRectF viewSceneRect = sceneRect();
|
||||
|
||||
@ -508,7 +511,9 @@ void QgsModelGraphicsView::friendlySetSceneRect()
|
||||
viewSceneRect.setTop( std::min( modelSceneRect.top(), visibleRect.top() ) );
|
||||
viewSceneRect.setBottom( std::max( modelSceneRect.bottom(), visibleRect.bottom() ) );
|
||||
|
||||
mBlockScrollbarSignals++;
|
||||
setSceneRect( viewSceneRect );
|
||||
mBlockScrollbarSignals--;
|
||||
}
|
||||
|
||||
void QgsModelGraphicsView::copySelectedItems( QgsModelGraphicsView::ClipboardOperation operation )
|
||||
|
||||
@ -66,18 +66,6 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
|
||||
*/
|
||||
void setModelScene( QgsModelGraphicsScene *scene );
|
||||
|
||||
/**
|
||||
* Sets the scene rect used for scrollbar without disturbing the user
|
||||
* i.e:
|
||||
* - We grow the scene rect as the model grows
|
||||
* - We shrink only if the model scene rect is outside the current viewed viewport
|
||||
*
|
||||
* Called each time the view viewport moved or the model scene changed
|
||||
*
|
||||
* \since QGIS 4.0
|
||||
*/
|
||||
void friendlySetSceneRect();
|
||||
|
||||
/**
|
||||
* Returns the scene associated with the tool.
|
||||
* \see view()
|
||||
@ -245,6 +233,18 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
|
||||
*/
|
||||
QPointF deltaForKeyEvent( QKeyEvent *event );
|
||||
|
||||
/**
|
||||
* Sets the scene rect used for scrollbar without disturbing the user
|
||||
* i.e:
|
||||
* - We grow the scene rect as the model grows
|
||||
* - We shrink only if the model scene rect is outside the current viewed viewport
|
||||
*
|
||||
* Called each time the view viewport moved or the model scene changed
|
||||
*
|
||||
* \since QGIS 4.0
|
||||
*/
|
||||
void friendlySetSceneRect();
|
||||
|
||||
QPointer<QgsModelViewTool> mTool;
|
||||
|
||||
QgsModelViewToolTemporaryKeyPan *mSpacePanTool = nullptr;
|
||||
@ -253,6 +253,8 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
|
||||
|
||||
QPoint mMouseCurrentXY;
|
||||
|
||||
int mBlockScrollbarSignals = 0;
|
||||
|
||||
QgsModelSnapper mSnapper;
|
||||
QgsModelViewSnapMarker *mSnapMarker = nullptr;
|
||||
};
|
||||
|
||||
@ -81,7 +81,6 @@ void QgsModelViewToolPan::modelReleaseEvent( QgsModelViewMouseEvent *event )
|
||||
|
||||
mIsPanning = false;
|
||||
view()->viewport()->setCursor( Qt::OpenHandCursor );
|
||||
view()->friendlySetSceneRect();
|
||||
}
|
||||
|
||||
void QgsModelViewToolPan::deactivate()
|
||||
|
||||
@ -37,7 +37,6 @@ void QgsModelViewToolTemporaryKeyPan::keyReleaseEvent( QKeyEvent *event )
|
||||
if ( event->key() == Qt::Key_Space && !event->isAutoRepeat() )
|
||||
{
|
||||
view()->setTool( mPreviousViewTool );
|
||||
view()->friendlySetSceneRect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ void QgsModelViewToolTemporaryMousePan::modelReleaseEvent( QgsModelViewMouseEven
|
||||
if ( event->button() == Qt::MiddleButton )
|
||||
{
|
||||
view()->setTool( mPreviousViewTool );
|
||||
view()->friendlySetSceneRect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user