Skip to content

Commit

Permalink
set the enabled state of widgets again in setEnabled
Browse files Browse the repository at this point in the history
because if this is called for any reason directly we are save
  • Loading branch information
signedav committed Jan 24, 2019
1 parent 73e774b commit 727bca9
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Expand Up @@ -193,6 +193,7 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
if ( item )
{
item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
//re-set enabled state because it's lost after reloading items
item->setFlags( mEnabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
lastChangedItem = item;
}
Expand All @@ -218,7 +219,6 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
}
}
mComboBox->setCurrentIndex( idx );
mComboBox->setEnabled( mEnabled );
}
else if ( mLineEdit )
{
Expand All @@ -230,7 +230,6 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
break;
}
}
mLineEdit->setEnabled( mEnabled );
}
}

Expand Down Expand Up @@ -389,4 +388,24 @@ void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
return;

mEnabled = enabled;

if ( mTableWidget )
{
auto signalBlockedTableWidget = whileBlocking( mTableWidget );
Q_UNUSED( signalBlockedTableWidget )

for ( int j = 0; j < mTableWidget->rowCount(); j++ )
{
for ( int i = 0; i < mTableWidget->columnCount(); ++i )
{
QTableWidgetItem *item = mTableWidget->item( j, i );
if ( item )
{
item->setFlags( enabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
}
}
}
}
else
QgsEditorWidgetWrapper::setEnabled( enabled );
}

0 comments on commit 727bca9

Please sign in to comment.