Skip to content

Commit

Permalink
Merged "save as" and "save selection as" actions - choice moved to th…
Browse files Browse the repository at this point in the history
…e dialog
  • Loading branch information
wonder-sk committed Mar 4, 2014
1 parent cbf2c1a commit 8ed4114
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 37 deletions.
3 changes: 2 additions & 1 deletion python/gui/qgisinterface.sip
Expand Up @@ -476,7 +476,8 @@ class QgisInterface : QObject
/** @note added in 1.9 */
virtual QAction *actionCancelAllEdits() = 0;
virtual QAction *actionLayerSaveAs() = 0;
virtual QAction *actionLayerSelectionSaveAs() = 0;
/** @note deprecated in 2.4 - returns null pointer */
virtual QAction *actionLayerSelectionSaveAs() = 0 /Deprecated/;
virtual QAction *actionRemoveLayer() = 0;
/** @note added in 1.9 */
virtual QAction *actionDuplicateLayer() = 0;
Expand Down
7 changes: 0 additions & 7 deletions src/app/legend/qgslegendlayer.cpp
Expand Up @@ -436,13 +436,6 @@ void QgsLegendLayer::addToPopupMenu( QMenu& theMenu )
// save as vector file
theMenu.addAction( tr( "Save As..." ), QgisApp::instance(), SLOT( saveAsFile() ) );

// save selection as vector file
QAction* saveSelectionAsAction = theMenu.addAction( tr( "Save Selection As..." ), QgisApp::instance(), SLOT( saveSelectionAsVectorFile() ) );
if ( vlayer->selectedFeatureCount() == 0 )
{
saveSelectionAsAction->setEnabled( false );
}

if ( !vlayer->isEditable() && vlayer->dataProvider()->supportsSubsetString() && vlayer->vectorJoins().isEmpty() )
theMenu.addAction( tr( "&Filter..." ), QgisApp::instance(), SLOT( layerSubsetString() ) );

Expand Down
9 changes: 8 additions & 1 deletion src/app/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -32,7 +32,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, QWidget* par
setup();
}

QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, int options, QWidget* parent, Qt::WFlags fl )
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRectangle& layerExtent, bool layerHasSelectedFeatures, int options, QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mCRS( srsid )
, mLayerExtent( layerExtent )
Expand All @@ -45,6 +45,8 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
mScaleLabel->hide();
mScaleSpinBox->hide();
}

mSelectedOnly->setEnabled( layerHasSelectedFeatures );
}

void QgsVectorLayerSaveAsDialog::setup()
Expand Down Expand Up @@ -482,6 +484,11 @@ QgsRectangle QgsVectorLayerSaveAsDialog::filterExtent() const
return mExtentGroupBox->outputExtent();
}

bool QgsVectorLayerSaveAsDialog::onlySelected() const
{
return mSelectedOnly->isChecked();
}

void QgsVectorLayerSaveAsDialog::on_mSymbologyExportComboBox_currentIndexChanged( const QString& text )
{
bool scaleEnabled = true;
Expand Down
4 changes: 3 additions & 1 deletion src/app/ogr/qgsvectorlayersaveasdialog.h
Expand Up @@ -39,7 +39,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
};

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

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

bool onlySelected() const;

private slots:
void on_mFormatComboBox_currentIndexChanged( int idx );
void on_mCRSSelection_currentIndexChanged( int idx );
Expand Down
19 changes: 5 additions & 14 deletions src/app/qgisapp.cpp
Expand Up @@ -1070,7 +1070,6 @@ void QgisApp::createActions()
connect( mActionCancelEdits, SIGNAL( triggered() ), this, SLOT( cancelEdits() ) );
connect( mActionCancelAllEdits, SIGNAL( triggered() ), this, SLOT( cancelAllEdits() ) );
connect( mActionLayerSaveAs, SIGNAL( triggered() ), this, SLOT( saveAsFile() ) );
connect( mActionLayerSelectionSaveAs, SIGNAL( triggered() ), this, SLOT( saveSelectionAsVectorFile() ) );
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
connect( mActionDuplicateLayer, SIGNAL( triggered() ), this, SLOT( duplicateLayers() ) );
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
Expand Down Expand Up @@ -4571,16 +4570,11 @@ void QgisApp::saveAsFile()
}
else if ( layerType == QgsMapLayer::VectorLayer )
{
saveAsVectorFileGeneral( false );
saveAsVectorFileGeneral();
}
}

void QgisApp::saveSelectionAsVectorFile()
{
saveAsVectorFileGeneral( true );
}

void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* vlayer, bool symbologyOption )
void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer* vlayer, bool symbologyOption )
{
if ( !mMapLegend )
return;
Expand All @@ -4601,7 +4595,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* v
options &= ~QgsVectorLayerSaveAsDialog::Symbology;
}

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

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

