Skip to content

Commit 2d0b167

Browse files
author
mhugent
committed
Consider toplevel group in mapserver
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14250 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e008053 commit 2d0b167

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

src/mapserver/qgsprojectparser.cpp

+30-15
Original file line numberDiff line numberDiff line change
@@ -260,30 +260,45 @@ QList<QgsMapLayer*> QgsProjectParser::mapLayerFromStyle( const QString& lName, c
260260
layerFound = true;
261261
}
262262

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

268-
QList< GroupLayerInfo > groupInfo = groupLayerRelationshipFromProject();
269-
QList< GroupLayerInfo >::const_iterator groupIt = groupInfo.constBegin();
270-
for ( ; groupIt != groupInfo.constEnd(); ++groupIt )
268+
//Check if layer name refers to the top level group for the project.
269+
//The project group is not contained in the groupLayerRelationship list
270+
//because the list (and the qgis legend) does not support nested groups
271+
if ( lName == projectTitle() )
272+
{
273+
QList<QDomElement> layerElemList = projectLayerElements();
274+
QList<QDomElement>::const_iterator layerElemIt = layerElemList.constBegin();
275+
for ( ; layerElemIt != layerElemList.constEnd(); ++layerElemIt )
271276
{
272-
if ( groupIt->first == lName )
277+
layerList.push_back( createLayerFromElement( *layerElemIt ) );
278+
}
279+
return layerList;
280+
}
281+
282+
//maybe the layer is a goup. Check if lName is contained in the group list
283+
QMap< QString, QDomElement > idLayerMap = projectLayerElementsById();
284+
285+
QList< GroupLayerInfo > groupInfo = groupLayerRelationshipFromProject();
286+
QList< GroupLayerInfo >::const_iterator groupIt = groupInfo.constBegin();
287+
for ( ; groupIt != groupInfo.constEnd(); ++groupIt )
288+
{
289+
if ( groupIt->first == lName )
290+
{
291+
QList< QString >::const_iterator layerIdIt = groupIt->second.constBegin();
292+
for ( ; layerIdIt != groupIt->second.constEnd(); ++layerIdIt )
273293
{
274-
QList< QString >::const_iterator layerIdIt = groupIt->second.constBegin();
275-
for ( ; layerIdIt != groupIt->second.constEnd(); ++layerIdIt )
294+
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( *layerIdIt );
295+
if ( layerEntry != idLayerMap.constEnd() )
276296
{
277-
QMap< QString, QDomElement >::const_iterator layerEntry = idLayerMap.find( *layerIdIt );
278-
if ( layerEntry != idLayerMap.constEnd() )
279-
{
280-
layerList.push_back( createLayerFromElement( layerEntry.value() ) );
281-
}
297+
layerList.push_back( createLayerFromElement( layerEntry.value() ) );
282298
}
283299
}
284300
}
285301
}
286-
287302
return layerList;
288303
}
289304

0 commit comments

Comments
 (0)