diff options
author | John Layt <jlayt@kde.org> | 2012-01-23 22:34:09 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-31 07:02:11 +0100 |
commit | 0436281771d5d47f0c80d0694f938bb8f737da4c (patch) | |
tree | 32438375b7ccc29bf42ee4e1742149c9b0dcc5d0 /src/gui/util/qvalidator.cpp | |
parent | 9c1f3bce4dd078bf395292e7b81035da4a2f91cf (diff) |
QValidator: Don't fallback to C Locale when validating input
QIntValidator and QDoubleValidator used to accept C formatted input if
the input wasn't valid in the default locale. This change removes this,
only the default locale is now used.
Change-Id: I8b2d8f9f3849abe3fcb5c12083aae542a76eaf90
Reviewed-by: Jonas Gastal <jgastal@profusion.mobi>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/util/qvalidator.cpp')
-rw-r--r-- | src/gui/util/qvalidator.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 619b19157d..faff264723 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -321,9 +321,7 @@ void QValidator::fixup(QString &) const or individually with setBottom() and setTop(). QIntValidator uses its locale() to interpret the number. For example, - in Arabic locales, QIntValidator will accept Arabic digits. In addition, - QIntValidator is always guaranteed to accept a number formatted according - to the "C" locale. + in Arabic locales, QIntValidator will accept Arabic digits. \sa QDoubleValidator, QRegExpValidator, {Line Edits Example} */ @@ -403,9 +401,7 @@ QValidator::State QIntValidator::validate(QString & input, int&) const { QByteArray buff; if (!locale().d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) { - QLocale cl(QLocale::C); - if (!cl.d()->validateChars(input, QLocalePrivate::IntegerMode, &buff)) - return Invalid; + return Invalid; } if (buff.isEmpty()) @@ -444,9 +440,7 @@ 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; + return; } bool ok, overflow; qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow); @@ -561,10 +555,6 @@ public: in the German locale, "1,234" will be accepted as the fractional number 1.234. In Arabic locales, QDoubleValidator will accept Arabic digits. - In addition, QDoubleValidator is always guaranteed to accept a number - formatted according to the "C" locale. QDoubleValidator will not accept - numbers with thousand-separators. - \sa QIntValidator, QRegExpValidator, {Line Edits Example} */ @@ -658,11 +648,7 @@ QValidator::State QDoubleValidator::validate(QString & input, int &) const break; } - State currentLocaleValidation = d->validateWithLocale(input, numMode, locale()); - if (currentLocaleValidation == Acceptable || locale().language() == QLocale::C) - return currentLocaleValidation; - State cLocaleValidation = d->validateWithLocale(input, numMode, QLocale(QLocale::C)); - return qMax(currentLocaleValidation, cLocaleValidation); + return d->validateWithLocale(input, numMode, locale()); } QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const |