Skip to content
Permalink
Browse files

Merge pull request #4579 from alexbruy/layer-naming

homogenize layer naming when adding via browser and add vector dialog (fix #15510)
  • Loading branch information
alexbruy committed May 19, 2017
2 parents 95ac7d0 + e0a2267 commit d7b952b4c04e33650f45e4371bda317ab270559d
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/app/qgisapp.cpp
@@ -9857,6 +9857,17 @@ QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const Q
{
// Register this layer with the layers registry
QList<QgsMapLayer *> myList;

//set friendly name for datasources with only one layer
QStringList sublayers = layer->dataProvider()->subLayers();
QStringList elements = sublayers.at( 0 ).split( ':' );

Q_ASSERT( elements.size() >= 4 );
if ( layer->name() != elements.at( 1 ) )
{
layer->setName( QStringLiteral( "%1 %2 %3" ).arg( layer->name(), elements.at( 1 ), elements.at( 3 ) ) );
}

myList << layer;
QgsProject::instance()->addMapLayers( myList );
bool ok;

0 comments on commit d7b952b

Please sign in to comment.
You can’t perform that action at this time.