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 authored and alexbruy committed Feb 11, 2012
1 parent 4ba2c39 commit b3807b72a77501988ddff8fb9b9e2539fa3865e3
Showing with 60 additions and 34 deletions.
  1. +27 −5 src/app/ogr/qgsvectorlayersaveasdialog.cpp
  2. +2 −1 src/app/ogr/qgsvectorlayersaveasdialog.h
  3. +10 −13 src/app/qgisapp.cpp
  4. +21 −15 src/ui/qgsvectorlayersaveasdialogbase.ui
@@ -20,14 +20,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 );

@@ -53,9 +54,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() );
}

@@ -72,6 +77,11 @@ void QgsVectorLayerSaveAsDialog::accept()
QDialog::accept();
}

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

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

delete mySelector;
@@ -142,7 +153,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
@@ -31,7 +31,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() ); }
@@ -3284,29 +3284,26 @@ 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 )
{
QString encoding = dialog->encoding();
QString vectorFilename = dialog->filename();
QString format = dialog->format();

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,6 +139,19 @@
</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 b3807b7

Please sign in to comment.