Skip to content

Commit

Permalink
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
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 );
}

QApplication::restoreOverrideCursor();
buttonBox->setEnabled( true );

Expand Down
15 changes: 13 additions & 2 deletions src/ui/qgsosmexportdialog.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>436</height>
<width>456</width>
<height>434</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -118,6 +118,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkLoadWhenFinished">
<property name="text">
<string>&amp;Load into canvas when finished</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down Expand Up @@ -150,6 +160,7 @@
<tabstop>editLayerName</tabstop>
<tabstop>btnLoadTags</tabstop>
<tabstop>viewTags</tabstop>
<tabstop>chkLoadWhenFinished</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit 958f5e6

Please sign in to comment.