[QGIS Commit] r13939 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jul 19 15:12:11 EDT 2010


Author: gjm
Date: 2010-07-19 19:12:11 +0000 (Mon, 19 Jul 2010)
New Revision: 13939

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
Log:
Fix bug #2772 (dropping gpx files onto qgis didn't open the file
correctly).


Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-07-19 19:11:34 UTC (rev 13938)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-07-19 19:12:11 UTC (rev 13939)
@@ -611,7 +611,7 @@
       else
       {
         QgsDebugMsg( "Adding " + fileName + " to the map canvas" );
-        openLayer( fileName );
+        openLayer( fileName , true);
       }
     }
   }
@@ -3403,17 +3403,28 @@
   Used to process a commandline argument or OpenDocument AppleEvent.
   @returns true if the file is successfully opened
   */
-bool QgisApp::openLayer( const QString & fileName )
+bool QgisApp::openLayer( const QString & fileName, bool allowInteractive )
 {
   QFileInfo fileInfo( fileName );
 
   // try to load it as raster
-  QgsMapLayer* ok = NULL;
+  bool ok(false);
   CPLPushErrorHandler( CPLQuietErrorHandler );
   if ( QgsRasterLayer::isValidRasterFileName( fileName ) )
-    ok = addRasterLayer( fileName, fileInfo.completeBaseName() );
+    {
+      ok  = (addRasterLayer( fileName, fileInfo.completeBaseName() ) != NULL);
+    }
   else // nope - try to load it as a shape/ogr
-    ok = addVectorLayer( fileName, fileInfo.completeBaseName(), "ogr" );
+    {
+      if (allowInteractive)
+	{
+	  ok = addVectorLayers(QStringList(fileName), "System", "file");
+	}
+      else
+	{
+	  ok = (addVectorLayer( fileName, fileInfo.completeBaseName(), "ogr" ) != NULL);
+	}
+    }
 
   CPLPopErrorHandler();
 

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2010-07-19 19:11:34 UTC (rev 13938)
+++ trunk/qgis/src/app/qgisapp.h	2010-07-19 19:12:11 UTC (rev 13939)
@@ -142,9 +142,13 @@
       Used to process a commandline argument or OpenDocument AppleEvent.
       @returns true if the file is successfully opened
       */
-    bool openLayer( const QString & fileName );
-    /** Open the specified project file; prompt to save previous project if necessary.
-      Used to process a commandline argument or OpenDocument AppleEvent.
+    bool openLayer( const QString & fileName, bool allowInteractive = false );
+    /** Open the specified file (project, vector, or raster); prompt to save
+      previous project if necessary. 
+      Used to process a commandline argument, OpenDocument AppleEvent, or a
+      file drag/drop event. Set interactive to true if it is ok to ask the
+      user for information (mostly for when a vector layer has sublayers and
+      we want to ask which sublayers to use).
       */
     void openProject( const QString & fileName );
     /** opens a qgis project file



More information about the QGIS-commit mailing list