Expand Down Expand Up @@ -4664,7 +4658,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* v
QgsRectangle filterExtent = dialog->filterExtent();
error = QgsVectorFileWriter::writeAsVectorFormat(
vlayer, vectorFilename, encoding, ct, format,
saveOnlySelection,
dialog->onlySelected(),
&errorMessage,
datasourceOptions, dialog->layerOptions(),
dialog->skipAttributeCreation(),
Expand Down Expand Up @@ -5681,7 +5675,7 @@ void QgisApp::pasteAsNewVector()
if ( !layer )
return;

saveAsVectorFileGeneral( false, layer, false );
saveAsVectorFileGeneral( layer, false );

delete layer;
}
Expand Down Expand Up @@ -8305,7 +8299,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionToggleEditing->setChecked( false );
mActionSaveLayerEdits->setEnabled( false );
mActionLayerSaveAs->setEnabled( false );
mActionLayerSelectionSaveAs->setEnabled( false );
mActionLayerProperties->setEnabled( false );
mActionLayerSubsetString->setEnabled( false );
mActionAddToOverview->setEnabled( false );
Expand Down Expand Up @@ -8402,7 +8395,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSelectByExpression->setEnabled( true );
mActionOpenTable->setEnabled( true );
mActionLayerSaveAs->setEnabled( true );
mActionLayerSelectionSaveAs->setEnabled( true );
mActionCopyFeatures->setEnabled( layerHasSelection );
mActionFeatureAction->setEnabled( layerHasActions );

Expand Down Expand Up @@ -8571,7 +8563,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionUndo->setEnabled( false );
mActionRedo->setEnabled( false );
mActionLayerSaveAs->setEnabled( true );
mActionLayerSelectionSaveAs->setEnabled( false );
mActionAddFeature->setEnabled( false );
mActionDeleteSelected->setEnabled( false );
mActionAddRing->setEnabled( false );
Expand Down
4 changes: 1 addition & 3 deletions src/app/qgisapp.h
Expand Up @@ -334,7 +334,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
/** @note added in 1.9 */
QAction *actionCancelAllEdits() { return mActionCancelAllEdits; }
QAction *actionLayerSaveAs() { return mActionLayerSaveAs; }
QAction *actionLayerSelectionSaveAs() { return mActionLayerSelectionSaveAs; }
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
/** @note added in 1.9 */
QAction *actionDuplicateLayer() { return mActionDuplicateLayer; }
Expand Down Expand Up @@ -1085,7 +1084,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

//! save current vector layer
void saveAsFile();
void saveSelectionAsVectorFile();

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

void saveAsVectorFileGeneral( bool saveOnlySelection, QgsVectorLayer* vlayer = 0, bool symbologyOption = true );
void saveAsVectorFileGeneral( QgsVectorLayer* vlayer = 0, bool symbologyOption = true );

/** Paste features from clipboard into a new memory layer.
* If no features are in clipboard an empty layer is returned.
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -536,7 +536,7 @@ QAction *QgisAppInterface::actionRollbackAllEdits() { return qgis->actionRollbac
QAction *QgisAppInterface::actionCancelEdits() { return qgis->actionCancelEdits(); }
QAction *QgisAppInterface::actionCancelAllEdits() { return qgis->actionCancelAllEdits(); }
QAction *QgisAppInterface::actionLayerSaveAs() { return qgis->actionLayerSaveAs(); }
QAction *QgisAppInterface::actionLayerSelectionSaveAs() { return qgis->actionLayerSelectionSaveAs(); }
QAction *QgisAppInterface::actionLayerSelectionSaveAs() { return 0; }
QAction *QgisAppInterface::actionRemoveLayer() { return qgis->actionRemoveLayer(); }
QAction *QgisAppInterface::actionDuplicateLayer() { return qgis->actionDuplicateLayer(); }
QAction *QgisAppInterface::actionLayerProperties() { return qgis->actionLayerProperties(); }
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgisinterface.h
Expand Up @@ -530,6 +530,7 @@ class GUI_EXPORT QgisInterface : public QObject
/** @note added in 1.9 */
virtual QAction *actionCancelAllEdits() = 0;
virtual QAction *actionLayerSaveAs() = 0;
/** @note deprecated in 2.4 - returns null pointer */
virtual QAction *actionLayerSelectionSaveAs() = 0;
virtual QAction *actionRemoveLayer() = 0;
/** @note added in 1.9 */
Expand Down
10 changes: 2 additions & 8 deletions src/ui/qgisapp.ui
Expand Up @@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1050</width>
<height>25</height>
<height>27</height>
</rect>
</property>
<widget class="QMenu" name="mProjectMenu">
Expand Down Expand Up @@ -144,7 +144,6 @@
<addaction name="mActionAllEdits"/>
<addaction name="separator"/>
<addaction name="mActionLayerSaveAs"/>
<addaction name="mActionLayerSelectionSaveAs"/>
<addaction name="mActionRemoveLayer"/>
<addaction name="mActionDuplicateLayer"/>
<addaction name="mActionSetLayerCRS"/>
Expand Down Expand Up @@ -1306,11 +1305,6 @@
<string>Save As...</string>
</property>
</action>
<action name="mActionLayerSelectionSaveAs">
<property name="text">
<string>Save Selection as Vector File...</string>
</property>
</action>
<action name="mActionRemoveLayer">
<property name="icon">
<iconset resource="../../images/images.qrc">
Expand Down Expand Up @@ -2152,7 +2146,7 @@ Acts on currently active editable layer</string>
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<iconset>
<normaloff>:/images/themes/default/mActionFillRing.png</normaloff>:/images/themes/default/mActionFillRing.png</iconset>
</property>
<property name="text">
Expand Down
9 changes: 8 additions & 1 deletion src/ui/qgsvectorlayersaveasdialogbase.ui
Expand Up @@ -107,7 +107,7 @@
<x>0</x>
<y>0</y>
<width>562</width>
<height>483</height>
<height>508</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand All @@ -128,6 +128,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="mSelectedOnly">
<property name="text">
<string>Save only selected features</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mSkipAttributeCreation">
<property name="toolTip">
Expand Down

0 comments on commit 8ed4114

Please sign in to comment.