Skip to content

Commit 16d0d2f

Browse files
committed
optionally add save vector file to canvas (fix #4598)
1 parent 04a2824 commit 16d0d2f

4 files changed

+17
-0
lines changed

src/app/ogr/qgsvectorlayersaveasdialog.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,8 @@ bool QgsVectorLayerSaveAsDialog::skipAttributeCreation() const
167167
{
168168
return mSkipAttributeCreation->isChecked();
169169
}
170+
171+
bool QgsVectorLayerSaveAsDialog::addToCanvas() const
172+
{
173+
return mAddToCanvas->isChecked();
174+
}

src/app/ogr/qgsvectorlayersaveasdialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
4040
QStringList layerOptions() const;
4141
long crs() const;
4242
bool skipAttributeCreation() const;
43+
bool addToCanvas() const;
4344

4445
private slots:
4546
void on_mFormatComboBox_currentIndexChanged( int idx );

src/app/qgisapp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -3471,6 +3471,10 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )
34713471

34723472
if ( error == QgsVectorFileWriter::NoError )
34733473
{
3474+
if ( dialog->addToCanvas() )
3475+
{
3476+
addVectorLayers( QStringList( vectorFilename ), encoding, "file" );
3477+
}
34743478
QMessageBox::information( 0, tr( "Saving done" ), tr( "Export to vector file has been completed" ) );
34753479
}
34763480
else

src/ui/qgsvectorlayersaveasdialogbase.ui

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@
143143
</property>
144144
</widget>
145145
</item>
146+
<item row="3" column="0" colspan="2">
147+
<widget class="QCheckBox" name="mAddToCanvas">
148+
<property name="text">
149+
<string>Add save file to map</string>
150+
</property>
151+
</widget>
152+
</item>
146153
</layout>
147154
</widget>
148155
</item>

0 commit comments

Comments
 (0)