Skip to content

Commit

Permalink
load style from the QML file with the same name as layer file name
Browse files Browse the repository at this point in the history
for GeoPackages, CSV and SpatiaLite (fix #21691)
  • Loading branch information
alexbruy authored and nyalldawson committed May 27, 2019
1 parent b38e1a9 commit 6d5fa2e
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,24 +799,15 @@ QString QgsMapLayer::baseURI( PropertyType type ) const
{
QString myURI = publicSource();

// if file is using the VSIFILE mechanism, remove the prefix
if ( myURI.startsWith( QLatin1String( "/vsigzip/" ), Qt::CaseInsensitive ) )
{
myURI.remove( 0, 9 );
}
else if ( myURI.startsWith( QLatin1String( "/vsizip/" ), Qt::CaseInsensitive ) &&
myURI.endsWith( QLatin1String( ".zip" ), Qt::CaseInsensitive ) )
{
// ideally we should look for .qml file inside zip file
myURI.remove( 0, 8 );
}
else if ( myURI.startsWith( QLatin1String( "/vsitar/" ), Qt::CaseInsensitive ) &&
( myURI.endsWith( QLatin1String( ".tar" ), Qt::CaseInsensitive ) ||
myURI.endsWith( QLatin1String( ".tar.gz" ), Qt::CaseInsensitive ) ||
myURI.endsWith( QLatin1String( ".tgz" ), Qt::CaseInsensitive ) ) )
{
// ideally we should look for .qml file inside tar file
myURI.remove( 0, 8 );
// first get base path for delimited text, spatialite and OGR layers,
// as in these cases URI may contain layer name and/or additional
// information. This also strips prefix in case if VSIFILE mechanism
// is used
if ( providerType() == QLatin1String( "ogr" ) || providerType() == QLatin1String( "delimitedtext" ) ||
providerType() == QLatin1String( "spatialite" ) )
{
QVariantMap components = QgsProviderRegistry::instance()->decodeUri( providerType(), myURI );
myURI = components["path"].toString();
}

QFileInfo myFileInfo( myURI );
Expand Down

0 comments on commit 6d5fa2e

Please sign in to comment.