Skip to content

Commit

Permalink
Respect the overridden layer name in composer legend also in rendered…
Browse files Browse the repository at this point in the history
… legend
  • Loading branch information
wonder-sk committed Sep 5, 2014
1 parent 36467e9 commit e2f1ceb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/app/composer/qgscomposerlegendwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ void QgsComposerLegendWidget::on_mEditPushButton_clicked()
else if ( QgsLayerTree::isLayer( currentNode ) )
{
currentNode->setCustomProperty( "legend/title-label", newText );

// force update of label of the legend node with embedded icon (a bit clumsy i know)
QList<QgsLayerTreeModelLegendNode*> nodes = model->layerLegendNodes( QgsLayerTree::toLayer( currentNode ) );
if ( nodes.count() == 1 && nodes[0]->isEmbeddedInParent() )
nodes[0]->setUserLabel( QString() );
}
else if ( legendNode )
{
Expand Down
6 changes: 5 additions & 1 deletion src/core/layertree/qgslayertreemodellegendnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,11 @@ void QgsSymbolV2LegendNode::updateLabel()

if ( mEmbeddedInParent )
{
mLabel = mUserLabel.isEmpty() ? mLayerNode->layerName() : mUserLabel;
QString layerName = mLayerNode->layerName();
if ( !mLayerNode->customProperty( "legend/title-label" ).isNull() )
layerName = mLayerNode->customProperty( "legend/title-label" ).toString();

mLabel = mUserLabel.isEmpty() ? layerName : mUserLabel;
if ( showFeatureCount && vl && vl->pendingFeatureCount() >= 0 )
mLabel += QString( " [%1]" ).arg( vl->pendingFeatureCount() );
}
Expand Down

0 comments on commit e2f1ceb

Please sign in to comment.