Navigation Menu

Skip to content

Commit

Permalink
[FEATURE] allow OGR save as without attributes (for eg. DGN/DXF)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14562 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 12, 2010
1 parent fab2b0f commit 917f57c
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 116 deletions.
4 changes: 3 additions & 1 deletion python/core/qgsvectorfilewriter.sip
Expand Up @@ -44,7 +44,9 @@ public:
bool onlySelected = FALSE,
QString *errorMessage = 0,
const QStringList &datasourceOptions = QStringList(),
const QStringList &layerOptions = QStringList() );
const QStringList &layerOptions = QStringList(),
bool skipAttributeCreation = FALSE // added in 1.7
);

/** create shapefile and initialize it */
QgsVectorFileWriter(const QString& vectorFileName,
Expand Down
21 changes: 13 additions & 8 deletions src/app/ogr/qgsvectorlayersaveasdialog.cpp
Expand Up @@ -26,15 +26,15 @@
#include <QTextCodec>

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

QSettings settings;
QMap<QString, QString> map = QgsVectorFileWriter::ogrDriverList();
mFormatComboBox->blockSignals( true );
for ( QMap< QString, QString>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
for( QMap< QString, QString>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
{
mFormatComboBox->addItem( it.key(), it.value() );
}
Expand All @@ -47,7 +47,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl

QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
int idx = mEncodingComboBox->findText( enc );
if ( idx < 0 )
if( idx < 0 )
{
mEncodingComboBox->insertItem( 0, enc );
idx = 0;
Expand Down Expand Up @@ -77,7 +77,7 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
browseFilename->setEnabled( true );
leFilename->setEnabled( true );

if ( format() == "KML" )
if( format() == "KML" )
{
mEncodingComboBox->setCurrentIndex( mEncodingComboBox->findText( "UTF-8" ) );
mEncodingComboBox->setDisabled( true );
Expand All @@ -94,7 +94,7 @@ void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
QString dirName = leFilename->text().isEmpty() ? settings.value( "/UI/lastVectorFileFilterDir", "." ).toString() : leFilename->text();
QString filterString = QgsVectorFileWriter::filterForDriver( format() );
QString outputFile = QFileDialog::getSaveFileName( 0, tr( "Save layer as..." ), dirName, filterString );
if ( !outputFile.isNull() )
if( !outputFile.isNull() )
{
leFilename->setText( outputFile );
}
Expand All @@ -103,12 +103,12 @@ void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
void QgsVectorLayerSaveAsDialog::on_browseCRS_clicked()
{
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector();
if ( mCRS >= 0 )
if( mCRS >= 0 )
mySelector->setSelectedCrsId( mCRS );
mySelector->setMessage( tr( "Select the coordinate reference system for the vector file. "
"The data points will be transformed from the layer coordinate reference system." ) );

if ( mySelector->exec() )
if( mySelector->exec() )
{
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
mCRS = srs.srsid();
Expand Down Expand Up @@ -147,3 +147,8 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
{
return mOgrLayerOptions->toPlainText().split( "\n" );
}

bool QgsVectorLayerSaveAsDialog::skipAttributeCreation() const
{
return mSkipAttributeCreation->isChecked();
}
1 change: 1 addition & 0 deletions src/app/ogr/qgsvectorlayersaveasdialog.h
Expand Up @@ -40,6 +40,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
QStringList datasourceOptions() const;
QStringList layerOptions() const;
long crs() const;
bool skipAttributeCreation() const;

private slots:
void on_mFormatComboBox_currentIndexChanged( int idx );
Expand Down

0 comments on commit 917f57c

Please sign in to comment.