Skip to content

Commit 8ed4114

Browse files
committed
Merged "save as" and "save selection as" actions - choice moved to the dialog
1 parent cbf2c1a commit 8ed4114

10 files changed

+31
-37
lines changed

python/gui/qgisinterface.sip

+2-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ class QgisInterface : QObject
476476
/** @note added in 1.9 */
477477
virtual QAction *actionCancelAllEdits() = 0;
478478
virtual QAction *actionLayerSaveAs() = 0;
479-
virtual QAction *actionLayerSelectionSaveAs() = 0;
479+
/** @note deprecated in 2.4 - returns null pointer */
480+
virtual QAction *actionLayerSelectionSaveAs() = 0 /Deprecated/;
480481
virtual QAction *actionRemoveLayer() = 0;
481482
/** @note added in 1.9 */
482483
virtual QAction *actionDuplicateLayer() = 0;

src/app/legend/qgslegendlayer.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,6 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
436436
// save as vector file
437437
theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) );
438438

439-
// save selection as vector file
440-
QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) );
441-
if ( vlayer->selectedFeatureCount() == 0 )
442-
{
443-
saveSelectionAsAction->setEnabled( false );
444-
}
445-
446439
if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() )
447440
theMenu.addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) );
448441

src/app/ogr/qgsvectorlayersaveasdialog.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, QWidget* par
3232
setup();
3333
}
3434

35-
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, int options, QWidget* parent, Qt::WFlags fl )
35+
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, bool layerHasSelectedFeatures, int options, QWidget* parent, Qt::WFlags fl )
3636
: QDialog( parent, fl )
3737
, mCRS( srsid )
3838
, mLayerExtent( layerExtent )
@@ -45,6 +45,8 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
4545
mScaleLabel->hide();
4646
mScaleSpinBox->hide();
4747
}
48+
49+
mSelectedOnly->setEnabled( layerHasSelectedFeatures );
4850
}
4951

5052
void QgsVectorLayerSaveAsDialog::setup()
@@ -482,6 +484,11 @@ QgsRectangle QgsVectorLayerSaveAsDialog::filterExtent() const
482484
return mExtentGroupBox->outputExtent();
483485
}
484486

487+
bool QgsVectorLayerSaveAsDialog::onlySelected() const
488+
{
489+
return mSelectedOnly->isChecked();
490+
}
491+
485492
void QgsVectorLayerSaveAsDialog::on_mSymbologyExportComboBox_currentIndexChanged( const QString& text )
486493
{
487494
bool scaleEnabled = true;

src/app/ogr/qgsvectorlayersaveasdialog.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
3939
};
4040

4141
QgsVectorLayerSaveAsDialog( long srsid, QWidget* parent = 0, Qt::WFlags fl = 0 );
42-
QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, int options = AllOptions, QWidget* parent = 0, Qt::WFlags fl = 0 );
42+
QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, bool layerHasSelectedFeatures, int options = AllOptions, QWidget* parent = 0, Qt::WFlags fl = 0 );
4343
~QgsVectorLayerSaveAsDialog();
4444

4545
QString format() const;
@@ -63,6 +63,8 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
6363
bool hasFilterExtent() const;
6464
QgsRectangle filterExtent() const;
6565

66+
bool onlySelected() const;
67+
6668
private slots:
6769
void on_mFormatComboBox_currentIndexChanged( int idx );
6870
void on_mCRSSelection_currentIndexChanged( int idx );

src/app/qgisapp.cpp

+5-14
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,6 @@ void QgisApp::createActions()
10701070
connect( mActionCancelEdits, SIGNAL( triggered() ), this, SLOT( cancelEdits() ) );
10711071
connect( mActionCancelAllEdits, SIGNAL( triggered() ), this, SLOT( cancelAllEdits() ) );
10721072
connect( mActionLayerSaveAs, SIGNAL( triggered() ), this, SLOT( saveAsFile() ) );
1073-
connect( mActionLayerSelectionSaveAs, SIGNAL( triggered() ), this, SLOT( saveSelectionAsVectorFile() ) );
10741073
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
10751074
connect( mActionDuplicateLayer, SIGNAL( triggered() ), this, SLOT( duplicateLayers() ) );
10761075
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
@@ -4571,16 +4570,11 @@ void QgisApp::saveAsFile()
45714570
}
45724571
else if ( layerType == QgsMapLayer::VectorLayer )
45734572
{
4574-
saveAsVectorFileGeneral( false );
4573+
saveAsVectorFileGeneral();
45754574
}
45764575
}
45774576

