[QGIS Commit] r15437 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Mar 11 14:02:18 EST 2011


Author: jef
Date: 2011-03-11 11:02:18 -0800 (Fri, 11 Mar 2011)
New Revision: 15437

Modified:
   trunk/qgis/src/core/qgsmaplayer.cpp
Log:
update old delimited text provider datasources on load

Modified: trunk/qgis/src/core/qgsmaplayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsmaplayer.cpp	2011-03-11 19:00:48 UTC (rev 15436)
+++ trunk/qgis/src/core/qgsmaplayer.cpp	2011-03-11 19:02:18 UTC (rev 15437)
@@ -179,6 +179,14 @@
   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() );
@@ -309,9 +317,10 @@
   }
   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
   {
@@ -678,8 +687,7 @@
   }
   else if ( vlayer && vlayer->providerType() == "delimitedtext" )
   {
-    QStringList theURIParts = theURI.split( "?" );
-    filename = theURIParts[0];
+    filename = QUrl::fromEncoded( theURI.toAscii() ).toLocalFile();
   }
   else
   {



More information about the QGIS-commit mailing list