Skip to content

Commit

Permalink
Merge pull request #7303 from rldhont/server-wms-getprint-autoupdate-…
Browse files Browse the repository at this point in the history
…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 294f8ac
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/server/qgswmsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit 294f8ac

Please sign in to comment.