--- a/src/corelib/tools/qlocale.cpp Mon Jun 21 22:38:13 2010 +0100
+++ b/src/corelib/tools/qlocale.cpp Thu Jul 22 16:41:55 2010 +0100
@@ -129,6 +129,11 @@
}
#endif
+#if defined(Q_OS_SYMBIAN)
+void qt_symbianUpdateSystemPrivate();
+void qt_symbianInitSystemLocale();
+#endif
+
/******************************************************************************
** Helpers for accessing Qt locale database
*/
@@ -170,16 +175,17 @@
}
// Assumes that code is a
-// QChar code[2];
+// QChar code[3];
static QLocale::Country codeToCountry(const QChar *code)
{
ushort uc1 = code[0].unicode();
ushort uc2 = code[1].unicode();
+ ushort uc3 = code[2].unicode();
const unsigned char *c = country_code_list;
- for (; *c != 0; c += 2) {
- if (uc1 == c[0] && uc2 == c[1])
- return QLocale::Country((c - country_code_list)/2);
+ for (; *c != 0; c += 3) {
+ if (uc1 == c[0] && uc2 == c[1] && uc3 == c[2])
+ return QLocale::Country((c - country_code_list)/3);
}
return QLocale::AnyCountry;
@@ -207,10 +213,15 @@
if (country == QLocale::AnyCountry)
return QString();
- QString code(2, Qt::Uninitialized);
- const unsigned char *c = country_code_list + 2*(uint(country));
+ const unsigned char *c = country_code_list + 3*(uint(country));
+
+ QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized);
+
code[0] = ushort(c[0]);
code[1] = ushort(c[1]);
+ if (c[2] != 0)
+ code[2] = ushort(c[2]);
+
return code;
}
@@ -246,7 +257,7 @@
{
for (int i = 0; i < 3; ++i)
lang_begin[i] = 0;
- for (int i = 0; i < 2; ++i)
+ for (int i = 0; i < 3; ++i)
cntry_begin[i] = 0;
int l = name.length();
@@ -277,7 +288,7 @@
break;
case 1:
// parsing country
- if (cntry - cntry_begin == 2) {
+ if (cntry - cntry_begin == 3) {
cntry_begin[0] = 0;
break;
}
@@ -301,7 +312,7 @@
cntry = QLocale::AnyCountry;
QChar lang_code[3];
- QChar cntry_code[2];
+ QChar cntry_code[3];
if (!splitLocaleName(name, lang_code, cntry_code))
return;
@@ -419,7 +430,7 @@
if (id == LOCALE_USER_DEFAULT) {
result = envVarLocale();
QChar lang[3];
- QChar cntry[2];
+ QChar cntry[3];
if ( result == "C" || (!result.isEmpty()
&& splitLocaleName(QString::fromLocal8Bit(result), lang, cntry)) ) {
long id = 0;
@@ -465,7 +476,7 @@
if (text == QLatin1String("'"))
result += QLatin1String("''");
else
- result += QLatin1Char('\'') + text + QLatin1Char('\'');
+ result += QString(QLatin1Char('\'') + text + QLatin1Char('\''));
continue;
}
@@ -681,8 +692,8 @@
case DateTimeFormatLong:
case DateTimeFormatShort:
- return query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString()
- + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString();
+ return QString(query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString()
+ + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString());
case DayNameLong:
case DayNameShort:
return winDayName(in.toInt(), (type == DayNameShort));
@@ -698,8 +709,8 @@
case DateTimeToStringShort:
case DateTimeToStringLong: {
const QDateTime dt = in.toDateTime();
- return winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE)
- + QLatin1Char(' ') + winTimeToString(dt.time()); }
+ return QString(winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE)
+ + QLatin1Char(' ') + winTimeToString(dt.time())); }
case ZeroDigit:
locale_info = LOCALE_SNATIVEDIGITS;
@@ -945,7 +956,7 @@
QByteArray result = envVarLocale();
QChar lang[3];
- QChar cntry[2];
+ QChar cntry[3];
if (result.isEmpty() || result != "C"
&& !splitLocaleName(QString::fromLocal8Bit(result), lang, cntry)) {
QCFType<CFLocaleRef> l = CFLocaleCopyCurrent();
@@ -1215,7 +1226,7 @@
case LanguageId:
case CountryId: {
QString preferredLanguage;
- QString preferredCountry;
+ QString preferredCountry(3, QChar()); // codeToCountry assumes QChar[3]
getMacPreferredLanguageAndCountry(&preferredLanguage, &preferredCountry);
QLocale::Language languageCode = (preferredLanguage.isEmpty() ? QLocale::C : codeToLanguage(preferredLanguage.data()));
QLocale::Country countryCode = (preferredCountry.isEmpty() ? QLocale::AnyCountry : codeToCountry(preferredCountry.data()));
@@ -1407,6 +1418,9 @@
{
if (_systemLocale)
return _systemLocale;
+#if defined(Q_OS_SYMBIAN)
+ qt_symbianInitSystemLocale();
+#endif
return QSystemLocale_globalSystemLocale();
}
@@ -1417,6 +1431,10 @@
system_lp = globalLocalePrivate();
*system_lp = *sys_locale->fallbackLocale().d();
+#if defined(Q_OS_SYMBIAN)
+ qt_symbianUpdateSystemPrivate();
+#endif
+
QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant());
if (!res.isNull())
system_lp->m_language_id = res.toInt();
@@ -1570,7 +1588,7 @@
This constructor converts the locale name to a language/country
pair; it does not use the system locale database.
- QLocale's data is based on Common Locale Data Repository v1.6.1.
+ QLocale's data is based on Common Locale Data Repository v1.8.1.
The double-to-string and string-to-double conversion functions are
covered by the following licenses:
@@ -1771,6 +1789,55 @@
\value Hawaiian
\value Tyap
\value Chewa
+ \value Filipino
+ \value SwissGerman
+ \value SichuanYi
+ \value Kpelle
+ \value LowGerman
+ \value SouthNdebele
+ \value NorthernSotho
+ \value NorthernSami
+ \value Taroko
+ \value Gusii
+ \value Taita
+ \value Fulah
+ \value Kikuyu
+ \value Samburu
+ \value Sena
+ \value NorthNdebele
+ \value Rombo
+ \value Tachelhit
+ \value Kabyle
+ \value Nyankole
+ \value Bena
+ \value Vunjo
+ \value Bambara
+ \value Embu
+ \value Cherokee
+ \value Morisyen
+ \value Makonde
+ \value Langi
+ \value Ganda
+ \value Bemba
+ \value Kabuverdianu
+ \value Meru
+ \value Kalenjin
+ \value Nama
+ \value Machame
+ \value Colognian
+ \value Masai
+ \value Soga
+ \value Luyia
+ \value Asu
+ \value Teso
+ \value Saho
+ \value KoyraChiini
+ \value Rwa
+ \value Luo
+ \value Chiga
+ \value CentralMoroccoTamazight
+ \value KoyraboroSenni
+ \value Shambala
\omitvalue LastLanguage
\sa language()
@@ -2023,6 +2090,11 @@
\value Yugoslavia
\value Zambia
\value Zimbabwe
+ \value SerbiaAndMontenegro
+ \value Montenegro
+ \value Serbia
+ \value SaintBarthelemy
+ \value SaintMartin
\omitvalue LastCountry
\sa country()
@@ -2917,7 +2989,7 @@
#ifndef QT_NO_DATESTRING
QDateTime QLocale::toDateTime(const QString &string, FormatType format) const
{
- return toDateTime(string, dateFormat(format));
+ return toDateTime(string, dateTimeFormat(format));
}
#endif
@@ -3147,7 +3219,7 @@
On Windows and Mac, this locale will use the decimal/grouping characters and date/time
formats specified in the system configuration panel.
- \sa QTextCodec::locale() c()
+ \sa c()
*/
QLocale QLocale::system()
@@ -4293,6 +4365,7 @@
const bool scientific = numMode == DoubleScientificMode;
bool lastWasE = false;
+ bool lastWasDigit = false;
int eCnt = 0;
int decPointCnt = 0;
bool dec = false;
@@ -4307,6 +4380,7 @@
if (dec && decDigits != -1 && decDigits < ++decDigitCnt)
return false;
}
+ lastWasDigit = true;
} else {
switch (c) {
case '.':
@@ -4344,7 +4418,10 @@
break;
case ',':
- return false;
+ //it can only be placed after a digit which is before the decimal point
+ if (!lastWasDigit || decPointCnt > 0)
+ return false;
+ break;
case 'e':
if (scientific) {
@@ -4362,10 +4439,12 @@
// If it's not a valid digit, it shall be Invalid.
return false;
}
+ lastWasDigit = false;
}
lastWasE = c == 'e';
- buff->append(c);
+ if (c != ',')
+ buff->append(c);
}
return true;