20#include "moc_qgscheckboxwidgetwrapper.cpp"
22using namespace Qt::StringLiterals;
33 if (
config( u
"AllowNullState"_s ).toBool() && mCheckBox && mCheckBox->checkState() == Qt::PartiallyChecked )
38 if (
field().type() == QMetaType::Type::Bool )
42 return mGroupBox->isChecked();
46 return mCheckBox->isChecked();
53 return mGroupBox->isChecked() ?
config( u
"CheckedState"_s ) :
config( u
"UncheckedState"_s );
57 return mCheckBox->isChecked() ?
config( u
"CheckedState"_s ) :
config( u
"UncheckedState"_s );
68 mIndeterminateStateEnabled =
true;
69 whileBlocking( mCheckBox )->setCheckState( Qt::PartiallyChecked );
75 return new QCheckBox( parent );
80 mCheckBox = qobject_cast<QCheckBox *>( editor );
81 mGroupBox = qobject_cast<QGroupBox *>( editor );
84 connect( mCheckBox, &QCheckBox::stateChanged,
this, [
this](
int state ) {
85 if ( !mIndeterminateStateEnabled && mCheckBox->checkState() != Qt::PartiallyChecked )
87 mCheckBox->setTristate(
false );
95 connect( mGroupBox, &QGroupBox::toggled,
this, [
this](
bool state ) {
105 return mCheckBox || mGroupBox;
108void QgsCheckboxWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
110 Qt::CheckState state = Qt::Unchecked;
112 if (
config( u
"AllowNullState"_s ).toBool() &&
value.isNull() )
114 state = Qt::PartiallyChecked;
118 if (
field().type() == QMetaType::Type::Bool )
120 state =
value.toBool() ? Qt::Checked : Qt::Unchecked;
124 state =
value ==
config( u
"CheckedState"_s ) ? Qt::Checked : Qt::Unchecked;
130 mGroupBox->setChecked( state == Qt::Checked );
135 mCheckBox->setTristate( state == Qt::PartiallyChecked );
136 mCheckBox->setCheckState( state );
Represents a vector layer which manages a vector based dataset.
#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.