QLocalePrivate: move the stringToXxx to QLocaleData
Along with some more helper functions. There are two more functions used in QIntValidator Change-Id: I469ef40426cbb73ab515454bd5ecb12d944f5c0a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
1b26ef0c0c
commit
ed7458a8a6
@ -3296,7 +3296,7 @@ qlonglong QByteArray::toLongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
return QLocalePrivate::bytearrayToLongLong(nulTerminated().constData(), base, ok);
|
||||
return QLocaleData::bytearrayToLongLong(nulTerminated().constData(), base, ok);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3329,7 +3329,7 @@ qulonglong QByteArray::toULongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
return QLocalePrivate::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok);
|
||||
return QLocaleData::bytearrayToUnsLongLong(nulTerminated().constData(), base, ok);
|
||||
}
|
||||
|
||||
|
||||
@ -3544,7 +3544,7 @@ ushort QByteArray::toUShort(bool *ok, int base) const
|
||||
|
||||
double QByteArray::toDouble(bool *ok) const
|
||||
{
|
||||
return QLocalePrivate::bytearrayToDouble(nulTerminated().constData(), ok);
|
||||
return QLocaleData::bytearrayToDouble(nulTerminated().constData(), ok);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1232,12 +1232,12 @@ uint QLocale::toUInt(const QString &s, bool *ok) const
|
||||
|
||||
qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
return d->m_data->stringToLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1256,12 +1256,12 @@ qlonglong QLocale::toLongLong(const QString &s, bool *ok) const
|
||||
|
||||
qulonglong QLocale::toULongLong(const QString &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToUnsLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
return d->m_data->stringToUnsLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1315,12 +1315,12 @@ float QLocale::toFloat(const QString &s, bool *ok) const
|
||||
|
||||
double QLocale::toDouble(const QString &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToDouble(s.constData(), s.size(), ok, mode);
|
||||
return d->m_data->stringToDouble(s.constData(), s.size(), ok, mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1445,12 +1445,12 @@ uint QLocale::toUInt(const QStringRef &s, bool *ok) const
|
||||
|
||||
qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
return d->m_data->stringToLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1471,12 +1471,12 @@ qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok) const
|
||||
|
||||
qulonglong QLocale::toULongLong(const QStringRef &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToUnsLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
return d->m_data->stringToUnsLongLong(s.constData(), s.size(), 10, ok, mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1532,12 +1532,12 @@ float QLocale::toFloat(const QStringRef &s, bool *ok) const
|
||||
|
||||
double QLocale::toDouble(const QStringRef &s, bool *ok) const
|
||||
{
|
||||
QLocalePrivate::GroupSeparatorMode mode
|
||||
QLocaleData::GroupSeparatorMode mode
|
||||
= d->m_numberOptions & RejectGroupSeparator
|
||||
? QLocalePrivate::FailOnGroupSeparators
|
||||
: QLocalePrivate::ParseGroupSeparators;
|
||||
? QLocaleData::FailOnGroupSeparators
|
||||
: QLocaleData::ParseGroupSeparators;
|
||||
|
||||
return d->stringToDouble(s.constData(), s.size(), ok, mode);
|
||||
return d->m_data->stringToDouble(s.constData(), s.size(), ok, mode);
|
||||
}
|
||||
|
||||
|
||||
@ -3091,7 +3091,7 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group,
|
||||
number. We can't detect junk here, since we don't even know the base
|
||||
of the number.
|
||||
*/
|
||||
bool QLocalePrivate::numberToCLocale(const QChar *str, int len,
|
||||
bool QLocaleData::numberToCLocale(const QChar *str, int len,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const
|
||||
{
|
||||
@ -3116,9 +3116,9 @@ bool QLocalePrivate::numberToCLocale(const QChar *str, int len,
|
||||
|
||||
char out = digitToCLocale(in);
|
||||
if (out == 0) {
|
||||
if (in == list())
|
||||
if (in == m_list)
|
||||
out = ';';
|
||||
else if (in == percent())
|
||||
else if (in == m_percent)
|
||||
out = '%';
|
||||
// for handling base-x numbers
|
||||
else if (in.unicode() >= 'A' && in.unicode() <= 'Z')
|
||||
@ -3145,7 +3145,7 @@ bool QLocalePrivate::numberToCLocale(const QChar *str, int len,
|
||||
return idx == l;
|
||||
}
|
||||
|
||||
bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByteArray *buff,
|
||||
bool QLocaleData::validateChars(const QString &str, NumberMode numMode, QByteArray *buff,
|
||||
int decDigits) const
|
||||
{
|
||||
buff->clear();
|
||||
@ -3238,7 +3238,7 @@ bool QLocalePrivate::validateChars(const QString &str, NumberMode numMode, QByte
|
||||
return true;
|
||||
}
|
||||
|
||||
double QLocalePrivate::stringToDouble(const QChar *begin, int len, bool *ok,
|
||||
double QLocaleData::stringToDouble(const QChar *begin, int len, bool *ok,
|
||||
GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
@ -3250,7 +3250,7 @@ double QLocalePrivate::stringToDouble(const QChar *begin, int len, bool *ok,
|
||||
return bytearrayToDouble(buff.constData(), ok);
|
||||
}
|
||||
|
||||
qlonglong QLocalePrivate::stringToLongLong(const QChar *begin, int len, int base,
|
||||
qlonglong QLocaleData::stringToLongLong(const QChar *begin, int len, int base,
|
||||
bool *ok, GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
@ -3263,7 +3263,7 @@ qlonglong QLocalePrivate::stringToLongLong(const QChar *begin, int len, int base
|
||||
return bytearrayToLongLong(buff.constData(), base, ok);
|
||||
}
|
||||
|
||||
qulonglong QLocalePrivate::stringToUnsLongLong(const QChar *begin, int len, int base,
|
||||
qulonglong QLocaleData::stringToUnsLongLong(const QChar *begin, int len, int base,
|
||||
bool *ok, GroupSeparatorMode group_sep_mode) const
|
||||
{
|
||||
CharBuff buff;
|
||||
@ -3276,7 +3276,7 @@ qulonglong QLocalePrivate::stringToUnsLongLong(const QChar *begin, int len, int
|
||||
return bytearrayToUnsLongLong(buff.constData(), base, ok);
|
||||
}
|
||||
|
||||
double QLocalePrivate::bytearrayToDouble(const char *num, bool *ok, bool *overflow)
|
||||
double QLocaleData::bytearrayToDouble(const char *num, bool *ok, bool *overflow)
|
||||
{
|
||||
if (ok != 0)
|
||||
*ok = true;
|
||||
@ -3328,7 +3328,7 @@ double QLocalePrivate::bytearrayToDouble(const char *num, bool *ok, bool *overfl
|
||||
return d;
|
||||
}
|
||||
|
||||
qlonglong QLocalePrivate::bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow)
|
||||
qlonglong QLocaleData::bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow)
|
||||
{
|
||||
bool _ok;
|
||||
const char *endptr;
|
||||
@ -3370,7 +3370,7 @@ qlonglong QLocalePrivate::bytearrayToLongLong(const char *num, int base, bool *o
|
||||
return l;
|
||||
}
|
||||
|
||||
qulonglong QLocalePrivate::bytearrayToUnsLongLong(const char *num, int base, bool *ok)
|
||||
qulonglong QLocaleData::bytearrayToUnsLongLong(const char *num, int base, bool *ok)
|
||||
{
|
||||
bool _ok;
|
||||
const char *endptr;
|
||||
|
@ -188,6 +188,15 @@ public:
|
||||
ForcePoint = Alternate
|
||||
};
|
||||
|
||||
enum GroupSeparatorMode {
|
||||
FailOnGroupSeparators,
|
||||
ParseGroupSeparators
|
||||
};
|
||||
|
||||
enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode };
|
||||
|
||||
typedef QVarLengthArray<char, 256> CharBuff;
|
||||
|
||||
static QString doubleToString(const QChar zero, const QChar plus,
|
||||
const QChar minus, const QChar exponent,
|
||||
const QChar group, const QChar decimal,
|
||||
@ -218,6 +227,24 @@ public:
|
||||
int width = -1,
|
||||
unsigned flags = NoFlags) const;
|
||||
|
||||
double stringToDouble(const QChar *begin, int len, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
|
||||
// these functions are used in QIntValidator (QtGui)
|
||||
Q_CORE_EXPORT static double bytearrayToDouble(const char *num, bool *ok, bool *overflow = 0);
|
||||
Q_CORE_EXPORT static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow = 0);
|
||||
Q_CORE_EXPORT static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok);
|
||||
|
||||
bool numberToCLocale(const QChar *str, int len,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const;
|
||||
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;
|
||||
|
||||
public:
|
||||
quint16 m_language_id, m_script_id, m_country_id;
|
||||
|
||||
quint16 m_decimal, m_group, m_list, m_percent, m_zero, m_minus, m_plus, m_exponential;
|
||||
@ -302,30 +329,8 @@ public:
|
||||
|
||||
QLocale::MeasurementSystem measurementSystem() const;
|
||||
|
||||
enum GroupSeparatorMode {
|
||||
FailOnGroupSeparators,
|
||||
ParseGroupSeparators
|
||||
};
|
||||
|
||||
double stringToDouble(const QChar *begin, int len, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
qint64 stringToLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
quint64 stringToUnsLongLong(const QChar *begin, int len, int base, bool *ok, GroupSeparatorMode group_sep_mode) const;
|
||||
|
||||
static double bytearrayToDouble(const char *num, bool *ok, bool *overflow = 0);
|
||||
static qint64 bytearrayToLongLong(const char *num, int base, bool *ok, bool *overflow = 0);
|
||||
static quint64 bytearrayToUnsLongLong(const char *num, int base, bool *ok);
|
||||
|
||||
typedef QVarLengthArray<char, 256> CharBuff;
|
||||
bool numberToCLocale(const QChar *str, int len,
|
||||
GroupSeparatorMode group_sep_mode,
|
||||
CharBuff *result) const;
|
||||
inline char digitToCLocale(QChar c) const;
|
||||
|
||||
static void updateSystemPrivate();
|
||||
|
||||
enum NumberMode { IntegerMode, DoubleStandardMode, DoubleScientificMode };
|
||||
bool validateChars(const QString &str, NumberMode numMode, QByteArray *buff, int decDigits = -1) const;
|
||||
|
||||
QString dateTimeToString(const QString &format, const QDateTime &datetime,
|
||||
const QDate &dateOnly, const QTime &timeOnly,
|
||||
const QLocale *q) const;
|
||||
@ -343,37 +348,34 @@ inline QLocalePrivate *QSharedDataPointer<QLocalePrivate>::clone()
|
||||
return QLocalePrivate::create(d->m_data, d->m_numberOptions);
|
||||
}
|
||||
|
||||
inline char QLocalePrivate::digitToCLocale(QChar in) const
|
||||
inline char QLocaleData::digitToCLocale(QChar in) const
|
||||
{
|
||||
const QChar _zero = zero();
|
||||
const QChar _group = group();
|
||||
const ushort zeroUnicode = _zero.unicode();
|
||||
const ushort tenUnicode = zeroUnicode + 10;
|
||||
const ushort tenUnicode = m_zero + 10;
|
||||
|
||||
if (in.unicode() >= zeroUnicode && in.unicode() < tenUnicode)
|
||||
return '0' + in.unicode() - zeroUnicode;
|
||||
if (in.unicode() >= m_zero && in.unicode() < tenUnicode)
|
||||
return '0' + in.unicode() - m_zero;
|
||||
|
||||
if (in.unicode() >= '0' && in.unicode() <= '9')
|
||||
return in.toLatin1();
|
||||
|
||||
if (in == plus() || in == QLatin1Char('+'))
|
||||
if (in == m_plus || in == QLatin1Char('+'))
|
||||
return '+';
|
||||
|
||||
if (in == minus() || in == QLatin1Char('-') || in == QChar(0x2212))
|
||||
if (in == m_minus || in == QLatin1Char('-') || in == QChar(0x2212))
|
||||
return '-';
|
||||
|
||||
if (in == decimal())
|
||||
if (in == m_decimal)
|
||||
return '.';
|
||||
|
||||
if (in == group())
|
||||
if (in == m_group)
|
||||
return ',';
|
||||
|
||||
if (in == exponential() || in == exponential().toUpper())
|
||||
if (in == m_exponential || in == QChar::toUpper(m_exponential))
|
||||
return 'e';
|
||||
|
||||
// In several languages group() is the char 0xA0, which looks like a space.
|
||||
// People use a regular space instead of it and complain it doesn't work.
|
||||
if (_group.unicode() == 0xA0 && in.unicode() == ' ')
|
||||
if (m_group == 0xA0 && in.unicode() == ' ')
|
||||
return ',';
|
||||
|
||||
return 0;
|
||||
|
@ -185,7 +185,7 @@ QString &exponentForm(QChar zero, QChar decimal, QChar exponential,
|
||||
}
|
||||
|
||||
// Removes thousand-group separators in "C" locale.
|
||||
bool removeGroupSeparators(QLocalePrivate::CharBuff *num)
|
||||
bool removeGroupSeparators(QLocaleData::CharBuff *num)
|
||||
{
|
||||
int group_cnt = 0; // counts number of group chars
|
||||
int decpt_idx = -1;
|
||||
|
@ -105,7 +105,7 @@ inline bool isZero(double d)
|
||||
}
|
||||
|
||||
// Removes thousand-group separators in "C" locale.
|
||||
bool removeGroupSeparators(QLocalePrivate::CharBuff *num);
|
||||
bool removeGroupSeparators(QLocaleData::CharBuff *num);
|
||||
|
||||
Q_CORE_EXPORT char *qdtoa(double d, int mode, int ndigits, int *decpt,
|
||||
int *sign, char **rve, char **digits_str);
|
||||
|
@ -6075,8 +6075,7 @@ qint64 QString::toLongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToLongLong(constData(), size(), base, ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToLongLong(constData(), size(), base, ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -6110,8 +6109,7 @@ quint64 QString::toULongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToUnsLongLong(constData(), size(), base, ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToUnsLongLong(constData(), size(), base, ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -6349,8 +6347,7 @@ ushort QString::toUShort(bool *ok, int base) const
|
||||
|
||||
double QString::toDouble(bool *ok) const
|
||||
{
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToDouble(constData(), size(), ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -9616,8 +9613,7 @@ qint64 QStringRef::toLongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToLongLong(constData(), size(), base, ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToLongLong(constData(), size(), base, ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -9649,8 +9645,7 @@ quint64 QStringRef::toULongLong(bool *ok, int base) const
|
||||
}
|
||||
#endif
|
||||
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToUnsLongLong(constData(), size(), base, ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToUnsLongLong(constData(), size(), base, ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -9867,8 +9862,7 @@ ushort QStringRef::toUShort(bool *ok, int base) const
|
||||
|
||||
double QStringRef::toDouble(bool *ok) const
|
||||
{
|
||||
QLocale c_locale(QLocale::C);
|
||||
return c_locale.d->stringToDouble(constData(), size(), ok, QLocalePrivate::FailOnGroupSeparators);
|
||||
return QLocaleData::c()->stringToDouble(constData(), size(), ok, QLocaleData::FailOnGroupSeparators);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -401,7 +401,7 @@ static qlonglong pow10(int exp)
|
||||
QValidator::State QIntValidator::validate(QString & input, int&) const
|
||||
{
|
||||
QByteArray buff;
|
||||
if (!locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
|
||||
if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff)) {
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ QValidator::State QIntValidator::validate(QString & input, int&) const
|
||||
return Intermediate;
|
||||
|
||||
bool ok, overflow;
|
||||
qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
|
||||
qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
|
||||
if (overflow || !ok)
|
||||
return Invalid;
|
||||
|
||||
@ -440,11 +440,11 @@ QValidator::State QIntValidator::validate(QString & input, int&) const
|
||||
void QIntValidator::fixup(QString &input) const
|
||||
{
|
||||
QByteArray buff;
|
||||
if (!locale().d->validateChars(input, QLocalePrivate::IntegerMode, &buff)) {
|
||||
if (!locale().d->m_data->validateChars(input, QLocaleData::IntegerMode, &buff)) {
|
||||
return;
|
||||
}
|
||||
bool ok, overflow;
|
||||
qlonglong entered = QLocalePrivate::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
|
||||
qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok, &overflow);
|
||||
if (ok && !overflow)
|
||||
input = locale().toString(entered);
|
||||
}
|
||||
@ -532,7 +532,7 @@ public:
|
||||
|
||||
QDoubleValidator::Notation notation;
|
||||
|
||||
QValidator::State validateWithLocale(QString & input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const;
|
||||
QValidator::State validateWithLocale(QString & input, QLocaleData::NumberMode numMode, const QLocale &locale) const;
|
||||
};
|
||||
|
||||
|
||||
@ -639,24 +639,24 @@ QValidator::State QDoubleValidator::validate(QString & input, int &) const
|
||||
{
|
||||
Q_D(const QDoubleValidator);
|
||||
|
||||
QLocalePrivate::NumberMode numMode = QLocalePrivate::DoubleStandardMode;
|
||||
QLocaleData::NumberMode numMode = QLocaleData::DoubleStandardMode;
|
||||
switch (d->notation) {
|
||||
case StandardNotation:
|
||||
numMode = QLocalePrivate::DoubleStandardMode;
|
||||
numMode = QLocaleData::DoubleStandardMode;
|
||||
break;
|
||||
case ScientificNotation:
|
||||
numMode = QLocalePrivate::DoubleScientificMode;
|
||||
numMode = QLocaleData::DoubleScientificMode;
|
||||
break;
|
||||
}
|
||||
|
||||
return d->validateWithLocale(input, numMode, locale());
|
||||
}
|
||||
|
||||
QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocalePrivate::NumberMode numMode, const QLocale &locale) const
|
||||
QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QLocaleData::NumberMode numMode, const QLocale &locale) const
|
||||
{
|
||||
Q_Q(const QDoubleValidator);
|
||||
QByteArray buff;
|
||||
if (!locale.d->validateChars(input, numMode, &buff, q->dec))
|
||||
if (!locale.d->m_data->validateChars(input, numMode, &buff, q->dec))
|
||||
return QValidator::Invalid;
|
||||
|
||||
if (buff.isEmpty())
|
||||
@ -669,7 +669,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL
|
||||
return QValidator::Invalid;
|
||||
|
||||
bool ok, overflow;
|
||||
double i = QLocalePrivate::bytearrayToDouble(buff.constData(), &ok, &overflow);
|
||||
double i = QLocaleData::bytearrayToDouble(buff.constData(), &ok, &overflow);
|
||||
if (overflow)
|
||||
return QValidator::Invalid;
|
||||
if (!ok)
|
||||
|
Loading…
Reference in New Issue
Block a user