Skip to content
Permalink
Browse files

Cleanup cursor handling in QgsLayerTreeViewDefaultActions

  • Loading branch information
nyalldawson committed Jan 2, 2021
1 parent 0d33fe4 commit 9f8f65d3b3d991cd99bd03a4b22f8d1def118633
Showing with 8 additions and 10 deletions.
  1. +5 −10 src/gui/layertree/qgslayertreeviewdefaultactions.cpp
  2. +3 −0 src/gui/qgsmapcanvas.cpp
@@ -326,8 +326,8 @@ void QgsLayerTreeViewDefaultActions::zoomToGroup( QgsMapCanvas *canvas )
return;

QList<QgsMapLayer *> layers;
const auto constFindLayerIds = groupNode->findLayerIds();
for ( const QString &layerId : constFindLayerIds )
const QStringList findLayerIds = groupNode->findLayerIds();
for ( const QString &layerId : findLayerIds )
layers << QgsProject::instance()->mapLayer( layerId );

zoomToLayers( canvas, layers );
@@ -338,41 +338,36 @@ void QgsLayerTreeViewDefaultActions::zoomToLayer()
Q_NOWARN_DEPRECATED_PUSH
QAction *s = qobject_cast<QAction *>( sender() );
QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
QApplication::setOverrideCursor( Qt::WaitCursor );

zoomToLayer( canvas );
QApplication::restoreOverrideCursor();
Q_NOWARN_DEPRECATED_POP
}

void QgsLayerTreeViewDefaultActions::zoomToLayers()
{
QAction *s = qobject_cast<QAction *>( sender() );
QgsMapCanvas *canvas = s->data().value<QgsMapCanvas *>();
QApplication::setOverrideCursor( Qt::WaitCursor );
zoomToLayers( canvas );
QApplication::restoreOverrideCursor();
}

void QgsLayerTreeViewDefaultActions::zoomToSelection()
{
QAction *s = qobject_cast<QAction *>( sender() );
QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor );
zoomToSelection( canvas );
}

void QgsLayerTreeViewDefaultActions::zoomToGroup()
{
QAction *s = qobject_cast<QAction *>( sender() );
QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
QApplication::setOverrideCursor( Qt::WaitCursor );
zoomToGroup( canvas );
QApplication::restoreOverrideCursor();
}


void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas *canvas, const QList<QgsMapLayer *> &layers )
{
QgsTemporaryCursorOverride cursorOveride( Qt::WaitCursor );

QgsRectangle extent;
extent.setMinimal();

@@ -1319,6 +1319,8 @@ QgsRectangle QgsMapCanvas::optimalExtentForPointLayer( QgsVectorLayer *layer, co

void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
{
QgsTemporaryCursorOverride cursorOveride( Qt::WaitCursor );

if ( !layer )
{
// use current layer by default
@@ -1331,6 +1333,7 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )
QgsRectangle rect = layer->boundingBoxOfSelected();
if ( rect.isNull() )
{
cursorOveride.release();
emit messageEmitted( tr( "Cannot zoom to selected feature(s)" ), tr( "No extent could be determined." ), Qgis::Warning );
return;
}

0 comments on commit 9f8f65d

Please sign in to comment.
You can’t perform that action at this time.