Skip to content


Added option to load newly exported OpenStreetMap layer to canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 5, 2013
1 parent 5a9715d commit 958f5e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/app/openstreetmap/qgsosmexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#include "qgsosmdatabase.h"

#include "qgsdatasourceuri.h"
#include "qgsmaplayerregistry.h"
#include "qgsvectorlayer.h"

#include <QApplication>
#include <QFileDialog>
#include <QMessageBox>
Expand Down Expand Up @@ -148,6 +152,17 @@ void QgsOSMExportDialog::onOK()

bool res = mDatabase->exportSpatiaLite( type, editLayerName->text(), tagKeys );

// load the layer into canvas if that was requested
if ( chkLoadWhenFinished->isChecked() )
QgsDataSourceURI uri;
uri.setDatabase( editDbFileName->text() );
uri.setDataSource( QString(), editLayerName->text(), "geometry" );
QgsVectorLayer* vlayer = new QgsVectorLayer( uri.uri(), editLayerName->text(), "spatialite" );
if ( vlayer->isValid() )
QgsMapLayerRegistry::instance()->addMapLayer( vlayer );

buttonBox->setEnabled( true );

Expand Down
15 changes: 13 additions & 2 deletions src/ui/qgsosmexportdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<property name="windowTitle">
Expand Down Expand Up @@ -118,6 +118,16 @@
<widget class="QCheckBox" name="chkLoadWhenFinished">
<property name="text">
<string>&amp;Load into canvas when finished</string>
<property name="checked">
<layout class="QHBoxLayout" name="horizontalLayout_4">
Expand Down Expand Up @@ -150,6 +160,7 @@
Expand Down

0 comments on commit 958f5e6

Please sign in to comment.