Skip to content
Permalink
Browse files

Use a real scale widget in vector save as dialog

  • Loading branch information
nyalldawson committed Jun 8, 2017
1 parent e0d29e7 commit a3d919dcffe60a87070bf000906047651170a78b
@@ -23,10 +23,12 @@
#include "qgseditorwidgetfactory.h"
#include "qgseditorwidgetregistry.h"
#include "qgssettings.h"
#include "qgsmapcanvas.h"
#include "qgsgui.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QTextCodec>
#include <QSpinBox>

static const int COLUMN_IDX_NAME = 0;
static const int COLUMN_IDX_TYPE = 1;
@@ -61,7 +63,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, i
mSymbologyExportLabel->hide();
mSymbologyExportComboBox->hide();
mScaleLabel->hide();
mScaleSpinBox->hide();
mScaleWidget->hide();
}

mSelectedOnly->setEnabled( layer && layer->selectedFeatureCount() != 0 );
@@ -814,14 +816,17 @@ int QgsVectorLayerSaveAsDialog::symbologyExport() const
return mSymbologyExportComboBox->currentData().toInt();
}

double QgsVectorLayerSaveAsDialog::scaleDenominator() const
double QgsVectorLayerSaveAsDialog::scale() const
{
return mScaleSpinBox->value();
return mScaleWidget->scale();
}

void QgsVectorLayerSaveAsDialog::setCanvasExtent( const QgsRectangle &canvasExtent, const QgsCoordinateReferenceSystem &canvasCrs )
void QgsVectorLayerSaveAsDialog::setMapCanvas( QgsMapCanvas *canvas )
{
mExtentGroupBox->setCurrentExtent( canvasExtent, canvasCrs );
mMapCanvas = canvas;
mScaleWidget->setMapCanvas( canvas );
mScaleWidget->setShowCurrentScaleButton( true );
mExtentGroupBox->setCurrentExtent( canvas->mapSettings().visibleExtent(), canvas->mapSettings().destinationCrs() );
}

bool QgsVectorLayerSaveAsDialog::hasFilterExtent() const
@@ -889,7 +894,7 @@ void QgsVectorLayerSaveAsDialog::on_mSymbologyExportComboBox_currentIndexChanged
{
scaleEnabled = false;
}
mScaleSpinBox->setEnabled( scaleEnabled );
mScaleWidget->setEnabled( scaleEnabled );
mScaleLabel->setEnabled( scaleEnabled );
}

@@ -63,10 +63,17 @@ class APP_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
1: Feature symbology
2: Symbol level symbology*/
int symbologyExport() const;
double scaleDenominator() const;

//! setup canvas extent - for the use in extent group box
void setCanvasExtent( const QgsRectangle &canvasExtent, const QgsCoordinateReferenceSystem &canvasCrs );
/**
* Returns the specified map scale.
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
*/
double scale() const;

/**
* Sets a map \a canvas to associate with the dialog.
*/
void setMapCanvas( QgsMapCanvas *canvas );

bool hasFilterExtent() const;
QgsRectangle filterExtent() const;
@@ -130,6 +137,7 @@ class APP_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVec
QgsRectangle mLayerExtent;
QgsCoordinateReferenceSystem mLayerCrs;
QgsVectorLayer *mLayer = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;
bool mAttributeTableItemChangedSlotEnabled;
bool mReplaceRawFieldValuesStateChangedSlotEnabled;
QgsVectorFileWriter::ActionOnExistingFile mActionOnExistingFile;
@@ -6776,7 +6776,7 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOpt

QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer, options, this );

dialog->setCanvasExtent( mMapCanvas->mapSettings().visibleExtent(), mMapCanvas->mapSettings().destinationCrs() );
dialog->setMapCanvas( mMapCanvas );
dialog->setIncludeZ( QgsWkbTypes::hasZ( vlayer->wkbType() ) );

if ( dialog->exec() == QDialog::Accepted )
@@ -6835,7 +6835,7 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer *vlayer, bool symbologyOpt
options.layerOptions = dialog->layerOptions();
options.skipAttributeCreation = dialog->selectedAttributes().isEmpty();
options.symbologyExport = static_cast< QgsVectorFileWriter::SymbologyExport >( dialog->symbologyExport() );
options.symbologyScale = dialog->scaleDenominator();
options.symbologyScale = dialog->scale();
if ( dialog->hasFilterExtent() )
options.filterExtent = filterExtent;
options.overrideGeometryType = autoGeometryType ? QgsWkbTypes::Unknown : forcedGeometryType;
@@ -106,9 +106,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-303</y>
<width>557</width>
<height>922</height>
<height>1004</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -235,15 +235,9 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="mScaleSpinBox">
<property name="prefix">
<string>1:</string>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="value">
<number>50000</number>
<widget class="QgsScaleWidget" name="mScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
@@ -469,6 +463,11 @@
<header>qgsextentgroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleWidget</class>
<extends>QWidget</extends>
<header>qgsscalewidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mFormatComboBox</tabstop>
@@ -482,15 +481,15 @@
<tabstop>mSelectAllAttributes</tabstop>
<tabstop>mDeselectAllAttributes</tabstop>
<tabstop>mSymbologyExportComboBox</tabstop>
<tabstop>mScaleSpinBox</tabstop>
<tabstop>mGeometryGroupBox</tabstop>
<tabstop>mScaleWidget</tabstop>
<tabstop>mGeometryTypeComboBox</tabstop>
<tabstop>mForceMultiCheckBox</tabstop>
<tabstop>mIncludeZCheckBox</tabstop>
<tabstop>mExtentGroupBox</tabstop>
<tabstop>mDatasourceOptionsGroupBox</tabstop>
<tabstop>mLayerOptionsGroupBox</tabstop>
<tabstop>mOgrOptionsGroupBox</tabstop>
<tabstop>mAddToCanvas</tabstop>
<tabstop>mAttributeTable</tabstop>
<tabstop>mReplaceRawFieldValues</tabstop>
<tabstop>mOgrDatasourceOptions</tabstop>
<tabstop>mOgrLayerOptions</tabstop>
</tabstops>
<resources/>
<connections>

0 comments on commit a3d919d

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