4578-
void QgisApp::saveSelectionAsVectorFile()
4579-
{
4580-
saveAsVectorFileGeneral( true );
4581-
}
4582-
4583-
void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* vlayer, bool symbologyOption )
4577+
void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer* vlayer, bool symbologyOption )
45844578
{
45854579
if ( !mMapLegend )
45864580
return;
@@ -4601,7 +4595,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* v
46014595
options &= ~QgsVectorLayerSaveAsDialog::Symbology;
46024596
}
46034597

4604-
QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer->crs().srsid(), vlayer->extent(), options, this );
4598+
QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer->crs().srsid(), vlayer->extent(), vlayer->selectedFeatureCount() != 0, options, this );
46054599

46064600
dialog->setCanvasExtent( mMapCanvas->mapSettings().visibleExtent(), mMapCanvas->mapSettings().destinationCrs() );
46074601

@@ -4664,7 +4658,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* v
46644658
QgsRectangle filterExtent = dialog->filterExtent();
46654659
error = QgsVectorFileWriter::writeAsVectorFormat(
46664660
vlayer, vectorFilename, encoding, ct, format,
4667-
saveOnlySelection,
4661+
dialog->onlySelected(),
46684662
&errorMessage,
46694663
datasourceOptions, dialog->layerOptions(),
46704664
dialog->skipAttributeCreation(),
@@ -5681,7 +5675,7 @@ void QgisApp::pasteAsNewVector()
56815675
if ( !layer )
56825676
return;
56835677

5684-
saveAsVectorFileGeneral( false, layer, false );
5678+
saveAsVectorFileGeneral( layer, false );
56855679

56865680
delete layer;
56875681
}
@@ -8305,7 +8299,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
83058299
mActionToggleEditing->setChecked( false );
83068300
mActionSaveLayerEdits->setEnabled( false );
83078301
mActionLayerSaveAs->setEnabled( false );
8308-
mActionLayerSelectionSaveAs->setEnabled( false );
83098302
mActionLayerProperties->setEnabled( false );
83108303
mActionLayerSubsetString->setEnabled( false );
83118304
mActionAddToOverview->setEnabled( false );
@@ -8402,7 +8395,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
84028395
mActionSelectByExpression->setEnabled( true );
84038396
mActionOpenTable->setEnabled( true );
84048397
mActionLayerSaveAs->setEnabled( true );
8405-
mActionLayerSelectionSaveAs->setEnabled( true );
84068398
mActionCopyFeatures->setEnabled( layerHasSelection );
84078399
mActionFeatureAction->setEnabled( layerHasActions );
84088400

@@ -8571,7 +8563,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
85718563
mActionUndo->setEnabled( false );
85728564
mActionRedo->setEnabled( false );
85738565
mActionLayerSaveAs->setEnabled( true );
8574-
mActionLayerSelectionSaveAs->setEnabled( false );
85758566
mActionAddFeature->setEnabled( false );
85768567
mActionDeleteSelected->setEnabled( false );
85778568
mActionAddRing->setEnabled( false );

src/app/qgisapp.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
334334
/** @note added in 1.9 */
335335
QAction *actionCancelAllEdits() { return mActionCancelAllEdits; }
336336
QAction *actionLayerSaveAs() { return mActionLayerSaveAs; }
337-
QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
338337
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
339338
/** @note added in 1.9 */
340339
QAction *actionDuplicateLayer() { return mActionDuplicateLayer; }
@@ -1085,7 +1084,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
10851084

10861085
//! save current vector layer
10871086
void saveAsFile();
1088-
void saveSelectionAsVectorFile();
10891087

10901088
//! save current raster layer
10911089
void saveAsRasterFile();
@@ -1258,7 +1256,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
12581256
/**Deletes all the composer objects and clears mPrintComposers*/
12591257
void deletePrintComposers();
12601258

