[afs] Fix group layers are incorrectly shown in browser

These layers cannot be opened so should be skipped

Fixes #18886
This commit is contained in:
Nyall Dawson 2018-05-01 08:52:41 +10:00
parent 313970de79
commit c63260e109

View File

@ -95,18 +95,25 @@ QVector<QgsDataItem *> QgsAfsConnectionItem::createChildren()
{
QVector<QgsDataItem *> layers;
QString errorTitle, errorMessage;
QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
const QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
if ( serviceData.isEmpty() )
{
return layers;
}
QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData[QStringLiteral( "spatialReference" )].toMap() ).authid();
const QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData.value( QStringLiteral( "spatialReference" ) ).toMap() ).authid();
foreach ( const QVariant &layerInfo, serviceData["layers"].toList() )
const QVariantList layerInfoList = serviceData[QStringLiteral( "layers" )].toList();
for ( const QVariant &layerInfo : layerInfoList )
{
QVariantMap layerInfoMap = layerInfo.toMap();
QString id = layerInfoMap[QStringLiteral( "id" )].toString();
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap[QStringLiteral( "name" )].toString(), authid );
const QVariantMap layerInfoMap = layerInfo.toMap();
if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
{
// group layer - do not show as it is not possible to load
// TODO - show nested groups
continue;
}
const QString id = layerInfoMap.value( QStringLiteral( "id" ) ).toString();
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap.value( QStringLiteral( "name" ) ).toString(), authid );
layers.append( layer );
}