Skip to content
Permalink
Browse files

Handle 'inbuilt:' vector uri in iface.addVectorLayer() method

  • Loading branch information
rduivenvoorde committed Oct 29, 2020
1 parent cfbb292 commit 1132494fcb679e814857d5cf7fa4f1712b52f5e1
Showing with 10 additions and 2 deletions.
  1. +9 −1 src/app/qgisapp.cpp
  2. +1 −1 src/app/qgisapp.h
@@ -12900,7 +12900,15 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
// Default style is loaded later in this method
options.loadDefaultStyle = false;
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey, options );

QVariantMap uriElements = QgsProviderRegistry::instance()->decodeUri( providerKey, vectorLayerPath );
if ( uriElements.contains( QStringLiteral( "path" ) ) )
{
// run layer path through QgsPathResolver so that all inbuilt paths and other localised paths are correctly expanded
uriElements[ QStringLiteral( "path" ) ] = QgsPathResolver().readPath( uriElements.value( QStringLiteral( "path" ) ).toString() );
}
const QString updatedUri = QgsProviderRegistry::instance()->encodeUri( providerKey, uriElements );
QgsVectorLayer *layer = new QgsVectorLayer( updatedUri, baseName, providerKey, options );

if ( authok && layer->isValid() )
{
@@ -2100,7 +2100,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Open a vector tile layer - this is the generic function which takes all parameters
QgsVectorTileLayer *addVectorTileLayerPrivate( const QString &uri, const QString &baseName, bool guiWarning = true );

//! Open a point cloyd layer - this is the generic function which takes all parameters
//! Open a point cloud layer - this is the generic function which takes all parameters
QgsPointCloudLayer *addPointCloudLayerPrivate( const QString &uri,
const QString &baseName,
const QString &providerKey,

0 comments on commit 1132494

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