Skip to content
Permalink
Browse files

Merged "save as" and "save selection as" actions - choice moved to th…

…e dialog
  • Loading branch information
wonder-sk committed Mar 4, 2014
1 parent cbf2c1a commit 8ed41142554b1cd233d79a187f3203f6d6a1992c
@@ -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;
@@ -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() ) );

@@ -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 )
@@ -45,6 +45,8 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, const QgsRec
mScaleLabel->hide();
mScaleSpinBox->hide();
}

mSelectedOnly->setEnabled( layerHasSelectedFeatures );
}

void QgsVectorLayerSaveAsDialog::setup()
@@ -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;
@@ -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;
@@ -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 );
@@ -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() ) );
@@ -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;
@@ -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() );

@@ -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(),
@@ -5681,7 +5675,7 @@ void QgisApp::pasteAsNewVector()
if ( !layer )
return;

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

delete layer;
}
@@ -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 );
@@ -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 );

@@ -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 );
@@ -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; }
@@ -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();
@@ -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.
@@ -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(); }
@@ -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 */
@@ -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">
@@ -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"/>
@@ -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">
@@ -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">
@@ -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">
@@ -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">

0 comments on commit 8ed4114

Please sign in to comment.
You can’t perform that action at this time.