Skip to content

Commit 4ca81ba

Browse files
committed
Merge pull request #2576 from SebDieBln/DefaultLayerActions_on_selected_layers
Apply default layer actions to all selected layers (fixes #9714)
2 parents b64ebfb + bca8356 commit 4ca81ba

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/gui/layertree/qgslayertreeviewdefaultactions.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ void QgsLayerTreeViewDefaultActions::showInOverview()
152152
QgsLayerTreeNode* node = mView->currentNode();
153153
if ( !node )
154154
return;
155-
156-
node->setCustomProperty( "overview", node->customProperty( "overview", 0 ).toInt() ? 0 : 1 );
155+
int newValue = node->customProperty( "overview", 0 ).toInt();
156+
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
157+
l->setCustomProperty( "overview", newValue ? 0 : 1 );
157158
}
158159

159160
void QgsLayerTreeViewDefaultActions::showFeatureCount()
@@ -162,8 +163,9 @@ void QgsLayerTreeViewDefaultActions::showFeatureCount()
162163
if ( !QgsLayerTree::isLayer( node ) )
163164
return;
164165

165-
166-
node->setCustomProperty( "showFeatureCount", node->customProperty( "showFeatureCount", 0 ).toInt() ? 0 : 1 );
166+
int newValue = node->customProperty( "showFeatureCount", 0 ).toInt();
167+
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
168+
l->setCustomProperty( "showFeatureCount", newValue ? 0 : 1 );
167169
}
168170

169171

@@ -263,18 +265,16 @@ QString QgsLayerTreeViewDefaultActions::uniqueGroupName( QgsLayerTreeGroup* pare
263265

264266
void QgsLayerTreeViewDefaultActions::makeTopLevel()
265267
{
266-
QgsLayerTreeNode* node = mView->currentNode();
267-
if ( !node )
268-
return;
269-
270-
QgsLayerTreeGroup* rootGroup = mView->layerTreeModel()->rootGroup();
271-
QgsLayerTreeGroup* parentGroup = qobject_cast<QgsLayerTreeGroup*>( node->parent() );
272-
if ( !parentGroup || parentGroup == rootGroup )
273-
return;
274-
275-
QgsLayerTreeNode* clonedNode = node->clone();
276-
rootGroup->addChildNode( clonedNode );
277-
parentGroup->removeChildNode( node );
268+
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
269+
{
270+
QgsLayerTreeGroup* rootGroup = mView->layerTreeModel()->rootGroup();
271+
QgsLayerTreeGroup* parentGroup = qobject_cast<QgsLayerTreeGroup*>( l->parent() );
272+
if ( !parentGroup || parentGroup == rootGroup )
273+
continue;
274+
QgsLayerTreeLayer* clonedLayer = l->clone();
275+
rootGroup->addChildNode( clonedLayer );
276+
parentGroup->removeChildNode( l );
277+
}
278278
}
279279

280280

0 commit comments

Comments
 (0)