skip malformed key-values pairs

add options example in docs
This commit is contained in:
Alexander Bruy 2017-01-02 10:02:48 +02:00
parent d718eb0f18
commit 85d40937b9
3 changed files with 11 additions and 6 deletions

View File

@ -50,7 +50,8 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
QStringList options() const;
/**
* Populate widget with user-defined options
* Populate widget with user-defined options. String should contain
* key=value pairs separated by spaces, e.g. "TILED=YES TFW=YES"
* @see options()
* @note added in QGIS 3.0
*/

View File

@ -644,10 +644,13 @@ void QgsRasterFormatSaveOptionsWidget::setOptions( const QString& options )
mOptionsTable->insertRow( rowCount );
values = opt.split( '=' );
QTableWidgetItem* nameItem = new QTableWidgetItem( values.at( 0 ) );
mOptionsTable->setItem( rowCount, 0, nameItem );
QTableWidgetItem* valueItem = new QTableWidgetItem( values.at( 1 ) );
mOptionsTable->setItem( rowCount, 0, valueItem );
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 );
}
}
mOptionsMap[ currentProfileKey()] = options.trimmed();

View File

@ -76,7 +76,8 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
QStringList options() const;
/**
* Populate widget with user-defined options
* Populate widget with user-defined options. String should contain
* key=value pairs separated by spaces, e.g. "TILED=YES TFW=YES"
* @see options()
* @note added in QGIS 3.0
*/