Skip to content
Permalink
Browse files

vector layer save as: replace 'original crs' with 'layer crs' and 'pr…

…oject crs' - OTFR doesn't matter anymore (fixes #4109)
  • Loading branch information
jef-n committed Feb 3, 2012
1 parent 16d0d2f commit 3f50017a97ee61deecdf022dcc7b6023c5229881
@@ -19,14 +19,15 @@
#include "qgsgenericprojectionselector.h"
#include "qgsvectordataprovider.h"
#include "qgsvectorfilewriter.h"
#include "qgscoordinatereferencesystem.h"

#include <QSettings>
#include <QFileDialog>
#include <QTextCodec>

QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFlags fl )
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( long srsid, QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mCRS( -1 )
, mCRS( srsid )
{
setupUi( this );

@@ -57,9 +58,13 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl
idx = 0;
}

mEncodingComboBox->setCurrentIndex( idx );
mCRSSelection->clear();
mCRSSelection->addItems( QStringList() << tr( "Layer CRS" ) << tr( "Project CRS" ) << tr( "Selected CRS" ) );

QgsCoordinateReferenceSystem srs( srsid, QgsCoordinateReferenceSystem::InternalCrsId );
leCRS->setText( srs.description() );

leCRS->setText( tr( "Original CRS" ) );
mEncodingComboBox->setCurrentIndex( idx );
on_mFormatComboBox_currentIndexChanged( mFormatComboBox->currentIndex() );
}

@@ -78,6 +83,11 @@ void QgsVectorLayerSaveAsDialog::accept()
QDialog::accept();
}

void QgsVectorLayerSaveAsDialog::on_mCRSSelection_currentIndexChanged( int idx )
{
leCRS->setEnabled( idx == 2 );
}

void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx )
{
Q_UNUSED( idx );
@@ -128,6 +138,7 @@ void QgsVectorLayerSaveAsDialog::on_browseCRS_clicked()
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
mCRS = srs.srsid();
leCRS->setText( srs.description() );
mCRSSelection->setCurrentIndex( 2 );
}

delete mySelector;
@@ -150,7 +161,18 @@ QString QgsVectorLayerSaveAsDialog::format() const

long QgsVectorLayerSaveAsDialog::crs() const
{
return mCRS;
if ( mCRSSelection->currentIndex() == 0 )
{
return -1; // Layer CRS
}
else if ( mCRSSelection->currentIndex() == 1 )
{
return -2; // Project CRS
}
else
{
return mCRS;
}
}

QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
@@ -30,7 +30,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
Q_OBJECT

public:
QgsVectorLayerSaveAsDialog( QWidget* parent = 0, Qt::WFlags fl = 0 );
QgsVectorLayerSaveAsDialog( long srsid, QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsVectorLayerSaveAsDialog();

QString format() const;
@@ -44,6 +44,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav

private slots:
void on_mFormatComboBox_currentIndexChanged( int idx );
void on_mCRSSelection_currentIndexChanged( int idx );
void on_browseFilename_clicked();
void on_browseCRS_clicked();
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
@@ -3422,7 +3422,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )

QgsCoordinateReferenceSystem destCRS;

QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( this );
QgsVectorLayerSaveAsDialog *dialog = new QgsVectorLayerSaveAsDialog( vlayer->crs().srsid(), this );

if ( dialog->exec() == QDialog::Accepted )
{
@@ -3438,21 +3438,18 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )
format = "SQLite";
}

if ( dialog->crs() < 0 )
switch ( dialog->crs() )
{
// Find out if we have projections enabled or not
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
case -2: // Project CRS
destCRS = mMapCanvas->mapRenderer()->destinationCrs();
}
else
{
break;
case -1: // Layer CRS
destCRS = vlayer->crs();
}
}
else
{
destCRS = QgsCoordinateReferenceSystem( dialog->crs(), QgsCoordinateReferenceSystem::InternalCrsId );
break;

default: // Selected CRS
destCRS = QgsCoordinateReferenceSystem( dialog->crs(), QgsCoordinateReferenceSystem::InternalCrsId );
break;
}

// ok if the file existed it should be deleted now so we can continue...
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>383</width>
<height>427</height>
<height>496</height>
</rect>
</property>
<property name="windowTitle">
@@ -21,24 +21,17 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>CRS</string>
</property>
<property name="buddy">
<cstring>leCRS</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLineEdit" name="leCRS">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<item row="8" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -68,7 +61,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="6" column="2">
<widget class="QPushButton" name="browseCRS">
<property name="text">
<string>Browse</string>
@@ -101,7 +94,7 @@
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="mFormatComboBox"/>
</item>
<item row="6" column="0" colspan="3">
<item row="7" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>OGR creation options</string>
@@ -146,13 +139,26 @@
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="mAddToCanvas">
<property name="text">
<string>Add save file to map</string>
<string>Add saved file to map</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QComboBox" name="mCRSSelection"/>
</item>
<item row="5" column="0" rowspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>CRS</string>
</property>
<property name="buddy">
<cstring>leCRS</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>

0 comments on commit 3f50017

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