Skip to content

Commit 9076e64

Browse files
committedJun 28, 2021
If all layer names are the same, remove them from the sub layer uris
1 parent 6a0497f commit 9076e64

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎src/core/providers/ogr/qgsogrprovidermetadata.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,26 @@ QList<QgsProviderSublayerDetails> QgsOgrProviderMetadata::querySublayers( const
10771077

10781078
res << QgsOgrProviderUtils::querySubLayerList( i, i == 0 ? firstLayer.get() : layer.get(), driverName, flags, false, uri, false, feedback );
10791079
}
1080+
1081+
// if all layernames are equal, we remove them from the uris
1082+
QSet< QString > layerNames;
1083+
for ( const QgsProviderSublayerDetails &details : std::as_const( res ) )
1084+
{
1085+
const QVariantMap parts = decodeUri( details.uri() );
1086+
layerNames.insert( parts.value( QStringLiteral( "layerName" ) ).toString() );
1087+
}
1088+
1089+
if ( layerNames.count() == 1 )
1090+
{
1091+
// all layer names are the same, so remove them from uris
1092+
for ( int i = 0; i < res.size(); ++i )
1093+
{
1094+
QVariantMap parts = decodeUri( res.at( i ).uri() );
1095+
parts.remove( QStringLiteral( "layerName" ) );
1096+
res[ i ].setUri( encodeUri( parts ) );
1097+
}
1098+
}
1099+
10801100
return res;
10811101
}
10821102
}

0 commit comments

Comments
 (0)
Please sign in to comment.