summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qvalidator.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-12-09 09:59:10 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-12-09 10:04:05 (GMT)
commitb81b8e43ad57183ed66086ec90cabef5906ab9a2 (patch)
tree65615a52ebcf53b683f66be44c0a04bf44d04180 /src/gui/widgets/qvalidator.cpp
parent258bc1c288ec9be90a2a101b81f0a3c58d193bca (diff)
downloadQt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.zip
Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.gz
Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.bz2
Fix the int validator not handling the locale
Task-number: QTBUG-3179 Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/widgets/qvalidator.cpp')
-rw-r--r--src/gui/widgets/qvalidator.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/widgets/qvalidator.cpp
index 405bf04..83f603d 100644
--- a/src/gui/widgets/qvalidator.cpp
+++ b/src/gui/widgets/qvalidator.cpp
@@ -400,8 +400,10 @@ QValidator::State QIntValidator::validate(QString & input, int&) const
qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
if (overflow || !ok)
return Invalid;
- if (entered >= b && entered <= t)
- return Acceptable;
+ if (entered >= b && entered <= t) {
+ locale().toInt(input, &ok);
+ return ok ? Acceptable : Intermediate;
+ }
if (entered >= 0) {
// the -entered < b condition is necessary to allow people to type
@@ -412,6 +414,20 @@ QValidator::State QIntValidator::validate(QString & input, int&) const
}
}
+/*! \reimp */
+void QIntValidator::fixup(QString &input) const
+{
+ QByteArray buff;
+ if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
+ QLocale cl(QLocale::C);
+ if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff))
+ return;
+ }
+ bool ok, overflow;
+ qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
+ if (ok && !overflow)
+ input = locale().toString(entered);
+}
/*!
Sets the range of the validator to only accept integers between \a