Skip to content

Commit

Permalink
Add drag and drop for QLR files. Fix #10005
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed May 18, 2014
1 parent 317a509 commit 218da5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -2462,10 +2462,10 @@ void QgisApp::addLayerDefinition()
if ( path.isEmpty() )
return;

QList<QgsMapLayer*> layers = QgsMapLayer::fromLayerDefinitionFile( path );
QgsMapLayerRegistry::instance()->addMapLayers( layers );
openLayerDefinition( path );
}


/**
This method prompts the user for a list of vector file names with a dialog.
*/
Expand Down Expand Up @@ -3806,6 +3806,12 @@ void QgisApp::dxfExport()
}
}

void QgisApp::openLayerDefinition( const QString & path )
{
QList<QgsMapLayer*> layers = QgsMapLayer::fromLayerDefinitionFile( path );
QgsMapLayerRegistry::instance()->addMapLayers( layers );
}

// Open the project file corresponding to the
// path at the given index in mRecentProjectPaths
void QgisApp::openProject( QAction *action )
Expand Down Expand Up @@ -3914,6 +3920,10 @@ void QgisApp::openFile( const QString & fileName )
QgsDebugMsg( "Opening project " + fileName );
openProject( fileName );
}
else if ( fi.completeSuffix() == "qlr" )
{
openLayerDefinition( fileName );
}
else
{
QgsDebugMsg( "Adding " + fileName + " to the map canvas" );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -164,6 +164,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
Used to process a commandline argument, FileOpen or Drop event.
*/
void openProject( const QString & fileName );

void openLayerDefinition( const QString & filename );
/** opens a qgis project file
@returns false if unable to open the project
*/
Expand Down

0 comments on commit 218da5a

Please sign in to comment.