Skip to content
Permalink
Browse files
Merge pull request #3082 from rouault/vectorfilewriter_cleanup_and_en…
…coding_improvement

Vectorfilewriter cleanup and encoding improvement
  • Loading branch information
rouault committed May 19, 2016
2 parents a19741b + 1ab2977 commit 0078b33ed2cc5f5817527e2e7ceb1029bbc6c679
@@ -74,14 +74,16 @@ class QgsVectorFileWriter
{
MetaData();

MetaData( const QString& longName, const QString& trLongName, const QString& glob, const QString& ext, const QMap<QString, QgsVectorFileWriter::Option*>& driverOptions, const QMap<QString, QgsVectorFileWriter::Option*>& layerOptions );
MetaData( const QString& longName, const QString& trLongName, const QString& glob, const QString& ext, const QMap<QString, QgsVectorFileWriter::Option*>& driverOptions, const QMap<QString, QgsVectorFileWriter::Option*>& layerOptions, const QString& compulsoryEncoding = QString() );

QString longName;
QString trLongName;
QString glob;
QString ext;
QMap<QString, QgsVectorFileWriter::Option*> driverOptions;
QMap<QString, QgsVectorFileWriter::Option*> layerOptions;
/** Some formats require a compulsory encoding, typically UTF-8. If no compulsory encoding, empty string */
QString compulsoryEncoding;
};

enum WriterError
@@ -228,8 +228,6 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx

if ( format() == "KML" )
{
mEncodingComboBox->setCurrentIndex( mEncodingComboBox->findText( "UTF-8" ) );
mEncodingComboBox->setDisabled( true );
mAttributesSelection->setEnabled( true );
selectAllFields = false;
}
@@ -240,7 +238,6 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
}
else
{
mEncodingComboBox->setEnabled( true );
mAttributesSelection->setEnabled( true );
fieldsAsDisplayedValues = ( format() == "CSV" || format() == "XLS" || format() == "XLSX" || format() == "ODS" );
}
@@ -372,6 +369,29 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
{
mLayerOptionsGroupBox->setVisible( false );
}

if ( driverMetaData.compulsoryEncoding.isEmpty() )
{
mEncodingComboBox->setEnabled( true );
}
else
{
int idx = mEncodingComboBox->findText( driverMetaData.compulsoryEncoding );
if ( idx >= 0 )
{
mEncodingComboBox->setCurrentIndex( idx );
mEncodingComboBox->setDisabled( true );
}
else
{
mEncodingComboBox->setEnabled( true );
}
}

}
else
{
mEncodingComboBox->setEnabled( true );
}
}

0 comments on commit 0078b33

Please sign in to comment.