QgsVectorLayerSaveAsDialog: use QgsVectorFileWriter::MetaData::compulsoryEncoding to initialize the encoding combobox

This commit is contained in:
Even Rouault 2016-05-19 11:41:50 +02:00
parent 3ee7d59e18
commit 1ab29771b7

View File

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