Skip to content
Permalink
Browse files
Fix bug #2772 (dropping gpx files onto qgis didn't open the file
correctly).


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13939 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gjm committed Jul 19, 2010
1 parent 6bf395d commit 8b066a0bb5445ce6257a9d683b62a74e71986da1
Showing with 23 additions and 8 deletions.
  1. +16 −5 src/app/qgisapp.cpp
  2. +7 −3 src/app/qgisapp.h
@@ -611,7 +611,7 @@ void QgisApp::dropEvent( QDropEvent *event )
else
{
QgsDebugMsg( "Adding " + fileName + " to the map canvas" );
openLayer( fileName );
openLayer( fileName , true);
}
}
}
@@ -3403,17 +3403,28 @@ void QgisApp::openProject( const QString & fileName )
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();

@@ -142,9 +142,13 @@ class QgisApp : public QMainWindow
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

0 comments on commit 8b066a0

Please sign in to comment.