Skip to content
Permalink
Browse files

When setting the CRS for layers via the recent CRS menu in the

layer tree, make sure the CRS is set for ALL selected layers
  • Loading branch information
nyalldawson committed Sep 21, 2020
1 parent 0fb54bc commit ef99f005de0d2025532351100a4f1c3fa889d35f
Showing with 15 additions and 8 deletions.
  1. +15 −8 src/app/qgsapplayertreeviewmenuprovider.cpp
@@ -347,7 +347,6 @@ QMenu *QgsAppLayerTreeViewMenuProvider::createContextMenu()
for ( const QgsCoordinateReferenceSystem &crs : recentProjections )
{
QAction *action = menuSetCRS->addAction( tr( "Set to %1" ).arg( crs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ) ) );
action->setProperty( "layerId", layer->id() );
action->setProperty( "crs", crs.toWkt( QgsCoordinateReferenceSystem::WKT_PREFERRED ) );
i++;
if ( i == 2 )
@@ -1025,12 +1024,20 @@ bool QgsAppLayerTreeViewMenuProvider::removeActionEnabled()

void QgsAppLayerTreeViewMenuProvider::setLayerCrs( QAction *action )
{
QString layerId = action->property( "layerId" ).toString();
QgsMapLayer *layer = QgsProject::instance()->mapLayer( layerId );
if ( !layer )
return;
const QString wkt = action->property( "crs" ).toString();
const QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( wkt );

QString wkt = action->property( "crs" ).toString();
layer->setCrs( QgsCoordinateReferenceSystem( wkt ), true );
layer->triggerRepaint();
const auto constSelectedNodes = mView->selectedNodes();
for ( QgsLayerTreeNode *node : constSelectedNodes )
{
if ( QgsLayerTree::isLayer( node ) )
{
QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node );
if ( nodeLayer->layer() )
{
nodeLayer->layer()->setCrs( crs, true );
nodeLayer->layer()->triggerRepaint();
}
}
}
}

0 comments on commit ef99f00

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