Skip to content

Commit

Permalink
Fix bug #2772 (dropping gpx files onto qgis didn't open the file
Browse files Browse the repository at this point in the history
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 8b066a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
21 changes: 16 additions & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -611,7 +611,7 @@ void QgisApp::dropEvent( QDropEvent *event )
else
{
QgsDebugMsg( "Adding " + fileName + " to the map canvas" );
openLayer( fileName );
openLayer( fileName , true);
}
}
}
Expand Down Expand Up @@ -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();

Expand Down
10 changes: 7 additions & 3 deletions src/app/qgisapp.h
Expand Up @@ -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
Expand Down

0 comments on commit 8b066a0

Please sign in to comment.