Skip to content
Permalink
Browse files

Fix for accessing groups in mapserver

git-svn-id: http://svn.osgeo.org/qgis/trunk@15069 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jan 24, 2011
1 parent 0a76ab4 commit e7043c40e57e74a72de791b4679831e01c00417a
Showing with 31 additions and 7 deletions.
  1. +29 −7 src/mapserver/qgsprojectparser.cpp
  2. +2 −0 src/mapserver/qgsprojectparser.h
@@ -310,23 +310,24 @@ QList<QgsMapLayer*> QgsProjectParser::mapLayerFromStyle( const QString& lName, c
//maybe the layer is a goup. Check if lName is contained in the group list
QMap< QString, QDomElement > idLayerMap = projectLayerElementsById();

QList< GroupLayerInfo > groupInfo = groupLayerRelationshipFromProject();
QList< GroupLayerInfo >::const_iterator groupIt = groupInfo.constBegin();
for ( ; groupIt != groupInfo.constEnd(); ++groupIt )
QList<QDomElement> legendGroups = legendGroupElements();
QList<QDomElement>::const_iterator groupIt = legendGroups.constBegin();
for ( ; groupIt != legendGroups.constEnd(); ++groupIt )
{
if ( groupIt->first == lName )
if ( groupIt->attribute( "name" ) == lName )
{
QList< QString >::const_iterator layerIdIt = groupIt->second.constBegin();
for ( ; layerIdIt != groupIt->second.constEnd(); ++layerIdIt )
QDomNodeList layerFileList = groupIt->elementsByTagName( "legendlayerfile" );
for ( int i = 0; i < layerFileList.size(); ++i )
{
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( *layerIdIt );
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( layerFileList.at( i ).toElement().attribute( "layerid" ) );
if ( layerEntry != idLayerMap.constEnd() )
{
layerList.push_back( createLayerFromElement( layerEntry.value() ) );
}
}
}
}

return layerList;
}

@@ -609,6 +610,27 @@ QList<QDomElement> QgsProjectParser::projectLayerElements() const
return layerElemList;
}

QList<QDomElement> QgsProjectParser::legendGroupElements() const
{
QList<QDomElement> groupList;
if ( !mXMLDoc )
{
return groupList;
}

QDomElement legendElement = mXMLDoc->documentElement().firstChildElement( "legend" );
if ( legendElement.isNull() )
{
return groupList;
}

QDomNodeList groupNodeList = legendElement.elementsByTagName( "legendgroup" );
for ( int i = 0; i < groupNodeList.size(); ++i )
{
groupList.push_back( groupNodeList.at( i ).toElement() );
}
}

QMap< QString, QDomElement > QgsProjectParser::projectLayerElementsById() const
{
QMap< QString, QDomElement > layerMap;
@@ -102,6 +102,8 @@ class QgsProjectParser: public QgsConfigParser

/**Get all layers of the project (ordered same as in the project file)*/
QList<QDomElement> projectLayerElements() const;
/**Returns all legend group elements*/
QList<QDomElement> legendGroupElements() const;
/**Get all layers of the project, accessible by layer id*/
QMap< QString, QDomElement > projectLayerElementsById() const;
/**Get all layers of the project, accessible by layer name*/

0 comments on commit e7043c4

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