Skip to content
Permalink
Browse files

Merge pull request #5699 from m-kuhn/valueRelationMultiSelect

Fixes for Value relation widget, multi select
  • Loading branch information
m-kuhn committed Nov 23, 2017
2 parents 9d8a39f + b448826 commit e98842e3b97289625a7ddd42f9c0a3cbf9f2df90
@@ -29,7 +29,6 @@

QgsValueRelationWidgetWrapper::QgsValueRelationWidgetWrapper( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent )
: QgsEditorWidgetWrapper( vl, fieldIdx, editor, parent )
, mUpdating( false )
{
}

@@ -150,7 +149,11 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
{
if ( mListWidget )
{
QStringList checkList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );
QStringList checkList;
if ( value.type() == QVariant::StringList )
checkList = value.toStringList();
else if ( value.type() == QVariant::String )
checkList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );

for ( int i = 0; i < mListWidget->count(); ++i )
{
@@ -198,12 +201,13 @@ void QgsValueRelationWidgetWrapper::showIndeterminateState()

void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
{
if ( mUpdating )
if ( mEnabled == enabled )
return;

mEnabled = enabled;

if ( mListWidget )
{
mUpdating = true;
for ( int i = 0; i < mListWidget->count(); ++i )
{
QListWidgetItem *item = mListWidget->item( i );
@@ -213,7 +217,6 @@ void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
else
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
}
mUpdating = false;
}
else
QgsEditorWidgetWrapper::setEnabled( enabled );
@@ -78,7 +78,7 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
QgsValueRelationFieldFormatter::ValueRelationCache mCache;
QgsVectorLayer *mLayer = nullptr;

bool mUpdating;
bool mEnabled = false;

friend class QgsValueRelationWidgetFactory;
friend class TestQgsValueRelationWidgetWrapper;

0 comments on commit e98842e

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