17#include "moc_qgscheckboxwidgetwrapper.cpp"
28 if (
config( QStringLiteral(
"AllowNullState" ) ).toBool() && mCheckBox && mCheckBox->checkState() == Qt::PartiallyChecked )
33 if (
field().type() == QMetaType::Type::Bool )
37 return mGroupBox->isChecked();
41 return mCheckBox->isChecked();
48 return mGroupBox->isChecked() ?
config( QStringLiteral(
"CheckedState" ) ) :
config( QStringLiteral(
"UncheckedState" ) );
52 return mCheckBox->isChecked() ?
config( QStringLiteral(
"CheckedState" ) ) :
config( QStringLiteral(
"UncheckedState" ) );
63 mIndeterminateStateEnabled =
true;
64 whileBlocking( mCheckBox )->setCheckState( Qt::PartiallyChecked );
70 return new QCheckBox( parent );
75 mCheckBox = qobject_cast<QCheckBox *>( editor );
76 mGroupBox = qobject_cast<QGroupBox *>( editor );
79 connect( mCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int state )
81 if ( !mIndeterminateStateEnabled && mCheckBox->checkState() != Qt::PartiallyChecked )
83 mCheckBox->setTristate( false );
91 connect( mGroupBox, &QGroupBox::toggled,
this, [ = ](
bool state )
102 return mCheckBox || mGroupBox;
105void QgsCheckboxWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
107 Qt::CheckState state = Qt::Unchecked;
109 if (
config( QStringLiteral(
"AllowNullState" ) ).toBool() &&
value.isNull() )
111 state = Qt::PartiallyChecked;
115 if (
field().type() == QMetaType::Type::Bool )
117 state =
value.toBool() ? Qt::Checked : Qt::Unchecked;
121 state =
value ==
config( QStringLiteral(
"CheckedState" ) ) ? Qt::Checked : Qt::Unchecked;
127 mGroupBox->setChecked( state == Qt::Checked );
132 mCheckBox->setTristate( state == Qt::PartiallyChecked );
133 mCheckBox->setCheckState( state );
Represents a vector layer which manages a vector based data sets.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.