Skip to content
Permalink
Browse files

Apply default layer actions to all selected layers (fixes #9714)

the affected actions are:
- show feature count
- show in overview
- make top level
  • Loading branch information
SebDieBln committed Dec 3, 2015
1 parent 262514d commit bca8356ea035367573d6d0f6c9fac2c24058e6e5
Showing with 16 additions and 16 deletions.
  1. +16 −16 src/gui/layertree/qgslayertreeviewdefaultactions.cpp
@@ -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()
@@ -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 );
}


@@ -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 );
}
}


0 comments on commit bca8356

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