Skip to content
Permalink
Browse files

Merge pull request #2575 from slarosa/style_grp_layers

[FEATURE] allow applying the same style to selected layers or to legend group
  • Loading branch information
nyalldawson committed Dec 13, 2015
2 parents 262514d + f0aeee8 commit 2d9f36100e70f774455910ca851accde96e1d3f9
Showing with 41 additions and 0 deletions.
  1. +26 −0 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgisapp.h
  3. +12 −0 src/app/qgsapplayertreeviewmenuprovider.cpp
@@ -7746,7 +7746,33 @@ void QgisApp::legendLayerStretchUsingCurrentExtent()
}
}

void QgisApp::applyStyleToGroup()
{
if ( !mLayerTreeView )
return;

Q_FOREACH ( QgsLayerTreeNode* node, mLayerTreeView->selectedNodes() )
{
if ( QgsLayerTree::isGroup( node ) )
{
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, QgsLayerTree::toGroup( node )->findLayers() )
{
if ( nodeLayer->layer() )
{
pasteStyle( nodeLayer->layer() );
}
}
}
else if ( QgsLayerTree::isLayer( node ) )
{
QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node );
if ( nodeLayer->layer() )
{
pasteStyle( nodeLayer->layer() );
}
}
}
}

void QgisApp::legendGroupSetCRS()
{
@@ -748,6 +748,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
Only workds on raster layers*/
void legendLayerStretchUsingCurrentExtent();

/** Apply the same style to selected layers or to current legend group*/
void applyStyleToGroup();

/** Set the CRS of the current legend group*/
void legendGroupSetCRS();

@@ -66,6 +66,11 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
if ( mView->selectedNodes( true ).count() >= 2 )
menu->addAction( actions->actionGroupSelected( menu ) );

if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
{
menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) );
}

menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) );

menu->addAction( actions->actionAddGroup( menu ) );
@@ -121,6 +126,13 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()

menu->addMenu( menuStyleManager );
}
else
{
if ( QgisApp::instance()->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
{
menu->addAction( tr( "Paste Style" ), QgisApp::instance(), SLOT( applyStyleToGroup() ) );
}
}

menu->addSeparator();

0 comments on commit 2d9f361

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