diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-11-18 11:21:27 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-11-20 16:38:23 +0100 |
commit | 94e40c7c7874a2bceb9d6f01947c1668fd92f559 (patch) | |
tree | 2c7472f80b155456d1697d4eb8f74de684418d44 /src | |
parent | aef2ed910861c732b401bcb17fe10dc9901c45bf (diff) |
Observe QLocale::RejectGroupSeparator in QInt/DoubleValidator.
Pass it as additional boolean parameter to QLocaleData::validateChars().
Task-number: QTBUG-42522
Change-Id: I4b2367f4e2fdcbd17e343d215edad57e6687697a
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 4 | ||||
-rw-r--r-- | src/gui/util/qvalidator.cpp | 10 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index a253057435..a923be50c0 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3144,7 +3144,7 @@ bool QLocaleData::numberToCLocale(const QChar *str, int len, } bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArray *buff, - int decDigits) const + int decDigits, bool rejectGroupSeparators) const { buff->clear(); buff->reserve(str.length()); @@ -3205,7 +3205,7 @@ bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArr case ',': //it can only be placed after a digit which is before the decimal point - if (!lastWasDigit || decPointCnt > 0) + if (rejectGroupSeparators || !lastWasDigit || decPointCnt > 0) return false; break; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c33ced35d5..c5e62027c4 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -251,7 +251,9 @@ public: inline char digitToCLocale(QChar c) const; // this function is used in QIntValidator (QtGui) - Q_CORE_EXPORT bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const; + Q_CORE_EXPORT bool validateChars(const QString &str, NumberMode numMode, + QByteArray *buff, int decDigits = -1, + bool rejectGroupSeparators = false) const; public: quint16 m_language_id, m_script_id, m_country_id; diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index aac9282710..f879847935 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -398,7 +398,8 @@ static qlonglong pow10(int exp) QValidator::State QIntValidator::validate(QString & input, int&) const { QByteArray buff; - if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff)) { + if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff, + -1, locale().numberOptions() & QLocale::RejectGroupSeparator)) { return Invalid; } @@ -437,7 +438,8 @@ QValidator::State QIntValidator::validate(QString & input, int&) const void QIntValidator::fixup(QString &input) const { QByteArray buff; - if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff)) { + if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff, + -1, locale().numberOptions() & QLocale::RejectGroupSeparator)) { return; } bool ok, overflow; @@ -658,8 +660,10 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL { Q_Q(const QDoubleValidator); QByteArray buff; - if (!locale.d->m_data->validateChars(input, numMode, &buff, q->dec)) + if (!locale.d->m_data->validateChars(input, numMode, &buff, q->dec, + locale.numberOptions() & QLocale::RejectGroupSeparator)) { return QValidator::Invalid; + } if (buff.isEmpty()) return QValidator::Intermediate; |