Skip to content
Permalink
Browse files
Add drag and drop for QLR files. Fix #10005
  • Loading branch information
NathanW2 committed May 18, 2014
1 parent 317a509 commit 218da5a53898831fbe1011c2bed34af6d14c0e45
Showing with 14 additions and 2 deletions.
  1. +12 −2 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
@@ -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.
*/
@@ -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 )
@@ -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" );
@@ -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
*/

0 comments on commit 218da5a

Please sign in to comment.