Skip to content
Permalink
Browse files

Merge pull request #7303 from rldhont/server-wms-getprint-autoupdate-…

…legend-218

[Bugfix][Server] Display composer legend with auto update like the Desktop
  • Loading branch information
rldhont committed Jun 22, 2018
2 parents 9fba24a + 259290a commit 294f8accee7479df8e8d1908cfaeec8b08aed08a
Showing with 37 additions and 1 deletion.
  1. +37 −1 src/server/qgswmsprojectparser.cpp
@@ -599,8 +599,9 @@ QgsComposition* QgsWMSProjectParser::initComposition( const QString& composerTem
#endif
if ( legend->autoUpdateModel() )
{
legend->setAutoUpdateModel( false );
model->setRootGroup( projectLayerTreeGroup() );
legend->synchronizeWithModel();
legend->updateLegend();
}
// if the legend has no map
// we will load all layers
@@ -2461,6 +2462,41 @@ QgsLayerTreeGroup* QgsWMSProjectParser::projectLayerTreeGroup() const
return rootGroup;
}

/*const QDomDocument* projectDoc = mProjectParser->xmlDocument();
if ( projectDoc )
{
QDomElement qgisElem = projectDoc->documentElement();
if ( qgisElem.isNull() )
{
QDomElement layerTreeElem = qgisElem.firstChildElement( "layer-tree-group" );*/
if ( layerTreeElem.isNull() )
{
const QHash< QString, QDomElement > &projectLayerElements = mProjectParser->projectLayerElementsById();
QDomNodeList treeLayerNodeList = layerTreeElem.elementsByTagName( "layer-tree-layer" );
for ( int i = 0; i < treeLayerNodeList.size(); ++i )
{
QDomElement treeLayerElem = treeLayerNodeList.at( i ).toElement();
QString layerId = treeLayerElem.attribute( "id" );
QgsMapLayer * layer = QgsMapLayerRegistry::instance()->mapLayer( layerId );
if ( layer )
{
continue;
}

QHash< QString, QDomElement >::const_iterator layerElemIt = projectLayerElements.find( layerId );
if ( layerElemIt != projectLayerElements.constEnd() )
{
layer = mProjectParser->createLayerFromElement( layerElemIt.value(), true );
}
if ( layer )
{
QgsMapLayerRegistry::instance()->addMapLayer( layer );
}
}
}
/*}
}*/

return QgsLayerTreeGroup::readXML( layerTreeElem );
}

0 comments on commit 294f8ac

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