diff options
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 4dd7518c..d8d34d28 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -123,6 +123,7 @@ public: int boundValue(int value) const; void updateValue(); + bool setValue(int value); int effectiveStepSize() const; @@ -181,6 +182,24 @@ void QQuickSpinBoxPrivate::updateValue() } } +bool QQuickSpinBoxPrivate::setValue(int newValue) +{ + Q_Q(QQuickSpinBox); + if (q->isComponentComplete()) + newValue = boundValue(newValue); + + if (value == newValue) + return false; + + value = newValue; + + updateUpEnabled(); + updateDownEnabled(); + + emit q->valueChanged(); + return true; +} + int QQuickSpinBoxPrivate::effectiveStepSize() const { return from > to ? -1 * stepSize : stepSize; @@ -351,8 +370,12 @@ void QQuickSpinBox::setFrom(int from) d->from = from; emit fromChanged(); - if (isComponentComplete()) - setValue(d->value); + if (isComponentComplete()) { + if (!d->setValue(d->value)) { + d->updateUpEnabled(); + d->updateDownEnabled(); + } + } } /*! @@ -376,8 +399,12 @@ void QQuickSpinBox::setTo(int to) d->to = to; emit toChanged(); - if (isComponentComplete()) - setValue(d->value); + if (isComponentComplete()) { + if (!d->setValue(d->value)) { + d->updateUpEnabled(); + d->updateDownEnabled(); + } + } } /*! @@ -394,18 +421,7 @@ int QQuickSpinBox::value() const void QQuickSpinBox::setValue(int value) { Q_D(QQuickSpinBox); - if (isComponentComplete()) - value = d->boundValue(value); - - if (d->value == value) - return; - - d->value = value; - - d->updateUpEnabled(); - d->updateDownEnabled(); - - emit valueChanged(); + d->setValue(value); } /*! |