From 0436281771d5d47f0c80d0694f938bb8f737da4c Mon Sep 17 00:00:00 2001 From: John Layt Date: Mon, 23 Jan 2012 22:34:09 +0000 Subject: 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 Reviewed-by: Gunnar Sletta --- src/gui/util/qvalidator.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/gui/util/qvalidator.cpp') 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 -- cgit v1.2.3