Skip to content

Commit 958f5e6

Browse files
committedMar 5, 2013
Added option to load newly exported OpenStreetMap layer to canvas
1 parent 5a9715d commit 958f5e6

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
 

‎src/app/openstreetmap/qgsosmexportdialog.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
#include "qgsosmdatabase.h"
1919

20+
#include "qgsdatasourceuri.h"
21+
#include "qgsmaplayerregistry.h"
22+
#include "qgsvectorlayer.h"
23+
2024
#include <QApplication>
2125
#include <QFileDialog>
2226
#include <QMessageBox>
@@ -148,6 +152,17 @@ void QgsOSMExportDialog::onOK()
148152

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

155+
// load the layer into canvas if that was requested
156+
if ( chkLoadWhenFinished->isChecked() )
157+
{
158+
QgsDataSourceURI uri;
159+
uri.setDatabase( editDbFileName->text() );
160+
uri.setDataSource( QString(), editLayerName->text(), "geometry" );
161+
QgsVectorLayer* vlayer = new QgsVectorLayer( uri.uri(), editLayerName->text(), "spatialite" );
162+
if ( vlayer->isValid() )
163+
QgsMapLayerRegistry::instance()->addMapLayer( vlayer );
164+
}
165+
151166
QApplication::restoreOverrideCursor();
152167
buttonBox->setEnabled( true );
153168

‎src/ui/qgsosmexportdialog.ui

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>458</width>
10-
<height>436</height>
9+
<width>456</width>
10+
<height>434</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -118,6 +118,16 @@
118118
</layout>
119119
</widget>
120120
</item>
121+
<item>
122+
<widget class="QCheckBox" name="chkLoadWhenFinished">
123+
<property name="text">
124+
<string>&amp;Load into canvas when finished</string>
125+
</property>
126+
<property name="checked">
127+
<bool>true</bool>
128+
</property>
129+
</widget>
130+
</item>
121131
<item>
122132
<layout class="QHBoxLayout" name="horizontalLayout_4">
123133
<item>
@@ -150,6 +160,7 @@
150160
<tabstop>editLayerName</tabstop>
151161
<tabstop>btnLoadTags</tabstop>
152162
<tabstop>viewTags</tabstop>
163+
<tabstop>chkLoadWhenFinished</tabstop>
153164
<tabstop>buttonBox</tabstop>
154165
</tabstops>
155166
<resources/>

0 commit comments

Comments
 (0)
Please sign in to comment.