Skip to content

Commit 1ab2977

Browse files
committed
QgsVectorLayerSaveAsDialog: use QgsVectorFileWriter::MetaData::compulsoryEncoding to initialize the encoding combobox
1 parent 3ee7d59 commit 1ab2977

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/app/ogr/qgsvectorlayersaveasdialog.cpp

+23-3
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
228228

229229
if ( format() == "KML" )
230230
{
231-
mEncodingComboBox->setCurrentIndex( mEncodingComboBox->findText( "UTF-8" ) );
232-
mEncodingComboBox->setDisabled( true );
233231
mAttributesSelection->setEnabled( true );
234232
selectAllFields = false;
235233
}
@@ -240,7 +238,6 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
240238
}
241239
else
242240
{
243-
mEncodingComboBox->setEnabled( true );
244241
mAttributesSelection->setEnabled( true );
245242
fieldsAsDisplayedValues = ( format() == "CSV" || format() == "XLS" || format() == "XLSX" || format() == "ODS" );
246243
}
@@ -372,6 +369,29 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
372369
{
373370
mLayerOptionsGroupBox->setVisible( false );
374371
}
372+
373+
if ( driverMetaData.compulsoryEncoding.isEmpty() )
374+
{
375+
mEncodingComboBox->setEnabled( true );
376+
}
377+
else
378+
{
379+
int idx = mEncodingComboBox->findText( driverMetaData.compulsoryEncoding );
380+
if ( idx >= 0 )
381+
{
382+
mEncodingComboBox->setCurrentIndex( idx );
383+
mEncodingComboBox->setDisabled( true );
384+
}
385+
else
386+
{
387+
mEncodingComboBox->setEnabled( true );
388+
}
389+
}
390+
391+
}
392+
else
393+
{
394+
mEncodingComboBox->setEnabled( true );
375395
}
376396
}
377397

0 commit comments

Comments
 (0)