Skip to content

Commit e0afaaa

Browse files
author
gjm
committed
Fix bug #2772 (dropping gpx files onto qgis didn't open the file
correctly). git-svn-id: http://svn.osgeo.org/qgis/trunk@13939 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f05eefd commit e0afaaa

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/app/qgisapp.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ void QgisApp::dropEvent( QDropEvent *event )
611611
else
612612
{
613613
QgsDebugMsg( "Adding " + fileName + " to the map canvas" );
614-
openLayer( fileName );
614+
openLayer( fileName , true);
615615
}
616616
}
617617
}
@@ -3403,17 +3403,28 @@ void QgisApp::openProject( const QString & fileName )
34033403
Used to process a commandline argument or OpenDocument AppleEvent.
34043404
@returns true if the file is successfully opened
34053405
*/
3406-
bool QgisApp::openLayer( const QString & fileName )
3406+
bool QgisApp::openLayer( const QString & fileName, bool allowInteractive )
34073407
{
34083408
QFileInfo fileInfo( fileName );
34093409

34103410
// try to load it as raster
3411-
QgsMapLayer* ok = NULL;
3411+
bool ok(false);
34123412
CPLPushErrorHandler( CPLQuietErrorHandler );
34133413
if ( QgsRasterLayer::isValidRasterFileName( fileName ) )
3414-
ok = addRasterLayer( fileName, fileInfo.completeBaseName() );
3414+
{
3415+
ok = (addRasterLayer( fileName, fileInfo.completeBaseName() ) != NULL);
3416+
}
34153417
else // nope - try to load it as a shape/ogr
3416-
ok = addVectorLayer( fileName, fileInfo.completeBaseName(), "ogr" );
3418+
{
3419+
if (allowInteractive)
3420+
{
3421+
ok = addVectorLayers(QStringList(fileName), "System", "file");
3422+
}
3423+
else
3424+
{
3425+
ok = (addVectorLayer( fileName, fileInfo.completeBaseName(), "ogr" ) != NULL);
3426+
}
3427+
}
34173428

34183429
CPLPopErrorHandler();
34193430

src/app/qgisapp.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ class QgisApp : public QMainWindow
142142
Used to process a commandline argument or OpenDocument AppleEvent.
143143
@returns true if the file is successfully opened
144144
*/
145-
bool openLayer( const QString & fileName );
146-
/** Open the specified project file; prompt to save previous project if necessary.
147-
Used to process a commandline argument or OpenDocument AppleEvent.
145+
bool openLayer( const QString & fileName, bool allowInteractive = false );
146+
/** Open the specified file (project, vector, or raster); prompt to save
147+
previous project if necessary.
148+
Used to process a commandline argument, OpenDocument AppleEvent, or a
149+
file drag/drop event. Set interactive to true if it is ok to ask the
150+
user for information (mostly for when a vector layer has sublayers and
151+
we want to ask which sublayers to use).
148152
*/
149153
void openProject( const QString & fileName );
150154
/** opens a qgis project file

0 commit comments

Comments
 (0)