aboutsummaryrefslogtreecommitdiffstats
path: root/src/templates/qquickbuttongroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/templates/qquickbuttongroup.cpp')
-rw-r--r--src/templates/qquickbuttongroup.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/templates/qquickbuttongroup.cpp b/src/templates/qquickbuttongroup.cpp
index 0865277e..5f0ec6b1 100644
--- a/src/templates/qquickbuttongroup.cpp
+++ b/src/templates/qquickbuttongroup.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickButtonGroup
\inqmlmodule Qt.labs.controls
\ingroup utilities
- \brief An exclusive group of checkable controls.
+ \brief A mutually-exclusive group of checkable controls.
ButtonGroup is a non-visual, mutually exclusive group of buttons.
It is used with controls such as RadioButton, where only one of the options
@@ -129,7 +129,7 @@ class QQuickButtonGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickButtonGroup)
public:
- QQuickButtonGroupPrivate() : checkedButton(Q_NULLPTR) { }
+ QQuickButtonGroupPrivate() : checkedButton(nullptr) { }
void clear();
void updateCurrent();
@@ -145,8 +145,8 @@ public:
void QQuickButtonGroupPrivate::clear()
{
- foreach (QQuickAbstractButton *button, buttons) {
- QQuickAbstractButtonPrivate::get(button)->group = Q_NULLPTR;
+ for (QQuickAbstractButton *button : qAsConst(buttons)) {
+ QQuickAbstractButtonPrivate::get(button)->group = nullptr;
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, this, &QQuickButtonGroupPrivate::updateCurrent);
}
buttons.clear();
@@ -184,7 +184,7 @@ void QQuickButtonGroupPrivate::buttons_clear(QQmlListProperty<QQuickAbstractButt
if (!p->buttons.isEmpty()) {
p->clear();
QQuickButtonGroup *q = static_cast<QQuickButtonGroup *>(prop->object);
- q->setCheckedButton(Q_NULLPTR);
+ q->setCheckedButton(nullptr);
emit q->buttonsChanged();
}
}
@@ -221,14 +221,15 @@ QQuickAbstractButton *QQuickButtonGroup::checkedButton() const
void QQuickButtonGroup::setCheckedButton(QQuickAbstractButton *checkedButton)
{
Q_D(QQuickButtonGroup);
- if (d->checkedButton != checkedButton) {
- if (d->checkedButton)
- d->checkedButton->setChecked(false);
- d->checkedButton = checkedButton;
- if (checkedButton)
- checkedButton->setChecked(true);
- emit checkedButtonChanged();
- }
+ if (d->checkedButton == checkedButton)
+ return;
+
+ if (d->checkedButton)
+ d->checkedButton->setChecked(false);
+ d->checkedButton = checkedButton;
+ if (checkedButton)
+ checkedButton->setChecked(true);
+ emit checkedButtonChanged();
}
/*!
@@ -312,11 +313,11 @@ void QQuickButtonGroup::removeButton(QQuickAbstractButton *button)
if (!button || !d->buttons.contains(button))
return;
- QQuickAbstractButtonPrivate::get(button)->group = Q_NULLPTR;
+ QQuickAbstractButtonPrivate::get(button)->group = nullptr;
QObjectPrivate::disconnect(button, &QQuickAbstractButton::checkedChanged, d, &QQuickButtonGroupPrivate::updateCurrent);
if (d->checkedButton == button)
- setCheckedButton(Q_NULLPTR);
+ setCheckedButton(nullptr);
d->buttons.removeOne(button);
emit buttonsChanged();
@@ -325,7 +326,7 @@ void QQuickButtonGroup::removeButton(QQuickAbstractButton *button)
class QQuickButtonGroupAttachedPrivate : public QObjectPrivate
{
public:
- QQuickButtonGroupAttachedPrivate() : group(Q_NULLPTR) { }
+ QQuickButtonGroupAttachedPrivate() : group(nullptr) { }
QQuickButtonGroup *group;
};
@@ -366,14 +367,15 @@ QQuickButtonGroup *QQuickButtonGroupAttached::group() const
void QQuickButtonGroupAttached::setGroup(QQuickButtonGroup *group)
{
Q_D(QQuickButtonGroupAttached);
- if (d->group != group) {
- if (d->group)
- d->group->removeButton(qobject_cast<QQuickAbstractButton*>(parent()));
- d->group = group;
- if (group)
- group->addButton(qobject_cast<QQuickAbstractButton*>(parent()));
- emit groupChanged();
- }
+ if (d->group == group)
+ return;
+
+ if (d->group)
+ d->group->removeButton(qobject_cast<QQuickAbstractButton*>(parent()));
+ d->group = group;
+ if (group)
+ group->addButton(qobject_cast<QQuickAbstractButton*>(parent()));
+ emit groupChanged();
}
QT_END_NAMESPACE