diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-01-18 13:04:21 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-25 00:58:12 +0100 |
commit | c0d30db45ca0af9c3010097d8cd8b1ae92cf83ea (patch) | |
tree | c59524151ae121b13fd8995c7dc2016babfa96d4 /src/gui/util | |
parent | 4830b790fed26ce6b8f410c7fd068596eb81791a (diff) |
Add a changed() signal to QValidator.
This provides a general notification of changes that may change the
validity of previously validated input.
Change-Id: I5ec6f127af60fdca68605fee903a08758bc01360
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui/util')
-rw-r--r-- | src/gui/util/qvalidator.cpp | 25 | ||||
-rw-r--r-- | src/gui/util/qvalidator.h | 3 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index b4478cfaa5..d806a18b64 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -131,6 +131,12 @@ QT_BEGIN_NAMESPACE \omitvalue Valid */ +/*! + \fn void QValidator::changed() + + This signal is emitted when any property that may affect the validity of + a string has changed. +*/ /*! \fn void QIntValidator::topChanged(int top) @@ -247,7 +253,10 @@ QLocale QValidator::locale() const void QValidator::setLocale(const QLocale &locale) { Q_D(QValidator); - d->locale = locale; + if (d->locale != locale) { + d->locale = locale; + emit changed(); + } } /*! @@ -452,15 +461,21 @@ void QIntValidator::fixup(QString &input) const void QIntValidator::setRange(int bottom, int top) { + bool rangeChanged = false; if (b != bottom) { b = bottom; + rangeChanged = true; emit bottomChanged(b); } if (t != top) { t = top; + rangeChanged = true; emit topChanged(t); } + + if (rangeChanged) + emit changed(); } @@ -697,20 +712,26 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL void QDoubleValidator::setRange(double minimum, double maximum, int decimals) { + bool rangeChanged = false; if (b != minimum) { b = minimum; + rangeChanged = true; emit bottomChanged(b); } if (t != maximum) { t = maximum; + rangeChanged = true; emit topChanged(t); } if (dec != decimals) { dec = decimals; + rangeChanged = true; emit decimalsChanged(dec); } + if (rangeChanged) + emit changed(); } /*! @@ -772,6 +793,7 @@ void QDoubleValidator::setNotation(Notation newNotation) if (d->notation != newNotation) { d->notation = newNotation; emit notationChanged(d->notation); + emit changed(); } } @@ -888,6 +910,7 @@ void QRegExpValidator::setRegExp(const QRegExp& rx) if (r != rx) { r = rx; emit regExpChanged(r); + emit changed(); } } diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h index 0ae0e52833..a5f6beec55 100644 --- a/src/gui/util/qvalidator.h +++ b/src/gui/util/qvalidator.h @@ -76,6 +76,9 @@ public: virtual State validate(QString &, int &) const = 0; virtual void fixup(QString &) const; +Q_SIGNALS: + void changed(); + protected: QValidator(QObjectPrivate &d, QObject *parent); QValidator(QValidatorPrivate &d, QObject *parent); |