Skip to content

Commit

Permalink
Merge pull request #2576 from SebDieBln/DefaultLayerActions_on_select…
Browse files Browse the repository at this point in the history
…ed_layers

Apply default layer actions to all selected layers (fixes #9714)
  • Loading branch information
NathanW2 committed Dec 14, 2015
2 parents b64ebfb + bca8356 commit 4ca81ba
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/gui/layertree/qgslayertreeviewdefaultactions.cpp
Expand Up @@ -152,8 +152,9 @@ void QgsLayerTreeViewDefaultActions::showInOverview()
QgsLayerTreeNode* node = mView->currentNode();
if ( !node )
return;

node->setCustomProperty( "overview", node->customProperty( "overview", 0 ).toInt() ? 0 : 1 );
int newValue = node->customProperty( "overview", 0 ).toInt();
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
l->setCustomProperty( "overview", newValue ? 0 : 1 );
}

void QgsLayerTreeViewDefaultActions::showFeatureCount()
Expand All @@ -162,8 +163,9 @@ void QgsLayerTreeViewDefaultActions::showFeatureCount()
if ( !QgsLayerTree::isLayer( node ) )
return;


node->setCustomProperty( "showFeatureCount", node->customProperty( "showFeatureCount", 0 ).toInt() ? 0 : 1 );
int newValue = node->customProperty( "showFeatureCount", 0 ).toInt();
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
l->setCustomProperty( "showFeatureCount", newValue ? 0 : 1 );
}


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

void QgsLayerTreeViewDefaultActions::makeTopLevel()
{
QgsLayerTreeNode* node = mView->currentNode();
if ( !node )
return;

QgsLayerTreeGroup* rootGroup = mView->layerTreeModel()->rootGroup();
QgsLayerTreeGroup* parentGroup = qobject_cast<QgsLayerTreeGroup*>( node->parent() );
if ( !parentGroup || parentGroup == rootGroup )
return;

QgsLayerTreeNode* clonedNode = node->clone();
rootGroup->addChildNode( clonedNode );
parentGroup->removeChildNode( node );
Q_FOREACH ( QgsLayerTreeLayer* l, mView->selectedLayerNodes() )
{
QgsLayerTreeGroup* rootGroup = mView->layerTreeModel()->rootGroup();
QgsLayerTreeGroup* parentGroup = qobject_cast<QgsLayerTreeGroup*>( l->parent() );
if ( !parentGroup || parentGroup == rootGroup )
continue;
QgsLayerTreeLayer* clonedLayer = l->clone();
rootGroup->addChildNode( clonedLayer );
parentGroup->removeChildNode( l );
}
}


Expand Down

0 comments on commit 4ca81ba

Please sign in to comment.