Skip to content

Commit

Permalink
update old delimited text provider datasources on load
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15437 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 11, 2011
1 parent 16261f2 commit cbf1bc2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/core/qgsmaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ bool QgsMapLayer::readXML( QDomNode & layer_node )
else if ( provider == "delimitedtext" )
{
QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() );

if ( !mDataSource.startsWith( "file://" ) )
{
QUrl file = QUrl::fromLocalFile( mDataSource.left( mDataSource.indexOf( "?" ) ) );
urlSource.setScheme( "file" );
urlSource.setPath( file.path() );
}

QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->readPath( urlSource.toLocalFile() ) );
urlDest.setQueryItems( urlSource.queryItems() );
mDataSource = QString::fromAscii( urlDest.toEncoded() );
Expand Down Expand Up @@ -309,9 +317,10 @@ bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{
QStringList theURIParts = src.split( "?" );
theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0] );
src = theURIParts.join( "?" );
QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->writePath( urlSource.toLocalFile() ) );
urlDest.setQueryItems( urlSource.queryItems() );
src = QString::fromAscii( urlDest.toEncoded() );
}
else
{
Expand Down Expand Up @@ -678,8 +687,7 @@ QString QgsMapLayer::saveNamedStyle( const QString theURI, bool & theResultFlag
}
else if ( vlayer && vlayer->providerType() == "delimitedtext" )
{
QStringList theURIParts = theURI.split( "?" );
filename = theURIParts[0];
filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
}
else
{
Expand Down

0 comments on commit cbf1bc2

Please sign in to comment.