Skip to content

Commit

Permalink
QgsAppLayerHandling::addSublayers(): avoid prefixing layer name with …
Browse files Browse the repository at this point in the history
…basename if it starts with basename

Adresses #51144 (comment)
  • Loading branch information
rouault committed Jan 3, 2023
1 parent a5f28d0 commit 0175806
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/app/layers/qgsapplayerhandling.cpp
Expand Up @@ -728,8 +728,11 @@ QList<QgsMapLayer *> QgsAppLayerHandling::addSublayers( const QList<QgsProviderS
}
else
{
if ( layerName != baseName && !layerName.isEmpty() && !baseName.isEmpty() )
if ( layerName != baseName && !layerName.isEmpty() && !baseName.isEmpty() &&
!layerName.startsWith( baseName ) )
{
layer->setName( QStringLiteral( "%1 — %2" ).arg( baseName, layerName ) );
}
else if ( !layerName.isEmpty() )
layer->setName( layerName );
else if ( !baseName.isEmpty() )
Expand Down
7 changes: 1 addition & 6 deletions src/gui/qgsprovidersublayersdialog.cpp
Expand Up @@ -123,12 +123,7 @@ QgsProviderSublayersDialog::QgsProviderSublayersDialog( const QString &uri, cons

if ( !fileName.isEmpty() )
{
mGroupName = fileName;
const QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
mGroupName = QgsMapLayer::formatLayerName( mGroupName );
}
setGroupName( fileName );
}

setWindowTitle( fileName.isEmpty() ? tr( "Select Items to Add" ) : QStringLiteral( "%1 | %2" ).arg( tr( "Select Items to Add" ), fileName ) );
Expand Down

0 comments on commit 0175806

Please sign in to comment.