aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickabstractbutton.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-12-20 22:28:43 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-12-21 12:07:22 +0000
commitfed1476148399f4402ce2069874e7c66e834e764 (patch)
treebaac437da4423d7be890c01e7064de04b9bf1cf0 /src/quicktemplates2/qquickabstractbutton.cpp
parent7aee63b8a5db7721e079e1a3402a3ca6b4b1d06e (diff)
Add QQuickAbstractButton::buttonChange()
Merge the various virtuals to a single method that takes an enum value indicating the type of the change. This way we don't need to keep adding more and more virtuals, but can just extend the enum. The next in line is ButtonPressedChanged for the upcoming DelayButton. Change-Id: I40ebf170470790730217aba48c80daff8118dfba Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickabstractbutton.cpp')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 1724ead1..c47e6dcb 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -268,10 +268,9 @@ void QQuickAbstractButton::setText(const QString &text)
if (d->text == text)
return;
- QString oldText = d->text;
d->text = text;
setAccessibleName(text);
- textChange(text, oldText);
+ buttonChange(ButtonTextChange);
emit textChanged();
}
@@ -368,7 +367,7 @@ void QQuickAbstractButton::setChecked(bool checked)
d->checked = checked;
setAccessibleProperty("checked", checked);
- checkStateSet();
+ buttonChange(ButtonCheckedChange);
emit checkedChanged();
}
@@ -401,7 +400,7 @@ void QQuickAbstractButton::setCheckable(bool checkable)
d->checkable = checkable;
setAccessibleProperty("checkable", checkable);
- checkableChange();
+ buttonChange(ButtonCheckableChange);
emit checkableChanged();
}
@@ -449,7 +448,7 @@ void QQuickAbstractButton::setAutoRepeat(bool repeat)
d->stopPressRepeat();
d->autoRepeat = repeat;
- autoRepeatChange();
+ buttonChange(ButtonAutoRepeatChange);
}
/*!
@@ -623,13 +622,19 @@ void QQuickAbstractButton::timerEvent(QTimerEvent *event)
}
}
-void QQuickAbstractButton::checkStateSet()
+void QQuickAbstractButton::buttonChange(ButtonChange change)
{
Q_D(QQuickAbstractButton);
- if (d->checked) {
- QQuickAbstractButton *button = d->findCheckedButton();
- if (button && button != this)
- button->setChecked(false);
+ switch (change) {
+ case ButtonCheckedChange:
+ if (d->checked) {
+ QQuickAbstractButton *button = d->findCheckedButton();
+ if (button && button != this)
+ button->setChecked(false);
+ }
+ break;
+ default:
+ break;
}
}
@@ -640,20 +645,6 @@ void QQuickAbstractButton::nextCheckState()
d->toggle(!d->checked);
}
-void QQuickAbstractButton::checkableChange()
-{
-}
-
-void QQuickAbstractButton::autoRepeatChange()
-{
-}
-
-void QQuickAbstractButton::textChange(const QString &newText, const QString &oldText)
-{
- Q_UNUSED(newText);
- Q_UNUSED(oldText);
-}
-
#ifndef QT_NO_ACCESSIBILITY
void QQuickAbstractButton::accessibilityActiveChanged(bool active)
{