support relative paths for gpx datasources (fixes #11131)

This commit is contained in:
Juergen E. Fischer 2014-10-26 15:14:43 +01:00
parent c8a76f8c5c
commit e1ff0edfba

View File

@ -191,6 +191,12 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] ); theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
mDataSource = theURIParts.join( "|" ); mDataSource = theURIParts.join( "|" );
} }
else if ( provider == "gpx" )
{
QStringList theURIParts = mDataSource.split( "?" );
theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] );
mDataSource = theURIParts.join( "?" );
}
else if ( provider == "delimitedtext" ) else if ( provider == "delimitedtext" )
{ {
QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() ); QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() );
@ -466,6 +472,12 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath ); theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath );
src = theURIParts.join( "|" ); src = theURIParts.join( "|" );
} }
else if ( vlayer && vlayer->providerType() == "gpx" )
{
QStringList theURIParts = src.split( "?" );
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0], relativeBasePath );
src = theURIParts.join( "?" );
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" ) else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{ {
QUrl urlSource = QUrl::fromEncoded( src.toAscii() ); QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
@ -1066,6 +1078,11 @@ QString QgsMapLayer::saveNamedStyle( const QString &theURI, bool &theResultFlag
QStringList theURIParts = theURI.split( "|" ); QStringList theURIParts = theURI.split( "|" );
filename = theURIParts[0]; filename = theURIParts[0];
} }
else if ( vlayer && vlayer->providerType() == "gpx" )
{
QStringList theURIParts = theURI.split( "?" );
filename = theURIParts[0];
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" ) else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{ {
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile(); filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
@ -1244,6 +1261,11 @@ QString QgsMapLayer::saveSldStyle( const QString &theURI, bool &theResultFlag )
QStringList theURIParts = theURI.split( "|" ); QStringList theURIParts = theURI.split( "|" );
filename = theURIParts[0]; filename = theURIParts[0];
} }
else if ( vlayer->providerType() == "gpx" )
{
QStringList theURIParts = theURI.split( "?" );
filename = theURIParts[0];
}
else if ( vlayer->providerType() == "delimitedtext" ) else if ( vlayer->providerType() == "delimitedtext" )
{ {
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile(); filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();