Skip to content

Commit f9198e2

Browse files
author
jef
committedNov 12, 2010
[FEATURE] allow OGR save as without attributes (for eg. DGN/DXF)
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14562 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

6 files changed

+140
-116
lines changed

6 files changed

+140
-116
lines changed
 

‎python/core/qgsvectorfilewriter.sip

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public:
4444
bool onlySelected = FALSE,
4545
QString *errorMessage = 0,
4646
const QStringList &datasourceOptions = QStringList(),
47-
const QStringList &layerOptions = QStringList() );
47+
const QStringList &layerOptions = QStringList(),
48+
bool skipAttributeCreation = FALSE // added in 1.7
49+
);
4850

4951
/** create shapefile and initialize it */
5052
QgsVectorFileWriter(const QString& vectorFileName,

‎src/app/ogr/qgsvectorlayersaveasdialog.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
#include <QTextCodec>
2727

2828
QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFlags fl )
29-
: QDialog( parent, fl )
30-
, mCRS( -1 )
29+
: QDialog( parent, fl )
30+
, mCRS( -1 )
3131
{
3232
setupUi( this );
3333

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

4848
QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();
4949
int idx = mEncodingComboBox->findText( enc );
50-
if ( idx < 0 )
50+
if( idx < 0 )
5151
{
5252
mEncodingComboBox->insertItem( 0, enc );
5353
idx = 0;
@@ -77,7 +77,7 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
7777
browseFilename->setEnabled( true );
7878
leFilename->setEnabled( true );
7979

80-
if ( format() == "KML" )
80+
if( format() == "KML" )
8181
{
8282
mEncodingComboBox->setCurrentIndex( mEncodingComboBox->findText( "UTF-8" ) );
8383
mEncodingComboBox->setDisabled( true );
@@ -94,7 +94,7 @@ void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
9494
QString dirName = leFilename->text().isEmpty() ? settings.value( "/UI/lastVectorFileFilterDir", "." ).toString() : leFilename->text();
9595
QString filterString = QgsVectorFileWriter::filterForDriver( format() );
9696
QString outputFile = QFileDialog::getSaveFileName( 0, tr( "Save layer as..." ), dirName, filterString );
97-
if ( !outputFile.isNull() )
97+
if( !outputFile.isNull() )
9898
{
9999
leFilename->setText( outputFile );
100100
}
@@ -103,12 +103,12 @@ void QgsVectorLayerSaveAsDialog::on_browseFilename_clicked()
103103
void QgsVectorLayerSaveAsDialog::on_browseCRS_clicked()
104104
{
105105
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector();
106-
if ( mCRS >= 0 )
106+
if( mCRS >= 0 )
107107
mySelector->setSelectedCrsId( mCRS );
108108
mySelector->setMessage( tr( "Select the coordinate reference system for the vector file. "
109109
"The data points will be transformed from the layer coordinate reference system." ) );
110110

111-
if ( mySelector->exec() )
111+
if( mySelector->exec() )
112112
{
113113
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
114114
mCRS = srs.srsid();
@@ -147,3 +147,8 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
147147
{
148148
return mOgrLayerOptions->toPlainText().split( "\n" );
149149
}
150+
151+
bool QgsVectorLayerSaveAsDialog::skipAttributeCreation() const
152+
{
153+
return mSkipAttributeCreation->isChecked();
154+
}

‎src/app/ogr/qgsvectorlayersaveasdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSav
4040
QStringList datasourceOptions() const;
4141
QStringList layerOptions() const;
4242
long crs() const;
43+
bool skipAttributeCreation() const;
4344

4445
private slots:
4546
void on_mFormatComboBox_currentIndexChanged( int idx );

‎src/core/qgsvectorfilewriter.cpp

Lines changed: 110 additions & 105 deletions
Large diffs are not rendered by default.

‎src/core/qgsvectorfilewriter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class CORE_EXPORT QgsVectorFileWriter
7878
bool onlySelected = false,
7979
QString *errorMessage = 0,
8080
const QStringList &datasourceOptions = QStringList(), // added in 1.6
81-
const QStringList &layerOptions = QStringList() // added in 1.6
81+
const QStringList &layerOptions = QStringList(), // added in 1.6
82+
bool skipAttributeCreation = false // added in 1.6
8283
);
8384

8485
/** create shapefile and initialize it */

‎src/ui/qgsvectorlayersaveasdialogbase.ui

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>383</width>
10-
<height>348</height>
10+
<height>427</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -133,6 +133,16 @@
133133
</property>
134134
</widget>
135135
</item>
136+
<item row="2" column="0" colspan="2">
137+
<widget class="QCheckBox" name="mSkipAttributeCreation">
138+
<property name="toolTip">
139+
<string>This allows to surpress attribute creation as some OGR drivers (eg. DGN, DXF) don't support it.</string>
140+
</property>
141+
<property name="text">
142+
<string>Skip attribute creation</string>
143+
</property>
144+
</widget>
145+
</item>
136146
</layout>
137147
</widget>
138148
</item>

0 commit comments

Comments
 (0)
Please sign in to comment.