Skip to content

Commit fdafd68

Browse files
committed
[afs] Fix group layers are incorrectly shown in browser
These layers cannot be opened so should be skipped Fixes #18886 (cherry-picked from c63260e)
1 parent 4962953 commit fdafd68

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/providers/arcgisrest/qgsafsdataitems.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,25 @@ QVector<QgsDataItem *> QgsAfsConnectionItem::createChildren()
9595
{
9696
QVector<QgsDataItem *> layers;
9797
QString errorTitle, errorMessage;
98-
QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
98+
const QVariantMap serviceData = QgsArcGisRestUtils::getServiceInfo( mUrl, errorTitle, errorMessage );
9999
if ( serviceData.isEmpty() )
100100
{
101101
return layers;
102102
}
103-
QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData[QStringLiteral( "spatialReference" )].toMap() ).authid();
103+
const QString authid = QgsArcGisRestUtils::parseSpatialReference( serviceData.value( QStringLiteral( "spatialReference" ) ).toMap() ).authid();
104104

105-
foreach ( const QVariant &layerInfo, serviceData["layers"].toList() )
105+
const QVariantList layerInfoList = serviceData[QStringLiteral( "layers" )].toList();
106+
for ( const QVariant &layerInfo : layerInfoList )
106107
{
107-
QVariantMap layerInfoMap = layerInfo.toMap();
108-
QString id = layerInfoMap[QStringLiteral( "id" )].toString();
109-
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap[QStringLiteral( "name" )].toString(), authid );
108+
const QVariantMap layerInfoMap = layerInfo.toMap();
109+
if ( !layerInfoMap.value( QStringLiteral( "subLayerIds" ) ).toList().empty() )
110+
{
111+
// group layer - do not show as it is not possible to load
112+
// TODO - show nested groups
113+
continue;
114+
}
115+
const QString id = layerInfoMap.value( QStringLiteral( "id" ) ).toString();
116+
QgsAfsLayerItem *layer = new QgsAfsLayerItem( this, mName, mUrl + "/" + id, layerInfoMap.value( QStringLiteral( "name" ) ).toString(), authid );
110117
layers.append( layer );
111118
}
112119

0 commit comments

Comments
 (0)