Skip to content

Commit

Permalink
Merge pull request #4580 from alexbruy/layer-naming-2_18
Browse files Browse the repository at this point in the history
homogenize layer naming when adding layers from browser and add vector dialog (fix #15510)
  • Loading branch information
alexbruy authored May 19, 2017
2 parents 3cc9c5f + c849bc8 commit cc6f6e8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9307,6 +9307,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;
QgsMapLayerRegistry::instance()->addMapLayers( myList );
bool ok;
Expand Down

0 comments on commit cc6f6e8

Please sign in to comment.