Skip to content
Permalink
Browse files

Value map: remove hack and fix double parenthesis

Followup #36804
  • Loading branch information
elpaso authored and nyalldawson committed Jun 8, 2020
1 parent e81af2c commit 7aefaf4c75f5d6c382fe8378a3290e52afe89c1c
@@ -32,7 +32,9 @@ QVariant QgsValueMapWidgetWrapper::value() const
QVariant v;

if ( mComboBox )
{
v = mComboBox->currentData();
}

if ( v == QgsValueMapFieldFormatter::NULL_VALUE )
v = QVariant( field().type() );
@@ -80,15 +82,15 @@ void QgsValueMapWidgetWrapper::updateValues( const QVariant &value, const QVaria

if ( mComboBox )
{
if ( mComboBox->findData( v ) == -1 && !( v.startsWith( '(' ) && v.endsWith( ')' ) ) )
if ( mComboBox->findData( v ) == -1 )
{
if ( value.isNull( ) )
{
mComboBox->addItem( QgsApplication::nullRepresentation().prepend( '(' ).append( ')' ), v );
}
else
{
mComboBox->addItem( v.prepend( '(' ).append( ')' ), v );
mComboBox->addItem( QString( v ).prepend( '(' ).append( ')' ), v );
}
}
mComboBox->setCurrentIndex( mComboBox->findData( v ) );
@@ -68,6 +68,7 @@ class GUI_EXPORT QgsValueMapWidgetWrapper : public QgsEditorWidgetWrapper
void updateValues( const QVariant &value, const QVariantList & = QVariantList() ) override;

QComboBox *mComboBox = nullptr;

};

#endif // QGSVALUEMAPWIDGETWRAPPER_H

0 comments on commit 7aefaf4

Please sign in to comment.
You can’t perform that action at this time.