Skip to content

Commit

Permalink
Save and restore legend patch shape for QgsLayerTreeLayer nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 10, 2020
1 parent b920e35 commit 8c94c9d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/layertree/qgslayertreelayer.cpp
Expand Up @@ -121,6 +121,15 @@ QgsLayerTreeLayer *QgsLayerTreeLayer::readXml( QDomElement &element, const QgsRe
nodeLayer->setItemVisibilityChecked( checked != Qt::Unchecked );
nodeLayer->setExpanded( isExpanded );
nodeLayer->setLabelExpression( labelExpression );

const QDomElement patchElem = element.firstChildElement( QStringLiteral( "patch" ) );
if ( !patchElem.isNull() )
{
QgsLegendPatchShape patch;
patch.readXml( patchElem, context );
nodeLayer->setPatchShape( patch );
}

return nodeLayer;
}

Expand Down Expand Up @@ -148,6 +157,14 @@ void QgsLayerTreeLayer::writeXml( QDomElement &parentElement, const QgsReadWrite
elem.setAttribute( QStringLiteral( "checked" ), mChecked ? QStringLiteral( "Qt::Checked" ) : QStringLiteral( "Qt::Unchecked" ) );
elem.setAttribute( QStringLiteral( "expanded" ), mExpanded ? "1" : "0" );
elem.setAttribute( QStringLiteral( "legend_exp" ), mLabelExpression );

if ( !mPatchShape.isNull() )
{
QDomElement patchElem = doc.createElement( QStringLiteral( "patch" ) );
mPatchShape.writeXml( patchElem, doc, context );
elem.appendChild( patchElem );
}

writeCommonXml( elem );

parentElement.appendChild( elem );
Expand Down

0 comments on commit 8c94c9d

Please sign in to comment.