mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Fix checkbox search widget wrapper for boolean field types
Fixes #60152
This commit is contained in:
parent
af393490eb
commit
57d5bb0f67
@ -43,8 +43,19 @@ QVariant QgsCheckboxSearchWidgetWrapper::value() const
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
const QMetaType::Type fieldType = layer()->fields().at( mFieldIdx ).type();
|
||||
|
||||
if ( mCheckBox )
|
||||
v = mCheckBox->isChecked() ? config( QStringLiteral( "CheckedState" ), true ) : config( QStringLiteral( "UncheckedState" ), false );
|
||||
{
|
||||
if ( fieldType == QMetaType::Type::Bool )
|
||||
{
|
||||
v = mCheckBox->isChecked();
|
||||
}
|
||||
else
|
||||
{
|
||||
v = mCheckBox->isChecked() ? config( QStringLiteral( "CheckedState" ), true ) : config( QStringLiteral( "UncheckedState" ), false );
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -518,6 +518,9 @@ class PyQgsCheckboxSearchWidgetWrapper(QgisTestCase):
|
||||
parent = QWidget()
|
||||
w = QgsCheckboxSearchWidgetWrapper(layer, 2)
|
||||
w.initWidget(parent)
|
||||
# boolean fields should ignore CheckedState/UncheckedState config
|
||||
config = {"CheckedState": 5, "UncheckedState": 9}
|
||||
w.setConfig(config)
|
||||
c = w.widget()
|
||||
c.setChecked(True)
|
||||
self.assertEqual(
|
||||
|
Loading…
x
Reference in New Issue
Block a user