Skip to content

Commit 727bca9

Browse files
committedJan 24, 2019
set the enabled state of widgets again in setEnabled
because if this is called for any reason directly we are save
1 parent 73e774b commit 727bca9

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed
 

‎src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
193193
if ( item )
194194
{
195195
item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
196+
//re-set enabled state because it's lost after reloading items
196197
item->setFlags( mEnabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
197198
lastChangedItem = item;
198199
}
@@ -218,7 +219,6 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
218219
}
219220
}
220221
mComboBox->setCurrentIndex( idx );
221-
mComboBox->setEnabled( mEnabled );
222222
}
223223
else if ( mLineEdit )
224224
{
@@ -230,7 +230,6 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
230230
break;
231231
}
232232
}
233-
mLineEdit->setEnabled( mEnabled );
234233
}
235234
}
236235

@@ -389,4 +388,24 @@ void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
389388
return;
390389

391390
mEnabled = enabled;
391+
392+
if ( mTableWidget )
393+
{
394+
auto signalBlockedTableWidget = whileBlocking( mTableWidget );
395+
Q_UNUSED( signalBlockedTableWidget )
396+
397+
for ( int j = 0; j < mTableWidget->rowCount(); j++ )
398+
{
399+
for ( int i = 0; i < mTableWidget->columnCount(); ++i )
400+
{
401+
QTableWidgetItem *item = mTableWidget->item( j, i );
402+
if ( item )
403+
{
404+
item->setFlags( enabled ? item->flags() | Qt::ItemIsEnabled : item->flags() & ~Qt::ItemIsEnabled );
405+
}
406+
}
407+
}
408+
}
409+
else
410+
QgsEditorWidgetWrapper::setEnabled( enabled );
392411
}

0 commit comments

Comments
 (0)
Please sign in to comment.