Skip to content

Commit

Permalink
If all layer names are the same, remove them from the sub layer uris
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 28, 2021
1 parent 6a0497f commit 9076e64
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/providers/ogr/qgsogrprovidermetadata.cpp
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 9076e64

Please sign in to comment.