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 ) {
80 if ( !mIndeterminateStateEnabled && mCheckBox->checkState() != Qt::PartiallyChecked )
82 mCheckBox->setTristate( false );
90 connect( mGroupBox, &QGroupBox::toggled,
this, [=](
bool state ) {
100 return mCheckBox || mGroupBox;
103void QgsCheckboxWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
105 Qt::CheckState state = Qt::Unchecked;
107 if (
config( QStringLiteral(
"AllowNullState" ) ).toBool() &&
value.isNull() )
109 state = Qt::PartiallyChecked;
113 if (
field().type() == QMetaType::Type::Bool )
115 state =
value.toBool() ? Qt::Checked : Qt::Unchecked;
119 state =
value ==
config( QStringLiteral(
"CheckedState" ) ) ? Qt::Checked : Qt::Unchecked;
125 mGroupBox->setChecked( state == Qt::Checked );
130 mCheckBox->setTristate( state == Qt::PartiallyChecked );
131 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.