1261-
void saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* vlayer = 0, bool symbologyOption = true );
1259+
void saveAsVectorFileGeneral( QgsVectorLayer* vlayer = 0, bool symbologyOption = true );
12621260

12631261
/** Paste features from clipboard into a new memory layer.
12641262
* If no features are in clipboard an empty layer is returned.

src/app/qgisappinterface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ QAction *QgisAppInterface::actionRollbackAllEdits() { return qgis->actionRollbac
536536
QAction *QgisAppInterface::actionCancelEdits() { return qgis->actionCancelEdits(); }
537537
QAction *QgisAppInterface::actionCancelAllEdits() { return qgis->actionCancelAllEdits(); }
538538
QAction *QgisAppInterface::actionLayerSaveAs() { return qgis->actionLayerSaveAs(); }
539-
QAction *QgisAppInterface::actionLayerSelectionSaveAs() { return qgis->actionLayerSelectionSaveAs(); }
539+
QAction *QgisAppInterface::actionLayerSelectionSaveAs() { return 0; }
540540
QAction *QgisAppInterface::actionRemoveLayer() { return qgis->actionRemoveLayer(); }
541541
QAction *QgisAppInterface::actionDuplicateLayer() { return qgis->actionDuplicateLayer(); }
542542
QAction *QgisAppInterface::actionLayerProperties() { return qgis->actionLayerProperties(); }

src/gui/qgisinterface.h

+1
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ class GUI_EXPORT QgisInterface : public QObject
530530
/** @note added in 1.9 */
531531
virtual QAction *actionCancelAllEdits() = 0;
532532
virtual QAction *actionLayerSaveAs() = 0;
533+
/** @note deprecated in 2.4 - returns null pointer */
533534
virtual QAction *actionLayerSelectionSaveAs() = 0;
534535
virtual QAction *actionRemoveLayer() = 0;
535536
/** @note added in 1.9 */

src/ui/qgisapp.ui

+2-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<x>0</x>
1818
<y>0</y>
1919
<width>1050</width>
20-
<height>25</height>
20+
<height>27</height>
2121
</rect>
2222
</property>
2323
<widget class="QMenu" name="mProjectMenu">
@@ -144,7 +144,6 @@
144144
<addaction name="mActionAllEdits"/>
145145
<addaction name="separator"/>
146146
<addaction name="mActionLayerSaveAs"/>
147-
<addaction name="mActionLayerSelectionSaveAs"/>
148147
<addaction name="mActionRemoveLayer"/>
149148
<addaction name="mActionDuplicateLayer"/>
150149
<addaction name="mActionSetLayerCRS"/>
@@ -1306,11 +1305,6 @@
13061305
<string>Save As...</string>
13071306
</property>
13081307
</action>
1309-
<action name="mActionLayerSelectionSaveAs">
1310-
<property name="text">
1311-
<string>Save Selection as Vector File...</string>
1312-
</property>
1313-
</action>
13141308
<action name="mActionRemoveLayer">
13151309
<property name="icon">
13161310
<iconset resource="../../images/images.qrc">
@@ -2152,7 +2146,7 @@ Acts on currently active editable layer</string>
21522146
<bool>true</bool>
21532147
</property>
21542148
<property name="icon">
2155-
<iconset resource="../../images/images.qrc">
2149+
<iconset>
21562150
<normaloff>:/images/themes/default/mActionFillRing.png</normaloff>:/images/themes/default/mActionFillRing.png</iconset>
21572151
</property>
21582152
<property name="text">

src/ui/qgsvectorlayersaveasdialogbase.ui

+8-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<x>0</x>
108108
<y>0</y>
109109
<width>562</width>
110-
<height>483</height>
110+
<height>508</height>
111111
</rect>
112112
</property>
113113
<layout class="QVBoxLayout" name="verticalLayout">
@@ -128,6 +128,13 @@
128128
</item>
129129
</layout>
130130
</item>
131+
<item>
132+
<widget class="QCheckBox" name="mSelectedOnly">
133+
<property name="text">
134+
<string>Save only selected features</string>
135+
</property>
136+
</widget>
137+
</item>
131138
<item>
132139
<widget class="QCheckBox" name="mSkipAttributeCreation">
133140
<property name="toolTip">

0 commit comments

Comments
 (0)