Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76104b5

Browse files
committedMay 24, 2019
load style from the QML file with the same name as layer file name
for GeoPackages, CSV and SpatiaLite (fix #21691)
1 parent a888986 commit 76104b5

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed
 

‎src/core/qgsmaplayer.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -799,24 +799,15 @@ QString QgsMapLayer::baseURI( PropertyType type ) const
799799
{
800800
QString myURI = publicSource();
801801

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

822813
QFileInfo myFileInfo( myURI );

0 commit comments

Comments
 (0)
Please sign in to comment.