18#include "moc_qgscheckboxwidgetwrapper.cpp"
29 if (
config( QStringLiteral(
"AllowNullState" ) ).toBool() && mCheckBox && mCheckBox->checkState() == Qt::PartiallyChecked )
34 if (
field().type() == QMetaType::Type::Bool )
38 return mGroupBox->isChecked();
42 return mCheckBox->isChecked();
49 return mGroupBox->isChecked() ?
config( QStringLiteral(
"CheckedState" ) ) :
config( QStringLiteral(
"UncheckedState" ) );
53 return mCheckBox->isChecked() ?
config( QStringLiteral(
"CheckedState" ) ) :
config( QStringLiteral(
"UncheckedState" ) );
64 mIndeterminateStateEnabled =
true;
65 whileBlocking( mCheckBox )->setCheckState( Qt::PartiallyChecked );
71 return new QCheckBox( parent );
76 mCheckBox = qobject_cast<QCheckBox *>( editor );
77 mGroupBox = qobject_cast<QGroupBox *>( editor );
80 connect( mCheckBox, &QCheckBox::stateChanged,
this, [
this](
int state ) {
81 if ( !mIndeterminateStateEnabled && mCheckBox->checkState() != Qt::PartiallyChecked )
83 mCheckBox->setTristate(
false );
91 connect( mGroupBox, &QGroupBox::toggled,
this, [
this](
bool state ) {
101 return mCheckBox || mGroupBox;
104void QgsCheckboxWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
106 Qt::CheckState state = Qt::Unchecked;
108 if (
config( QStringLiteral(
"AllowNullState" ) ).toBool() &&
value.isNull() )
110 state = Qt::PartiallyChecked;
114 if (
field().type() == QMetaType::Type::Bool )
116 state =
value.toBool() ? Qt::Checked : Qt::Unchecked;
120 state =
value ==
config( QStringLiteral(
"CheckedState" ) ) ? Qt::Checked : Qt::Unchecked;
126 mGroupBox->setChecked( state == Qt::Checked );
131 mCheckBox->setTristate( state == Qt::PartiallyChecked );
132 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.