Skip to content
Permalink
Browse files
If all layer names are the same, remove them from the sub layer uris
  • Loading branch information
nyalldawson committed Jun 28, 2021
1 parent 6a0497f commit 9076e64afb7910eb526543e4f33f3935602a5c16
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/core/providers/ogr/qgsogrprovidermetadata.cpp
@@ -1077,6 +1077,26 @@ QList<QgsProviderSublayerDetails> QgsOgrProviderMetadata::querySublayers( const

res << QgsOgrProviderUtils::querySubLayerList( i, i == 0 ? firstLayer.get() : layer.get(), driverName, flags, false, uri, false, feedback );
}

// if all layernames are equal, we remove them from the uris
QSet< QString > layerNames;
for ( const QgsProviderSublayerDetails &details : std::as_const( res ) )
{
const QVariantMap parts = decodeUri( details.uri() );
layerNames.insert( parts.value( QStringLiteral( "layerName" ) ).toString() );
}

if ( layerNames.count() == 1 )
{
// all layer names are the same, so remove them from uris
for ( int i = 0; i < res.size(); ++i )
{
QVariantMap parts = decodeUri( res.at( i ).uri() );
parts.remove( QStringLiteral( "layerName" ) );
res[ i ].setUri( encodeUri( parts ) );
}
}

return res;
}
}

0 comments on commit 9076e64

Please sign in to comment.