Skip to content
Permalink
Browse files

Fix setting the current GDAL profile options temporarily overwrites

the definition of one of the stored GDAL profiles

Fixes #41378
Fixes #40235

(cherry picked from commit 7454a0e)
  • Loading branch information
nyalldawson committed Feb 19, 2021
1 parent 5bdda19 commit 1848b8f865d1fbc760603400b00e99f7addcad3c
Showing with 16 additions and 8 deletions.
  1. +15 −8 src/gui/qgsrasterformatsaveoptionswidget.cpp
  2. +1 −0 src/gui/qgsrasterformatsaveoptionswidget.h
@@ -217,6 +217,7 @@ void QgsRasterFormatSaveOptionsWidget::updateProfiles()

void QgsRasterFormatSaveOptionsWidget::updateOptions()
{
mBlockOptionUpdates++;
QString myOptions = mOptionsMap.value( currentProfileKey() );
QStringList myOptionsList = myOptions.trimmed().split( ' ', QString::SkipEmptyParts );

@@ -248,6 +249,7 @@ void QgsRasterFormatSaveOptionsWidget::updateOptions()
mOptionsLineEdit->setCursorPosition( 0 );
}

mBlockOptionUpdates--;
emit optionsChanged();
}

@@ -363,6 +365,9 @@ QString QgsRasterFormatSaveOptionsWidget::validateOptions( bool gui, bool report

void QgsRasterFormatSaveOptionsWidget::optionsTableChanged()
{
if ( mBlockOptionUpdates )
return;

QTableWidgetItem *key, *value;
QString options;
for ( int i = 0; i < mOptionsTable->rowCount(); i++ )
@@ -591,30 +596,32 @@ void QgsRasterFormatSaveOptionsWidget::showEvent( QShowEvent *event )

void QgsRasterFormatSaveOptionsWidget::setOptions( const QString &options )
{
mOptionsTable->blockSignals( true );
mBlockOptionUpdates++;
mOptionsTable->clearContents();

QStringList values;
QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
const auto constOptionsList = optionsList;
for ( const QString &opt : constOptionsList )
const QStringList optionsList = options.trimmed().split( ' ', QString::SkipEmptyParts );
for ( const QString &opt : optionsList )
{
int rowCount = mOptionsTable->rowCount();
mOptionsTable->insertRow( rowCount );

values = opt.split( '=' );
const QStringList values = opt.split( '=' );
if ( values.count() == 2 )
{
QTableWidgetItem *nameItem = new QTableWidgetItem( values.at( 0 ) );
mOptionsTable->setItem( rowCount, 0, nameItem );
QTableWidgetItem *valueItem = new QTableWidgetItem( values.at( 1 ) );
mOptionsTable->setItem( rowCount, 0, valueItem );
mOptionsTable->setItem( rowCount, 1, valueItem );
}
}

// reset to no profile index, otherwise we are changing the definition of whichever profile
// is currently selected...
mProfileComboBox->setCurrentIndex( 0 );

mOptionsMap[ currentProfileKey()] = options.trimmed();
mOptionsLineEdit->setText( options.trimmed() );
mOptionsLineEdit->setCursorPosition( 0 );

mOptionsTable->blockSignals( false );
mBlockOptionUpdates--;
}
@@ -145,6 +145,7 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, private Ui::Q
static QMap< QString, QStringList > sBuiltinProfiles;
bool mPyramids = false;
QgsRaster::RasterPyramidsFormat mPyramidsFormat = QgsRaster::PyramidsGTiff;
int mBlockOptionUpdates = 0;

QString settingsKey( QString profile ) const SIP_FORCE;
QString currentProfileKey() const SIP_FORCE;

0 comments on commit 1848b8f

Please sign in to comment.