20#include "moc_qgscheckboxwidgetwrapper.cpp"
22using namespace Qt::StringLiterals;
32 if (
config( u
"AllowNullState"_s ).toBool() && mCheckBox && mCheckBox->checkState() == Qt::PartiallyChecked )
37 if (
field().type() == QMetaType::Type::Bool )
41 return mGroupBox->isChecked();
45 return mCheckBox->isChecked();
52 return mGroupBox->isChecked() ?
config( u
"CheckedState"_s ) :
config( u
"UncheckedState"_s );
56 return mCheckBox->isChecked() ?
config( u
"CheckedState"_s ) :
config( u
"UncheckedState"_s );
67 mIndeterminateStateEnabled =
true;
68 whileBlocking( mCheckBox )->setCheckState( Qt::PartiallyChecked );
74 return new QCheckBox( parent );
79 mCheckBox = qobject_cast<QCheckBox *>( editor );
80 mGroupBox = qobject_cast<QGroupBox *>( editor );
83 connect( mCheckBox, &QCheckBox::stateChanged,
this, [
this](
int state ) {
84 if ( !mIndeterminateStateEnabled && mCheckBox->checkState() != Qt::PartiallyChecked )
86 mCheckBox->setTristate(
false );
94 connect( mGroupBox, &QGroupBox::toggled,
this, [
this](
bool state ) {
104 return mCheckBox || mGroupBox;
107void QgsCheckboxWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
109 Qt::CheckState state = Qt::Unchecked;
111 if (
config( u
"AllowNullState"_s ).toBool() &&
value.isNull() )
113 state = Qt::PartiallyChecked;
117 if (
field().type() == QMetaType::Type::Bool )
119 state =
value.toBool() ? Qt::Checked : Qt::Unchecked;
123 state =
value ==
config( u
"CheckedState"_s ) ? Qt::Checked : Qt::Unchecked;
129 mGroupBox->setChecked( state == Qt::Checked );
134 mCheckBox->setTristate( state == Qt::PartiallyChecked );
135 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.