Skip to content

Commit

Permalink
Value map: remove hack and fix double parenthesis
Browse files Browse the repository at this point in the history
Followup #36804
  • Loading branch information
elpaso authored and nyalldawson committed Jun 8, 2020
1 parent e81af2c commit 7aefaf4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ QVariant QgsValueMapWidgetWrapper::value() const
QVariant v;

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

if ( v == QgsValueMapFieldFormatter::NULL_VALUE )
v = QVariant( field().type() );
Expand Down Expand Up @@ -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 ) );
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsvaluemapwidgetwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.