Skip to content
Permalink
Browse files
Consider toplevel group in mapserver
git-svn-id: http://svn.osgeo.org/qgis/trunk@14250 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Sep 19, 2010
1 parent e83886e commit 21c79de762a439f3b7738497f0382fafd03086d5
Showing with 30 additions and 15 deletions.
  1. +30 −15 src/mapserver/qgsprojectparser.cpp
@@ -260,30 +260,45 @@ QList<QgsMapLayer*> QgsProjectParser::mapLayerFromStyle( const QString& lName, c
layerFound = true;
}

//maybe the layer is a goup. Check if lName is contained in the group list
if ( !layerFound )
if ( layerFound )
{
QMap< QString, QDomElement > idLayerMap = projectLayerElementsById();
return layerList;
}

QList< GroupLayerInfo > groupInfo = groupLayerRelationshipFromProject();
QList< GroupLayerInfo >::const_iterator groupIt = groupInfo.constBegin();
for ( ; groupIt != groupInfo.constEnd(); ++groupIt )
//Check if layer name refers to the top level group for the project.
//The project group is not contained in the groupLayerRelationship list
//because the list (and the qgis legend) does not support nested groups
if ( lName == projectTitle() )
{
QList<QDomElement> layerElemList = projectLayerElements();
QList<QDomElement>::const_iterator layerElemIt = layerElemList.constBegin();
for ( ; layerElemIt != layerElemList.constEnd(); ++layerElemIt )
{
if ( groupIt->first == lName )
layerList.push_back( createLayerFromElement( *layerElemIt ) );
}
return layerList;
}

//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 )
{
if ( groupIt->first == lName )
{
QList< QString >::const_iterator layerIdIt = groupIt->second.constBegin();
for ( ; layerIdIt != groupIt->second.constEnd(); ++layerIdIt )
{
QList< QString >::const_iterator layerIdIt = groupIt->second.constBegin();
for ( ; layerIdIt != groupIt->second.constEnd(); ++layerIdIt )
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( *layerIdIt );
if ( layerEntry != idLayerMap.constEnd() )
{
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( *layerIdIt );
if ( layerEntry != idLayerMap.constEnd() )
{
layerList.push_back( createLayerFromElement( layerEntry.value() ) );
}
layerList.push_back( createLayerFromElement( layerEntry.value() ) );
}
}
}
}

return layerList;
}

0 comments on commit 21c79de

Please sign in to comment.