Skip to content

Commit cbf1bc2

Browse files
author
jef
committed
update old delimited text provider datasources on load
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15437 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 16261f2 commit cbf1bc2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/core/qgsmaplayer.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
179179
else if ( provider == "delimitedtext" )
180180
{
181181
QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() );
182+
183+
if ( !mDataSource.startsWith( "file://" ) )
184+
{
185+
QUrl file = QUrl::fromLocalFile( mDataSource.left( mDataSource.indexOf( "?" ) ) );
186+
urlSource.setScheme( "file" );
187+
urlSource.setPath( file.path() );
188+
}
189+
182190
QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->readPath( urlSource.toLocalFile() ) );
183191
urlDest.setQueryItems( urlSource.queryItems() );
184192
mDataSource = QString::fromAscii( urlDest.toEncoded() );
@@ -309,9 +317,10 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
309317
}
310318
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
311319
{
312-
QStringList theURIParts = src.split( "?" );
313-
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0] );
314-
src = theURIParts.join( "?" );
320+
QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
321+
QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->writePath( urlSource.toLocalFile() ) );
322+
urlDest.setQueryItems( urlSource.queryItems() );
323+
src = QString::fromAscii( urlDest.toEncoded() );
315324
}
316325
else
317326
{
@@ -678,8 +687,7 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag
678687
}
679688
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
680689
{
681-
QStringList theURIParts = theURI.split( "?" );
682-
filename = theURIParts[0];
690+
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
683691
}
684692
else
685693
{

0 commit comments

Comments
 (0)