summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/widgets/calendarwidget/window.cpp11
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp10
-rw-r--r--src/corelib/io/qresource.cpp11
-rw-r--r--src/corelib/text/qlocale.cpp302
-rw-r--r--src/corelib/text/qlocale.h46
-rw-r--r--src/corelib/text/qlocale.qdoc63
-rw-r--r--src/corelib/text/qlocale_data_p.h20
-rw-r--r--src/corelib/text/qlocale_mac.mm4
-rw-r--r--src/corelib/text/qlocale_p.h30
-rw-r--r--src/corelib/text/qlocale_unix.cpp2
-rw-r--r--src/corelib/text/qlocale_win.cpp12
-rw-r--r--src/corelib/time/qcalendarbackend_p.h2
-rw-r--r--src/corelib/time/qhijricalendar_data_p.h4
-rw-r--r--src/corelib/time/qjalalicalendar_data_p.h4
-rw-r--r--src/corelib/time/qromancalendar_data_p.h4
-rw-r--r--src/corelib/time/qtimezone.cpp78
-rw-r--r--src/corelib/time/qtimezone.h12
-rw-r--r--src/corelib/time/qtimezoneprivate.cpp46
-rw-r--r--src/corelib/time/qtimezoneprivate_android.cpp6
-rw-r--r--src/corelib/time/qtimezoneprivate_data_p.h2
-rw-r--r--src/corelib/time/qtimezoneprivate_icu.cpp4
-rw-r--r--src/corelib/time/qtimezoneprivate_p.h24
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp14
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp16
-rw-r--r--src/tools/rcc/rcc.cpp32
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp194
-rw-r--r--tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp24
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp4
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp4
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp4
-rw-r--r--tests/benchmarks/corelib/text/qlocale/main.cpp28
-rw-r--r--tests/manual/qlocale/info.cpp8
-rw-r--r--tests/manual/qlocale/info.h4
-rw-r--r--tests/manual/qlocale/languages.cpp2
-rw-r--r--tests/manual/qlocale/window.cpp10
-rw-r--r--util/locale_database/cldr.py4
-rw-r--r--util/locale_database/enumdata.py8
-rw-r--r--util/locale_database/qlocalexml.py6
-rwxr-xr-xutil/locale_database/qlocalexml2cpp.py24
-rw-r--r--util/locale_database/testlocales/localemodel.cpp8
-rw-r--r--util/xkbdatagen/main.cpp4
41 files changed, 636 insertions, 459 deletions
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp
index 23010a6e1a..e88e41beb2 100644
--- a/examples/widgets/widgets/calendarwidget/window.cpp
+++ b/examples/widgets/widgets/calendarwidget/window.cpp
@@ -247,14 +247,13 @@ void Window::createGeneralOptionsGroupBox()
int index = 0;
for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
- QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
- for (int i = 0; i < countries.count(); ++i) {
- QLocale::Country country = countries.at(i);
+ const auto territories = QLocale::territoriesForLanguage(lang);
+ for (auto territory : territories) {
QString label = QLocale::languageToString(lang);
label += QLatin1Char('/');
- label += QLocale::countryToString(country);
- QLocale locale(lang, country);
- if (this->locale().language() == lang && this->locale().country() == country)
+ label += QLocale::territoryToString(territory);
+ QLocale locale(lang, territory);
+ if (this->locale().language() == lang && this->locale().territory() == territory)
curLocaleIndex = index;
localeCombo->addItem(label, locale);
++index;
diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp
index 3dcd04d9ff..3fdf5c6b3b 100644
--- a/examples/widgets/widgets/validators/localeselector.cpp
+++ b/examples/widgets/widgets/validators/localeselector.cpp
@@ -60,18 +60,18 @@ LocaleSelector::LocaleSelector(QWidget *parent)
for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
const QList<QLocale> locales =
- QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyCountry);
+ QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory);
for (const QLocale &l : locales) {
QString label = QLocale::languageToString(l.language());
label += QLatin1Char('/');
- label += QLocale::countryToString(l.country());
- // distinguish locales by script, if there are more than one script for a language/country pair
- if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.country()).size() > 1)
+ label += QLocale::territoryToString(l.territory());
+ // distinguish locales by script, if there are more than one script for a language/territory pair
+ if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.territory()).size() > 1)
label += QLatin1String(" (") + QLocale::scriptToString(l.script()) + QLatin1Char(')');
addItem(label, QVariant::fromValue(l));
- if (l.language() == locale().language() && l.country() == locale().country()
+ if (l.language() == locale().language() && l.territory() == locale().territory()
&& (locale().script() == QLocale::AnyScript || l.script() == locale().script())) {
curIndex = index;
}
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index be3f80f73a..936218608b 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -817,7 +817,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
}
}
#ifdef DEBUG_RESOURCE_MATCH
- qDebug() << "!!!!" << "START" << path << locale.country() << locale.language();
+ qDebug() << "!!!!" << "START" << path << locale.territory() << locale.language();
#endif
if (path == QLatin1String("/"))
@@ -877,7 +877,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
if (!splitter.hasNext()) {
if (!(flags & Directory)) {
- const qint16 country = qFromBigEndian<qint16>(tree + offset);
+ const qint16 territory = qFromBigEndian<qint16>(tree + offset);
offset += 2;
const qint16 language = qFromBigEndian<qint16>(tree + offset);
@@ -885,14 +885,15 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << " " << "LOCALE" << country << language;
#endif
- if (country == locale.country() && language == locale.language()) {
+ if (territory == locale.territory() && language == locale.language()) {
#ifdef DEBUG_RESOURCE_MATCH
qDebug() << "!!!!" << "FINISHED" << __LINE__ << sub_node;
#endif
return sub_node;
- } else if ((country == QLocale::AnyCountry
+ } else if ((territory == QLocale::AnyTerritory
&& language == locale.language())
- || (country == QLocale::AnyCountry && language == QLocale::C
+ || (territory == QLocale::AnyTerritory
+ && language == QLocale::C
&& node == -1)) {
node = sub_node;
}
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 0e73f84c68..763703b53d 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -154,23 +154,23 @@ QLocale::Script QLocalePrivate::codeToScript(QStringView code) noexcept
return QLocale::AnyScript;
}
-QLocale::Country QLocalePrivate::codeToCountry(QStringView code) noexcept
+QLocale::Territory QLocalePrivate::codeToTerritory(QStringView code) noexcept
{
const auto len = code.size();
if (len != 2 && len != 3)
- return QLocale::AnyCountry;
+ return QLocale::AnyTerritory;
char16_t uc1 = code[0].toUpper().unicode();
char16_t uc2 = code[1].toUpper().unicode();
char16_t uc3 = len > 2 ? code[2].toUpper().unicode() : 0;
- const unsigned char *c = country_code_list;
+ const unsigned char *c = territory_code_list;
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::Territory((c - territory_code_list)/3);
}
- return QLocale::AnyCountry;
+ return QLocale::AnyTerritory;
}
QLatin1String QLocalePrivate::languageToCode(QLocale::Language language)
@@ -192,12 +192,12 @@ QLatin1String QLocalePrivate::scriptToCode(QLocale::Script script)
return QLatin1String(reinterpret_cast<const char *>(c), 4);
}
-QLatin1String QLocalePrivate::countryToCode(QLocale::Country country)
+QLatin1String QLocalePrivate::territoryToCode(QLocale::Territory territory)
{
- if (country == QLocale::AnyCountry || country > QLocale::LastCountry)
+ if (territory == QLocale::AnyTerritory || territory > QLocale::LastTerritory)
return QLatin1String();
- const unsigned char *c = country_code_list + 3 * country;
+ const unsigned char *c = territory_code_list + 3 * territory;
return QLatin1String(reinterpret_cast<const char*>(c), c[2] == 0 ? 2 : 3);
}
@@ -222,7 +222,7 @@ bool operator<(const LikelyPair &lhs, const LikelyPair &rhs)
// Comparison order: language, region, script:
if (int cmp = compare(left.language_id, right.language_id))
return cmp < 0;
- if (int cmp = compare(left.country_id, right.country_id))
+ if (int cmp = compare(left.territory_id, right.territory_id))
return cmp < 0;
return compare(left.script_id, right.script_id) < 0;
}
@@ -277,25 +277,25 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const
// chopping within it - just traverse it all:
for (; pairs < afterPairs && pairs->key.language_id == language_id; ++pairs) {
const QLocaleId &key = pairs->key;
- if (key.country_id && key.country_id != country_id)
+ if (key.territory_id && key.territory_id != territory_id)
continue;
if (key.script_id && key.script_id != script_id)
continue;
QLocaleId value = pairs->value;
- if (country_id && !key.country_id)
- value.country_id = country_id;
+ if (territory_id && !key.territory_id)
+ value.territory_id = territory_id;
if (script_id && !key.script_id)
value.script_id = script_id;
return value;
}
}
// und_script_region or und_region (in that order):
- if (country_id) {
- sought.key = QLocaleId { 0, script_id, country_id };
+ if (territory_id) {
+ sought.key = QLocaleId { 0, script_id, territory_id };
pairs = std::lower_bound(pairs, afterPairs, sought);
// Again, individual und_?_region block isn't long enough to make binary
// chop a win:
- for (; pairs < afterPairs && pairs->key.country_id == country_id; ++pairs) {
+ for (; pairs < afterPairs && pairs->key.territory_id == territory_id; ++pairs) {
const QLocaleId &key = pairs->key;
Q_ASSERT(!key.language_id);
if (key.script_id && key.script_id != script_id)
@@ -313,12 +313,12 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const
sought.key = QLocaleId { 0, script_id, 0 };
pairs = std::lower_bound(pairs, afterPairs, sought);
if (pairs < afterPairs && pairs->key.script_id == script_id) {
- Q_ASSERT(!pairs->key.language_id && !pairs->key.country_id);
+ Q_ASSERT(!pairs->key.language_id && !pairs->key.territory_id);
QLocaleId value = pairs->value;
if (language_id)
value.language_id = language_id;
- if (country_id)
- value.country_id = country_id;
+ if (territory_id)
+ value.territory_id = territory_id;
return value;
}
}
@@ -345,8 +345,8 @@ QLocaleId QLocaleId::withLikelySubtagsRemoved() const
return id;
}
// language_region
- if (country_id) {
- QLocaleId id { language_id, 0, country_id };
+ if (territory_id) {
+ QLocaleId id { language_id, 0, territory_id };
if (id.withLikelySubtagsAdded() == max)
return id;
}
@@ -370,7 +370,8 @@ QByteArray QLocaleId::name(char separator) const
const unsigned char *script =
(script_id != QLocale::AnyScript ? script_code_list + 4 * script_id : nullptr);
const unsigned char *country =
- (country_id != QLocale::AnyCountry ? country_code_list + 3 * country_id : nullptr);
+ (territory_id != QLocale::AnyTerritory
+ ? territory_code_list + 3 * territory_id : nullptr);
char len = (lang[2] != 0 ? 3 : 2) + (script ? 4 + 1 : 0)
+ (country ? (country[2] != 0 ? 3 : 2) + 1 : 0);
QByteArray name(len, Qt::Uninitialized);
@@ -416,8 +417,8 @@ QByteArray QLocalePrivate::rawName(char separator) const
parts.append(languageCode().latin1());
if (m_data->m_script_id != QLocale::AnyScript)
parts.append(scriptCode().latin1());
- if (m_data->m_country_id != QLocale::AnyCountry)
- parts.append(countryCode().latin1());
+ if (m_data->m_territory_id != QLocale::AnyTerritory)
+ parts.append(territoryCode().latin1());
return parts.join(separator);
}
@@ -433,7 +434,7 @@ static int findLocaleIndexById(const QLocaleId &localeId)
Q_ASSERT(localeId.acceptLanguage(locale_data[idx].m_language_id));
do {
- if (localeId.acceptScriptCountry(locale_data[idx].id()))
+ if (localeId.acceptScriptTerritory(locale_data[idx].id()))
return idx;
++idx;
} while (localeId.acceptLanguage(locale_data[idx].m_language_id));
@@ -467,8 +468,8 @@ int QLocaleData::findLocaleIndex(QLocaleId lid)
CheckCandidate(localeId);
// No match; try again with likely country for language_script
- if (lid.country_id && (lid.language_id || lid.script_id)) {
- localeId.country_id = 0;
+ if (lid.territory_id && (lid.language_id || lid.script_id)) {
+ localeId.territory_id = 0;
likelyId = localeId.withLikelySubtagsAdded();
CheckCandidate(likelyId);
@@ -477,8 +478,8 @@ int QLocaleData::findLocaleIndex(QLocaleId lid)
}
// No match; try again with likely script for language_region
- if (lid.script_id && (lid.language_id || lid.country_id)) {
- localeId = QLocaleId { lid.language_id, 0, lid.country_id };
+ if (lid.script_id && (lid.language_id || lid.territory_id)) {
+ localeId = QLocaleId { lid.language_id, 0, lid.territory_id };
likelyId = localeId.withLikelySubtagsAdded();
CheckCandidate(likelyId);
@@ -576,7 +577,7 @@ QLocaleId QLocaleId::fromName(const QString &name)
QLocale::Language langId = QLocalePrivate::codeToLanguage(lang);
if (langId == QLocale::AnyLanguage)
return { QLocale::C, 0, 0 };
- return { langId, QLocalePrivate::codeToScript(script), QLocalePrivate::codeToCountry(land) };
+ return { langId, QLocalePrivate::codeToScript(script), QLocalePrivate::codeToTerritory(land) };
}
QString qt_readEscapedFormatString(QStringView format, int *idx)
@@ -714,9 +715,9 @@ static void updateSystemPrivate()
systemLocaleData.m_language_id = res.toInt();
systemLocaleData.m_script_id = QLocale::AnyScript; // default for compatibility
}
- res = sys_locale->query(QSystemLocale::CountryId);
+ res = sys_locale->query(QSystemLocale::TerritoryId);
if (!res.isNull()) {
- systemLocaleData.m_country_id = res.toInt();
+ systemLocaleData.m_territory_id = res.toInt();
systemLocaleData.m_script_id = QLocale::AnyScript; // default for compatibility
}
res = sys_locale->query(QSystemLocale::ScriptId);
@@ -813,12 +814,12 @@ static QLocalePrivate *localePrivateByName(const QString &name)
}
static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Script script,
- QLocale::Country country)
+ QLocale::Territory territory)
{
if (language == QLocale::C)
return c_private();
- int index = QLocaleData::findLocaleIndex(QLocaleId { language, script, country });
+ int index = QLocaleData::findLocaleIndex(QLocaleId { language, script, territory });
Q_ASSERT(index >= 0 && size_t(index) < std::size(locale_data) - 1);
const QLocaleData *data = locale_data + index;
@@ -988,54 +989,52 @@ QLocale::QLocale()
/*!
Constructs a QLocale object with the specified \a language and \a
- country.
+ territory.
\list
- \li If the language/country pair is found in the database, it is used.
- \li If the language is found but the country is not, or if the country
- is \c AnyCountry, the language is used with the most
- appropriate available country (for example, Germany for German),
- \li If neither the language nor the country are found, QLocale
+ \li If the language/territory pair is found in the database, it is used.
+ \li If the language is found but the territory is not, or if the territory
+ is \c AnyTerritory, the language is used with the most
+ appropriate available territory (for example, Germany for German),
+ \li If neither the language nor the territory are found, QLocale
defaults to the default locale (see setDefault()).
\endlist
- The language and country that are actually used can be queried
- using language() and country().
+ The language and territory that are actually used can be queried
+ using language() and territory().
- \sa setDefault(), language(), country()
+ \sa setDefault(), language(), territory()
*/
-QLocale::QLocale(Language language, Country country)
- : d(findLocalePrivate(language, QLocale::AnyScript, country))
+QLocale::QLocale(Language language, Territory territory)
+ : d(findLocalePrivate(language, QLocale::AnyScript, territory))
{
}
/*!
- \since 4.8
-
Constructs a QLocale object with the specified \a language, \a script and
- \a country.
+ \a territory.
\list
- \li If the language/script/country is found in the database, it is used.
- \li If both \a script is AnyScript and \a country is AnyCountry, the
- language is used with the most appropriate available script and country
+ \li If the language/script/territory is found in the database, it is used.
+ \li If both \a script is AnyScript and \a territory is AnyTerritory, the
+ language is used with the most appropriate available script and territory
(for example, Germany for German),
- \li If either \a script is AnyScript or \a country is AnyCountry, the
+ \li If either \a script is AnyScript or \a territory is AnyTerritory, the
language is used with the first locale that matches the given \a script
- and \a country.
- \li If neither the language nor the country are found, QLocale
+ and \a territory.
+ \li If neither the language nor the territory are found, QLocale
defaults to the default locale (see setDefault()).
\endlist
- The language, script and country that are actually used can be queried
- using language(), script() and country().
+ The language, script and territory that are actually used can be queried
+ using language(), script() and territory().
- \sa setDefault(), language(), script(), country()
+ \sa setDefault(), language(), script(), territory()
*/
-QLocale::QLocale(Language language, Script script, Country country)
- : d(findLocalePrivate(language, script, country))
+QLocale::QLocale(Language language, Script script, Territory territory)
+ : d(findLocalePrivate(language, script, territory))
{
}
@@ -1262,14 +1261,30 @@ QLocale::Script QLocale::script() const
}
/*!
- Returns the country or region of this locale.
+ \since 6.2
+
+ Returns the territory of this locale.
+
+ \sa language(), script(), territoryToString(), bcp47Name()
+*/
+QLocale::Territory QLocale::territory() const
+{
+ return Territory(d->territoryId());
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territory() instead.
+
+ Returns the territory of this locale.
- \sa language(), script(), countryToString(), bcp47Name()
+ \sa language(), script(), territoryToString(), bcp47Name()
*/
QLocale::Country QLocale::country() const
{
- return Country(d->countryId());
+ return territory();
}
+#endif
/*!
Returns the language and country of this locale as a
@@ -1290,11 +1305,11 @@ QString QLocale::name() const
if (l == C)
return d->languageCode();
- Country c = country();
- if (c == AnyCountry)
+ Territory c = territory();
+ if (c == AnyTerritory)
return d->languageCode();
- return d->languageCode() + QLatin1Char('_') + d->countryCode();
+ return d->languageCode() + QLatin1Char('_') + d->territoryCode();
}
static qlonglong toIntegral_helper(const QLocaleData *d, QStringView str, bool *ok,
@@ -1375,32 +1390,66 @@ QLocale::Language QLocale::codeToLanguage(QStringView languageCode) noexcept
}
/*!
- Returns the two-letter country code for \a country, as defined
+ \since 6.2
+
+ Returns the two-letter territory code for \a territory, as defined
in the ISO 3166 standard.
- \note For \c{QLocale::AnyCountry} an empty string is returned.
+ \note For \c{QLocale::AnyTerritory} an empty string is returned.
- \since 6.1
- \sa codeToCountry(), country(), name(), bcp47Name(), languageToCode(), scriptToCode()
+ \sa codeToTerritory(), territory(), name(), bcp47Name(), languageToCode(), scriptToCode()
+*/
+QString QLocale::territoryToCode(QLocale::Territory territory)
+{
+ return QLocalePrivate::territoryToCode(territory);
+}
+
+/*!
+ \since 6.2
+
+ Returns the QLocale::Territory enum corresponding to the two-letter or
+ three-digit \a territoryCode, as defined in the ISO 3166 standard.
+
+ If the code is invalid or not known QLocale::AnyTerritory is returned.
+
+ \sa territoryToCode(), codeToLanguage(), codeToScript()
+*/
+QLocale::Territory QLocale::codeToTerritory(QStringView territoryCode) noexcept
+{
+ return QLocalePrivate::codeToTerritory(territoryCode);
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territoryToCode(Territory) instead.
+
+ Returns the two-letter territory code for \a country, as defined
+ in the ISO 3166 standard.
+
+ \note For \c{QLocale::AnyTerritory} or \c{QLocale::AnyCountry} an empty string is returned.
+
+ \sa codeToTerritory(), territory(), name(), bcp47Name(), languageToCode(), scriptToCode()
*/
QString QLocale::countryToCode(Country country)
{
- return QLocalePrivate::countryToCode(country);
+ return territoryToCode(country);
}
/*!
- Returns the QLocale::Country enum corresponding to the two-letter or
+ Returns the QLocale::Territory enum corresponding to the two-letter or
three-digit \a countryCode, as defined in the ISO 3166 standard.
- If the code is invalid or not known QLocale::AnyCountry is returned.
+ If the code is invalid or not known QLocale::AnyTerritory is returned.
+ \obsolete Use codeToTerritory(QStringView) instead.
\since 6.1
- \sa countryToCode(), codeToLanguage(), codeToScript()
+ \sa territoryToCode(), codeToLanguage(), codeToScript()
*/
QLocale::Country QLocale::codeToCountry(QStringView countryCode) noexcept
{
- return QLocalePrivate::codeToCountry(countryCode);
+ return QLocalePrivate::codeToTerritory(countryCode);
}
+#endif
/*!
Returns the four-letter script code for \a script, as defined in the
@@ -1444,17 +1493,32 @@ QString QLocale::languageToString(Language language)
}
/*!
- Returns a QString containing the name of \a country.
+ \since 6.2
- \sa languageToString(), scriptToString(), country(), bcp47Name()
+ Returns a QString containing the name of \a territory.
+
+ \sa languageToString(), scriptToString(), territory(), bcp47Name()
*/
+QString QLocale::territoryToString(QLocale::Territory territory)
+{
+ if (territory > QLocale::LastTerritory)
+ return QLatin1String("Unknown");
+ return QLatin1String(territory_name_list + territory_name_index[territory]);
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territoryToString(Territory) instead.
+ Returns a QString containing the name of \a country.
+
+ \sa languageToString(), scriptToString(), territory(), bcp47Name()
+*/
QString QLocale::countryToString(Country country)
{
- if (country > QLocale::LastCountry)
- return QLatin1String("Unknown");
- return QLatin1String(country_name_list + country_name_index[country]);
+ return territoryToString(country);
}
+#endif
/*!
\since 4.8
@@ -2563,26 +2627,22 @@ QLocale QLocale::system()
return QLocale(locale);
}
-
/*!
- \since 4.8
-
Returns a list of valid locale objects that match the given \a language, \a
- script and \a country.
+ script and \a territory.
Getting a list of all locales:
QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
- QLocale::AnyCountry);
+ QLocale::AnyTerritory);
Getting a list of locales suitable for Russia:
QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
QLocale::Russia);
*/
-QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
- QLocale::Script script,
- QLocale::Country country)
+QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Script script,
+ QLocale::Territory territory)
{
- const QLocaleId filter { language, script, country };
+ const QLocaleId filter { language, script, territory };
if (!filter.isValid())
return QList<QLocale>();
@@ -2597,7 +2657,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
Q_ASSERT(filter.acceptLanguage(locale_data[index].m_language_id));
do {
const QLocaleId id = locale_data[index].id();
- if (filter.acceptScriptCountry(id)) {
+ if (filter.acceptScriptTerritory(id)) {
result.append(QLocale(*(id.language_id == C ? c_private()
: new QLocalePrivate(locale_data + index, index))));
}
@@ -2608,8 +2668,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
}
/*!
- \obsolete
- \since 4.3
+ \since 6.2
Returns the list of countries that have entries for \a language in Qt's locale
database. If the result is an empty list, then \a language is not represented in
@@ -2617,26 +2676,43 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
\sa matchingLocales()
*/
-QList<QLocale::Country> QLocale::countriesForLanguage(Language language)
+QList<QLocale::Territory> QLocale::territoriesForLanguage(QLocale::Language language)
{
- QList<Country> result;
+ QList<Territory> result;
if (language == C) {
- result << AnyCountry;
+ result << AnyTerritory;
return result;
}
unsigned language_id = language;
const QLocaleData *data = locale_data + locale_index[language_id];
while (data->m_language_id == language_id) {
- const QLocale::Country country = static_cast<Country>(data->m_country_id);
- if (!result.contains(country))
- result.append(country);
+ const QLocale::Territory territory = static_cast<Territory>(data->m_territory_id);
+ if (!result.contains(territory))
+ result.append(territory);
++data;
}
return result;
}
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territoriesForLanguage(Language) instead.
+ \since 4.3
+
+ Returns the list of countries that have entries for \a language in Qt's locale
+ database. If the result is an empty list, then \a language is not represented in
+ Qt's locale database.
+
+ \sa matchingLocales()
+*/
+QList<QLocale::Country> QLocale::countriesForLanguage(Language language)
+{
+ return territoriesForLanguage(language);
+}
+#endif
+
/*!
\since 4.2
@@ -2928,7 +3004,7 @@ QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
{
for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) {
if (ImperialMeasurementSystems[i].languageId == m_data->m_language_id
- && ImperialMeasurementSystems[i].countryId == m_data->m_country_id) {
+ && ImperialMeasurementSystems[i].territoryId == m_data->m_territory_id) {
return ImperialMeasurementSystems[i].system;
}
}
@@ -4318,7 +4394,7 @@ QLocale QLocale::collation() const
Returns a native name of the language for the locale. For example
"Schwiizertüütsch" for Swiss-German locale.
- \sa nativeCountryName(), languageToString()
+ \sa nativeTerritoryName(), languageToString()
*/
QString QLocale::nativeLanguageName() const
{
@@ -4333,24 +4409,40 @@ QString QLocale::nativeLanguageName() const
}
/*!
- \since 4.8
+ \since 6.2
- Returns a native name of the country for the locale. For example
+ Returns a native name of the territory for the locale. For example
"España" for Spanish/Spain locale.
- \sa nativeLanguageName(), countryToString()
+ \sa nativeLanguageName(), territoryToString()
*/
-QString QLocale::nativeCountryName() const
+QString QLocale::nativeTerritoryName() const
{
#ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == &systemLocaleData) {
- auto res = systemLocale()->query(QSystemLocale::NativeCountryName).toString();
+ auto res = systemLocale()->query(QSystemLocale::NativeTerritoryName).toString();
if (!res.isEmpty())
return res;
}
#endif
- return d->m_data->endonymCountry().getData(endonyms_data);
+ return d->m_data->endonymTerritory().getData(endonyms_data);
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use nativeTerritoryName() instead.
+ \since 4.8
+
+ Returns a native name of the territory for the locale. For example
+ "España" for Spanish/Spain locale.
+
+ \sa nativeLanguageName(), territoryToString()
+*/
+QString QLocale::nativeCountryName() const
+{
+ return nativeTerritoryName();
}
+#endif
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QLocale &l)
@@ -4359,7 +4451,7 @@ QDebug operator<<(QDebug dbg, const QLocale &l)
dbg.nospace().noquote()
<< "QLocale(" << QLocale::languageToString(l.language())
<< ", " << QLocale::scriptToString(l.script())
- << ", " << QLocale::countryToString(l.country()) << ')';
+ << ", " << QLocale::territoryToString(l.territory()) << ')';
return dbg;
}
#endif
diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h
index 6a9d9b46d8..397cd396c9 100644
--- a/src/corelib/text/qlocale.h
+++ b/src/corelib/text/qlocale.h
@@ -580,8 +580,9 @@ public:
LastScript = YiScript
};
+ // ### Qt 7: Rename to Territory
enum Country : ushort {
- AnyCountry = 0,
+ AnyTerritory = 0,
Afghanistan = 1,
AlandIslands = 2,
Albania = 3,
@@ -744,7 +745,7 @@ public:
Mozambique = 160,
Myanmar = 161,
Namibia = 162,
- NauruCountry = 163,
+ NauruTerritory = 163,
Nepal = 164,
Netherlands = 165,
NewCaledonia = 166,
@@ -815,7 +816,7 @@ public:
Thailand = 231,
TimorLeste = 232,
Togo = 233,
- TokelauCountry = 234,
+ TokelauTerritory = 234,
Tonga = 235,
TrinidadAndTobago = 236,
TristanDaCunha = 237,
@@ -823,7 +824,7 @@ public:
Turkey = 239,
Turkmenistan = 240,
TurksAndCaicosIslands = 241,
- TuvaluCountry = 242,
+ TuvaluTerritory = 242,
Uganda = 243,
Ukraine = 244,
UnitedArabEmirates = 245,
@@ -844,6 +845,7 @@ public:
Zambia = 260,
Zimbabwe = 261,
+ AnyCountry = AnyTerritory,
Bonaire = CaribbeanNetherlands,
BosniaAndHerzegowina = BosniaAndHerzegovina,
CuraSao = Curacao,
@@ -853,6 +855,7 @@ public:
EastTimor = TimorLeste,
LatinAmericaAndTheCaribbean = LatinAmerica,
Macau = Macao,
+ NauruCountry = NauruTerritory,
PeoplesRepublicOfCongo = CongoBrazzaville,
RepublicOfKorea = SouthKorea,
RussianFederation = Russia,
@@ -861,14 +864,19 @@ public:
SvalbardAndJanMayenIslands = SvalbardAndJanMayen,
Swaziland = Eswatini,
SyrianArabRepublic = Syria,
+ TokelauCountry = TokelauTerritory,
+ TuvaluCountry = TuvaluTerritory,
UnitedStatesMinorOutlyingIslands = UnitedStatesOutlyingIslands,
VaticanCityState = VaticanCity,
WallisAndFutunaIslands = WallisAndFutuna,
- LastCountry = Zimbabwe
+ LastTerritory = Zimbabwe,
+ LastCountry = LastTerritory
};
// GENERATED PART ENDS HERE
+ using Territory = Country; // ### Qt 7: reverse
+
Q_ENUM(Language)
Q_ENUM(Country)
Q_ENUM(Script)
@@ -918,8 +926,8 @@ public:
QLocale();
explicit QLocale(const QString &name);
- QLocale(Language language, Country country = AnyCountry);
- QLocale(Language language, Script script, Country country);
+ QLocale(Language language, Territory territory = AnyTerritory);
+ QLocale(Language language, Script script, Territory territory);
QLocale(const QLocale &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QLocale)
QLocale &operator=(const QLocale &other);
@@ -929,12 +937,20 @@ public:
Language language() const;
Script script() const;
+ Territory territory() const;
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territory() instead")
Country country() const;
+#endif
QString name() const;
QString bcp47Name() const;
QString nativeLanguageName() const;
+ QString nativeTerritoryName() const;
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use nativeTerritoryName() instead")
QString nativeCountryName() const;
+#endif
#if QT_STRINGVIEW_LEVEL < 2
short toShort(const QString &s, bool *ok = nullptr) const
@@ -1069,21 +1085,35 @@ public:
static QString languageToCode(Language language);
static Language codeToLanguage(QStringView languageCode) noexcept;
+ static QString territoryToCode(Territory territory);
+ static Territory codeToTerritory(QStringView territoryCode) noexcept;
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territoryToCode(Territory) instead")
static QString countryToCode(Country country);
+ QT_DEPRECATED_VERSION_X_6_6("Use codeToTerritory(QStringView) instead")
static Country codeToCountry(QStringView countryCode) noexcept;
+#endif
static QString scriptToCode(Script script);
static Script codeToScript(QStringView scriptCode) noexcept;
static QString languageToString(Language language);
+ static QString territoryToString(Territory territory);
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territoryToString(Territory) instead")
static QString countryToString(Country country);
+#endif
static QString scriptToString(Script script);
static void setDefault(const QLocale &locale);
static QLocale c() { return QLocale(C); }
static QLocale system();
- static QList<QLocale> matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country);
+ static QList<QLocale> matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Territory territory);
+ static QList<Territory> territoriesForLanguage(Language lang);
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territoriesForLanguage(Language) instead")
static QList<Country> countriesForLanguage(Language lang);
+#endif
void setNumberOptions(NumberOptions options);
NumberOptions numberOptions() const;
diff --git a/src/corelib/text/qlocale.qdoc b/src/corelib/text/qlocale.qdoc
index f472560d22..e8246f7990 100644
--- a/src/corelib/text/qlocale.qdoc
+++ b/src/corelib/text/qlocale.qdoc
@@ -37,7 +37,7 @@
\ingroup shared
- QLocale is initialized with a language/country pair in its
+ QLocale is initialized with a language/territory pair in its
constructor and offers number-to-string and string-to-number
conversion functions similar to those in QString.
@@ -66,27 +66,27 @@
\snippet code/src_corelib_text_qlocale.cpp 1
- When a language/country pair is specified in the constructor, one
+ When a language/territory pair is specified in the constructor, one
of three things can happen:
\list
- \li If the language/country pair is found in the database, it is used.
- \li If the language is found but the country is not, or if the country
- is \c AnyCountry, the language is used with the most
- appropriate available country (for example, Germany for German),
- \li If neither the language nor the country are found, QLocale
+ \li If the language/territory pair is found in the database, it is used.
+ \li If the language is found but the territory is not, or if the territory
+ is \c AnyTerritory, the language is used with the most
+ appropriate available territory (for example, Germany for German),
+ \li If neither the language nor the territory are found, QLocale
defaults to the default locale (see setDefault()).
\endlist
- Use language() and country() to determine the actual language and
- country values used.
+ Use language() and territory() to determine the actual language and
+ territory values used.
An alternative method for constructing a QLocale object is by
specifying the locale name.
\snippet code/src_corelib_text_qlocale.cpp 2
- This constructor converts the locale name to a language/country
+ This constructor converts the locale name to a language/territory
pair; it does not use the system locale database.
\note For the current keyboard input locale take a look at
@@ -458,11 +458,25 @@
*/
/*!
+ \enum QLocale::Territory
+
+ This enumeration type is an alias for Country,
+ which shall be renamed to Territory at a future release.
+
+ \sa territory(), territoryToString()
+*/
+
+/*!
\enum QLocale::Country
- This enumerated type is used to specify a country or a region.
+ This enumerated type is used to identify a territory.
+
+ An individual territory may be a province of a country, a country (by far the
+ most common case) or a larger geographic entity, to which some localization
+ details are specific.
- \value AnyCountry
+ \value AnyCountry Osbolete alias for \c AnyTerritory
+ \value AnyTerritory Since 6.2
\value Afghanistan
\value AlandIslands
@@ -635,7 +649,8 @@
\value Mozambique
\value Myanmar
\value Namibia
- \value NauruCountry
+ \value NauruCountry Osbolete alias for \c NauruTerritory
+ \value NauruTerritory Since 6.2
\value Nepal
\value Netherlands
\value NewCaledonia
@@ -714,7 +729,8 @@
\value Thailand
\value TimorLeste
\value Togo
- \value TokelauCountry
+ \value TokelauCountry Osbolete alias for \c TokelauTerritory
+ \value TokelauTerritory Since 6.2
\value Tonga
\value TrinidadAndTobago
\value TristanDaCunha
@@ -722,7 +738,8 @@
\value Turkey
\value Turkmenistan
\value TurksAndCaicosIslands
- \value TuvaluCountry
+ \value TuvaluCountry Osbolete alias for \c TuvaluTerritory
+ \value TuvaluTerritory Since 6.2
\value Uganda
\value Ukraine
\value UnitedArabEmirates
@@ -746,9 +763,13 @@
\value Zambia
\value Zimbabwe
- \omitvalue LastCountry
+ \omitvalue LastCountry Osbolete alias for \c LastTerritory
+ \omitvalue LastTerritory
+
+ \note Use the Territory alias for this enumeration where possible.
+ The Country enum shall be renamed to Territory at a later release.
- \sa country(), countryToString()
+ \sa territory(), territoryToString(), codeToTerritory(), territoryToCode()
*/
/*!
@@ -1011,7 +1032,7 @@
otherwise returns \c false.
\note The system locale is not equal to the QLocale object constructed from
- its language(), script() and country(), even if the two agree in all data
+ its language(), script() and territory(), even if the two agree in all data
fields. Nor are two locales with different number options equal.
\sa operator!=(), setNumberOptions()
@@ -1024,7 +1045,7 @@
otherwise returns \c false.
\note The system locale is not equal to the QLocale object constructed from
- its language(), script() and country(), even if the two agree in all data
+ its language(), script() and territory(), even if the two agree in all data
fields. Nor are two locales with different number options equal.
\sa operator==(), setNumberOptions()
@@ -1072,7 +1093,7 @@
\value LanguageId a uint specifying the language.
\value ScriptId a uint specifying the script.
- \value CountryId a uint specifying the country.
+ \value TerritoryId a uint specifying the territory.
\value DecimalPoint a QString specifying the decimal point.
\value GroupSeparator a QString specifying the group separator.
\value ZeroDigit a QString specifying the zero digit.
@@ -1107,7 +1128,7 @@
\value LocaleChanged this type is queried whenever the system locale is changed.
\value ListToSeparatedString a string that represents a join of a given QStringList with a locale-defined separator.
\value NativeLanguageName a string that represents the name of the native language.
- \value NativeCountryName a string that represents the name of the native country.
+ \value NativeTerritoryName a string that represents the name of the native territory.
\sa FormatType
*/
diff --git a/src/corelib/text/qlocale_data_p.h b/src/corelib/text/qlocale_data_p.h
index 41cb376c23..8e28ebe780 100644
--- a/src/corelib/text/qlocale_data_p.h
+++ b/src/corelib/text/qlocale_data_p.h
@@ -58,13 +58,13 @@ QT_BEGIN_NAMESPACE
/* This part of the file isn't generated, but written by hand since
* Unicode CLDR doesn't contain measurement system information.
*/
-struct CountryLanguage
+struct TerritoryLanguage
{
quint16 languageId;
- quint16 countryId;
+ quint16 territoryId;
QLocale::MeasurementSystem system;
};
-static const CountryLanguage ImperialMeasurementSystems[] = {
+static const TerritoryLanguage ImperialMeasurementSystems[] = {
{ QLocale::English, QLocale::UnitedStates, QLocale::ImperialUSSystem },
{ QLocale::English, QLocale::UnitedStatesMinorOutlyingIslands, QLocale::ImperialUSSystem },
{ QLocale::Spanish, QLocale::UnitedStates, QLocale::ImperialUSSystem },
@@ -77,7 +77,7 @@ static const int ImperialMeasurementSystemsCount =
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-11-12 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -1152,7 +1152,7 @@ static const quint16 locale_index[] = {
static const QLocaleData locale_data[] = {
// lang script terr lStrt lpMid lpEnd lPair lDelm dec group prcnt zero minus plus exp qtOpn qtEnd altQO altQE lDFmt sDFmt lTFmt sTFmt slDay lDays ssDys sDays snDay nDays am pm byte siQnt iecQn crSym crDsp crFmt crFNg ntLng ntTer currISO curDgt curRnd dow1st wknd+ wknd- grpTop grpMid grpEnd
- { 1, 0, 0, 0, 0, 0, 0, 6, 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 0, 17, 0, 0, 0, 0, 56, 56, 83, 96, 0, 0, 0, 5, 22, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 8, 56, 56, 27, 27, 13, 13, 2, 2, 5, 17, 23, 0, 0, 4, 0, 0, 0, {0,0,0}, 2, 1, 1, 6, 7, 1, 3, 3 }, // C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 0, 0, 6, 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 8, 0, 17, 0, 0, 0, 0, 56, 56, 83, 96, 0, 0, 0, 5, 22, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 8, 56, 56, 27, 27, 13, 13, 2, 2, 5, 17, 23, 0, 0, 4, 0, 0, 0, {0,0,0}, 2, 1, 1, 6, 7, 1, 3, 3 }, // C/AnyScript/AnyTerritory
{ 3, 66, 77, 0, 0, 0, 0, 6, 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 27, 44, 0, 0, 56, 56, 56, 56, 83, 83, 0, 0, 0, 5, 22, 0, 0, 4, 0, 0, 0, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 5, 27, 27, 27, 27, 13, 13, 2, 2, 4, 17, 23, 0, 0, 5, 0, 0, 0, {69,84,66}, 2, 1, 7, 6, 7, 1, 3, 3 }, // Afar/Latin/Ethiopia
{ 4, 66, 216, 0, 0, 7, 7, 6, 1, 14, 2, 3, 4, 5, 9, 10, 11, 12, 13, 54, 44, 0, 0, 109, 109, 166, 166, 193, 193, 2, 2, 45, 5, 22, 0, 0, 9, 13, 0, 9, 6, 6, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 10, 10, 5, 57, 57, 27, 27, 13, 13, 3, 3, 5, 17, 23, 1, 20, 4, 6, 9, 11, {90,65,82}, 2, 1, 7, 6, 7, 1, 3, 3 }, // Afrikaans/Latin/South Africa
{ 4, 66, 162, 0, 0, 7, 7, 6, 1, 14, 2, 3, 4, 5, 9, 10, 11, 12, 13, 71, 44, 10, 22, 109, 109, 166, 166, 193, 193, 2, 2, 45, 5, 22, 1, 20, 9, 13, 0, 20, 6, 6, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 10, 12, 7, 57, 57, 27, 27, 13, 13, 3, 3, 5, 17, 23, 1, 16, 4, 6, 9, 7, {78,65,68}, 2, 1, 1, 6, 7, 1, 3, 3 }, // Afrikaans/Latin/Namibia
@@ -4775,7 +4775,7 @@ static const quint16 script_name_index[] = {
1312, // Yi
};
-static const char country_name_list[] =
+static const char territory_name_list[] =
"Default\0"
"Afghanistan\0"
"Aland Islands\0"
@@ -5040,8 +5040,8 @@ static const char country_name_list[] =
"Zimbabwe\0"
;
-static const quint16 country_name_index[] = {
- 0, // AnyCountry
+static const quint16 territory_name_index[] = {
+ 0, // AnyTerritory
8, // Afghanistan
20, // Aland Islands
34, // Albania
@@ -5781,8 +5781,8 @@ static const unsigned char script_code_list[] =
"Yiii" // Yi
;
-static const unsigned char country_code_list[] =
-"ZZ\0" // AnyCountry
+static const unsigned char territory_code_list[] =
+"ZZ\0" // AnyTerritory
"AF\0" // Afghanistan
"AX\0" // Aland Islands
"AL\0" // Albania
diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm
index 9c1eb6dcfb..2c63902b91 100644
--- a/src/corelib/text/qlocale_mac.mm
+++ b/src/corelib/text/qlocale_mac.mm
@@ -426,8 +426,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
switch(type) {
case LanguageId:
return getLocaleValue<QLocalePrivate::codeToLanguage>(kCFLocaleLanguageCode);
- case CountryId:
- return getLocaleValue<QLocalePrivate::codeToCountry>(kCFLocaleCountryCode);
+ case TerritoryId:
+ return getLocaleValue<QLocalePrivate::codeToTerritory>(kCFLocaleCountryCode);
case ScriptId:
return getLocaleValue<QLocalePrivate::codeToScript>(kCFLocaleScriptCode);
case DecimalPoint:
diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h
index 6e4073eaa3..44ac62422b 100644
--- a/src/corelib/text/qlocale_p.h
+++ b/src/corelib/text/qlocale_p.h
@@ -85,7 +85,7 @@ public:
enum QueryType {
LanguageId, // uint
- CountryId, // uint
+ TerritoryId, // uint
DecimalPoint, // QString
GroupSeparator, // QString (empty QString means: don't group digits)
ZeroDigit, // QString
@@ -122,7 +122,7 @@ public:
ListToSeparatedString, // QString
LocaleChanged, // system locale changed
NativeLanguageName, // QString
- NativeCountryName, // QString
+ NativeTerritoryName, // QString
StandaloneMonthNameLong, // QString, in: int
StandaloneMonthNameShort // QString, in: int
};
@@ -150,17 +150,17 @@ struct QLocaleId
{
Q_CORE_EXPORT static QLocaleId fromName(const QString &name);
inline bool operator==(QLocaleId other) const
- { return language_id == other.language_id && script_id == other.script_id && country_id == other.country_id; }
+ { return language_id == other.language_id && script_id == other.script_id && territory_id == other.territory_id; }
inline bool operator!=(QLocaleId other) const
{ return !operator==(other); }
inline bool isValid() const
{
return language_id <= QLocale::LastLanguage && script_id <= QLocale::LastScript
- && country_id <= QLocale::LastCountry;
+ && territory_id <= QLocale::LastTerritory;
}
inline bool matchesAll() const
{
- return !language_id && !script_id && !country_id;
+ return !language_id && !script_id && !territory_id;
}
// Use as: filter.accept...(candidate)
inline bool acceptLanguage(quint16 lang) const
@@ -169,9 +169,9 @@ struct QLocaleId
// So, when searching for AnyLanguage, accept everything *but* AnyLanguage.
return language_id ? lang == language_id : lang;
}
- inline bool acceptScriptCountry(QLocaleId other) const
+ inline bool acceptScriptTerritory(QLocaleId other) const
{
- return (!country_id || other.country_id == country_id)
+ return (!territory_id || other.territory_id == territory_id)
&& (!script_id || other.script_id == script_id);
}
@@ -180,7 +180,7 @@ struct QLocaleId
QByteArray name(char separator = '-') const;
- ushort language_id = 0, script_id = 0, country_id = 0;
+ ushort language_id = 0, script_id = 0, territory_id = 0;
};
Q_DECLARE_TYPEINFO(QLocaleId, Q_PRIMITIVE_TYPE);
@@ -288,7 +288,7 @@ public:
QLocale::NumberOptions number_options = QLocale::DefaultNumberOptions) const;
// Access to assorted data members:
- QLocaleId id() const { return QLocaleId { m_language_id, m_script_id, m_country_id }; }
+ QLocaleId id() const { return QLocaleId { m_language_id, m_script_id, m_territory_id }; }
QString decimalPoint() const;
QString groupSeparator() const;
@@ -359,7 +359,7 @@ public:
X(byteCount) X(byteAmountSI) X(byteAmountIEC) \
X(currencySymbol) X(currencyDisplayName) \
X(currencyFormat) X(currencyFormatNegative) \
- X(endonymLanguage) X(endonymCountry)
+ X(endonymLanguage) X(endonymTerritory)
#define rangeGetter(name) \
DataRange name() const { return { m_ ## name ## _idx, m_ ## name ## _size }; }
@@ -367,7 +367,7 @@ public:
#undef rangeGetter
public:
- quint16 m_language_id, m_script_id, m_country_id;
+ quint16 m_language_id, m_script_id, m_territory_id;
// Offsets, then sizes, for each range:
#define rangeIndex(name) quint16 m_ ## name ## _idx;
@@ -401,22 +401,22 @@ public:
m_index(index), m_numberOptions(numberOptions) {}
quint16 languageId() const { return m_data->m_language_id; }
- quint16 countryId() const { return m_data->m_country_id; }
+ quint16 territoryId() const { return m_data->m_territory_id; }
QByteArray bcp47Name(char separator = '-') const;
QByteArray rawName(char separator = '-') const;
inline QLatin1String languageCode() const { return languageToCode(QLocale::Language(m_data->m_language_id)); }
inline QLatin1String scriptCode() const { return scriptToCode(QLocale::Script(m_data->m_script_id)); }
- inline QLatin1String countryCode() const { return countryToCode(QLocale::Country(m_data->m_country_id)); }
+ inline QLatin1String territoryCode() const { return territoryToCode(QLocale::Territory(m_data->m_territory_id)); }
static const QLocalePrivate *get(const QLocale &l) { return l.d; }
static QLatin1String languageToCode(QLocale::Language language);
static QLatin1String scriptToCode(QLocale::Script script);
- static QLatin1String countryToCode(QLocale::Country country);
+ static QLatin1String territoryToCode(QLocale::Territory territory);
static QLocale::Language codeToLanguage(QStringView code) noexcept;
static QLocale::Script codeToScript(QStringView code) noexcept;
- static QLocale::Country codeToCountry(QStringView code) noexcept;
+ static QLocale::Territory codeToTerritory(QStringView code) noexcept;
QLocale::MeasurementSystem measurementSystem() const;
diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index 2caa6b7799..29053a7074 100644
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -130,7 +130,7 @@ static bool contradicts(const QString &maybe, const QString &known)
*/
QLocaleId knownId = QLocaleId::fromName(known);
QLocaleId maybeId = QLocaleId::fromName(maybe);
- return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptCountry(knownId));
+ return !(maybeId.acceptLanguage(knownId.language_id) && maybeId.acceptScriptTerritory(knownId));
}
QLocale QSystemLocale::fallbackLocale() const
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 664e82a5aa..c73e937581 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -107,7 +107,7 @@ struct QSystemLocalePrivate
QVariant toCurrencyString(const QSystemLocale::CurrencyToStringArgument &);
QVariant uiLanguages();
QVariant nativeLanguageName();
- QVariant nativeCountryName();
+ QVariant nativeTerritoryName();
void update();
@@ -625,7 +625,7 @@ QVariant QSystemLocalePrivate::nativeLanguageName()
return getLocaleInfo(LOCALE_SNATIVELANGUAGENAME);
}
-QVariant QSystemLocalePrivate::nativeCountryName()
+QVariant QSystemLocalePrivate::nativeTerritoryName()
{
return getLocaleInfo(LOCALE_SNATIVECOUNTRYNAME);
}
@@ -757,13 +757,13 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
return d->zeroDigit();
case LanguageId:
case ScriptId:
- case CountryId: {
+ case TerritoryId: {
QLocaleId lid = QLocaleId::fromName(QString::fromLatin1(getWinLocaleName()));
if (type == LanguageId)
return lid.language_id;
if (type == ScriptId)
return lid.script_id ? lid.script_id : ushort(fallbackLocale().script());
- return lid.country_id ? lid.country_id : ushort(fallbackLocale().country());
+ return lid.territory_id ? lid.territory_id : ushort(fallbackLocale().territory());
}
case MeasurementSystem:
return d->measurementSystem();
@@ -786,8 +786,8 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
break;
case NativeLanguageName:
return d->nativeLanguageName();
- case NativeCountryName:
- return d->nativeCountryName();
+ case NativeTerritoryName:
+ return d->nativeTerritoryName();
default:
break;
}
diff --git a/src/corelib/time/qcalendarbackend_p.h b/src/corelib/time/qcalendarbackend_p.h
index 8a3d4815bc..b011fa0f62 100644
--- a/src/corelib/time/qcalendarbackend_p.h
+++ b/src/corelib/time/qcalendarbackend_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
// Locale-related parts, mostly handled in ../text/qlocale.cpp
struct QCalendarLocale {
- quint16 m_language_id, m_script_id, m_country_id;
+ quint16 m_language_id, m_script_id, m_territory_id;
#define rangeGetter(name) \
QLocaleData::DataRange name() const { return { m_ ## name ## _idx, m_ ## name ## _size }; }
diff --git a/src/corelib/time/qhijricalendar_data_p.h b/src/corelib/time/qhijricalendar_data_p.h
index 48932eb1b6..012f09ef13 100644
--- a/src/corelib/time/qhijricalendar_data_p.h
+++ b/src/corelib/time/qhijricalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 0, 0, 106, 106, 184, 184,106,106, 78, 78, 26, 26 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qjalalicalendar_data_p.h b/src/corelib/time/qjalalicalendar_data_p.h
index 8106550670..1c82e75e84 100644
--- a/src/corelib/time/qjalalicalendar_data_p.h
+++ b/src/corelib/time/qjalalicalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 83, 83, 130, 153, 83, 83, 47, 47, 23, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 83, 83, 130, 153, 83, 83, 47, 47, 23, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 0, 0, 0, 0, 153, 153, 83, 83, 83, 83, 26, 26 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qromancalendar_data_p.h b/src/corelib/time/qromancalendar_data_p.h
index 6f19f573fb..46926c45de 100644
--- a/src/corelib/time/qromancalendar_data_p.h
+++ b/src/corelib/time/qromancalendar_data_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
// GENERATED PART STARTS HERE
/*
- This part of the file was generated on 2020-10-30 from the
+ This part of the file was generated on 2021-03-12 from the
Common Locale Data Repository v38
http://www.unicode.org/cldr/
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
static const QCalendarLocale locale_data[] = {
// lang script terr sLong long sShrt short sNarw narow Sizes...
- { 1, 0, 0, 0, 0, 85, 85, 132, 155, 85, 85, 47, 47, 23, 26 },// C/AnyScript/AnyCountry
+ { 1, 0, 0, 0, 0, 85, 85, 132, 155, 85, 85, 47, 47, 23, 26 },// C/AnyScript/AnyTerritory
{ 3, 66, 77, 181, 181, 181, 181, 155, 155, 47, 47, 47, 47, 26, 26 },// Afar/Latin/Ethiopia
{ 4, 66, 216, 228, 228, 319, 319, 132, 132, 91, 91, 58, 58, 23, 23 },// Afrikaans/Latin/South Africa
{ 4, 66, 162, 228, 228, 319, 319, 132, 132, 91, 91, 58, 58, 23, 23 },// Afrikaans/Latin/Namibia
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index 5f4589eda0..b9c6d727c8 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -373,23 +373,23 @@ QTimeZone::QTimeZone(int offsetSeconds)
Creates a custom time zone with an ID of \a ianaId and an offset from UTC
of \a offsetSeconds. The \a name will be the name used by displayName()
for the LongName, the \a abbreviation will be used by displayName() for the
- ShortName and by abbreviation(), and the optional \a country will be used
- by country(). The \a comment is an optional note that may be displayed in
+ ShortName and by abbreviation(), and the optional \a territory will be used
+ by territory(). The \a comment is an optional note that may be displayed in
a GUI to assist users in selecting a time zone.
The \a ianaId must not be one of the available system IDs returned by
availableTimeZoneIds(). The \a offsetSeconds from UTC must be in the range
-14 hours to +14 hours.
- If the custom time zone does not have a specific country then set it to the
- default value of QLocale::AnyCountry.
+ If the custom time zone does not have a specific territory then set it to the
+ default value of QLocale::AnyTerritory.
*/
QTimeZone::QTimeZone(const QByteArray &ianaId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country, const QString &comment)
+ const QString &abbreviation, QLocale::Territory territory, const QString &comment)
{
if (!isTimeZoneIdAvailable(ianaId))
- d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, country, comment);
+ d = new QUtcTimeZonePrivate(ianaId, offsetSeconds, name, abbreviation, territory, comment);
}
/*!
@@ -482,7 +482,7 @@ bool QTimeZone::isValid() const
Returns the IANA ID for the time zone.
IANA IDs are used on all platforms. On Windows these are translated
- from the Windows ID into the closest IANA ID for the time zone and country.
+ from the Windows ID into the closest IANA ID for the time zone and territory.
*/
QByteArray QTimeZone::id() const
@@ -491,13 +491,27 @@ QByteArray QTimeZone::id() const
}
/*!
- Returns the country for the time zone.
+ \since 6.2
+
+ Returns the territory for the time zone.
+*/
+QLocale::Territory QTimeZone::territory() const
+{
+ return isValid() ? d->territory() : QLocale::AnyTerritory;
+}
+
+#if QT_DEPRECATED_SINCE(6, 6)
+/*!
+ \obsolete Use territory() instead.
+
+ Returns the territory for the time zone.
*/
QLocale::Country QTimeZone::country() const
{
- return isValid() ? d->country() : QLocale::AnyCountry;
+ return territory();
}
+#endif
/*!
Returns any comment for the time zone.
@@ -841,20 +855,20 @@ QList<QByteArray> QTimeZone::availableTimeZoneIds()
}
/*!
- Returns a list of all available IANA time zone IDs for a given \a country.
+ Returns a list of all available IANA time zone IDs for a given \a territory.
- As a special case, a \a country of Qt::AnyCountry returns those time zones
- that do not have any country related to them, such as UTC. If you require
+ As a special case, a \a territory of Qt::AnyTerritory returns those time zones
+ that do not have any territory related to them, such as UTC. If you require
a list of all time zone IDs for all countries then use the standard
availableTimeZoneIds() method.
\sa isTimeZoneIdAvailable()
*/
-QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Country country)
+QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Territory territory)
{
- return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(country),
- global_tz->backend->availableTimeZoneIds(country));
+ return set_union(QUtcTimeZonePrivate().availableTimeZoneIds(territory),
+ global_tz->backend->availableTimeZoneIds(territory));
}
/*!
@@ -898,21 +912,20 @@ QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId)
}
/*!
- Returns the default IANA ID for a given \a windowsId and \a country.
+ Returns the default IANA ID for a given \a windowsId and \a territory.
- Because a Windows ID can cover several IANA IDs within a given country,
- the most frequently used IANA ID in that country is returned.
+ Because a Windows ID can cover several IANA IDs within a given territory,
+ the most frequently used IANA ID in that territory is returned.
- As a special case, QLocale::AnyCountry returns the default of those IANA IDs
- that do not have any specific country.
+ As a special case, QLocale::AnyTerritory returns the default of those IANA IDs
+ that do not have any specific territory.
\sa ianaIdToWindowsId(), windowsIdToIanaIds()
*/
-QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country)
+QByteArray QTimeZone::windowsIdToDefaultIanaId(const QByteArray &windowsId, QLocale::Territory territory)
{
- return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, country);
+ return QTimeZonePrivate::windowsIdToDefaultIanaId(windowsId, territory);
}
/*!
@@ -929,21 +942,20 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId)
}
/*!
- Returns all the IANA IDs for a given \a windowsId and \a country.
+ Returns all the IANA IDs for a given \a windowsId and \a territory.
- As a special case QLocale::AnyCountry returns those IANA IDs that do
- not have any specific country.
+ As a special case QLocale::AnyTerritory returns those IANA IDs that do
+ not have any specific territory.
The returned list is in order of frequency of usage, i.e. larger zones
- within a country are listed first.
+ within a territory are listed first.
\sa ianaIdToWindowsId(), windowsIdToDefaultIanaId()
*/
-QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country)
+QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId, QLocale::Territory territory)
{
- return QTimeZonePrivate::windowsIdToIanaIds(windowsId, country);
+ return QTimeZonePrivate::windowsIdToIanaIds(windowsId, territory);
}
#ifndef QT_NO_DATASTREAM
@@ -969,16 +981,16 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
int utcOffset;
QString name;
QString abbreviation;
- int country;
+ int territory;
QString comment;
- ds >> ianaId >> utcOffset >> name >> abbreviation >> country >> comment;
+ ds >> ianaId >> utcOffset >> name >> abbreviation >> territory >> comment;
// Try creating as a system timezone, which succeeds (producing a valid
// zone) iff ianaId is valid; we can then ignore the other data.
tz = QTimeZone(ianaId.toUtf8());
// If not, then construct a custom timezone using all the saved values:
if (!tz.isValid())
tz = QTimeZone(ianaId.toUtf8(), utcOffset, name, abbreviation,
- QLocale::Country(country), comment);
+ QLocale::Territory(territory), comment);
} else {
tz = QTimeZone(ianaId.toUtf8());
}
diff --git a/src/corelib/time/qtimezone.h b/src/corelib/time/qtimezone.h
index 5fd9044ef5..6039749689 100644
--- a/src/corelib/time/qtimezone.h
+++ b/src/corelib/time/qtimezone.h
@@ -93,7 +93,7 @@ public:
explicit QTimeZone(const QByteArray &ianaId);
explicit QTimeZone(int offsetSeconds);
QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country = QLocale::AnyCountry,
+ const QString &abbreviation, QLocale::Territory territory = QLocale::AnyTerritory,
const QString &comment = QString());
QTimeZone(const QTimeZone &other);
~QTimeZone();
@@ -110,7 +110,11 @@ public:
bool isValid() const;
QByteArray id() const;
+ QLocale::Territory territory() const;
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Use territory() instead")
QLocale::Country country() const;
+#endif
QString comment() const;
QString displayName(const QDateTime &atDateTime,
@@ -142,16 +146,16 @@ public:
static bool isTimeZoneIdAvailable(const QByteArray &ianaId);
static QList<QByteArray> availableTimeZoneIds();
- static QList<QByteArray> availableTimeZoneIds(QLocale::Country country);
+ static QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory);
static QList<QByteArray> availableTimeZoneIds(int offsetSeconds);
static QByteArray ianaIdToWindowsId(const QByteArray &ianaId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone);
diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp
index 5588cf8cce..be00f658bc 100644
--- a/src/corelib/time/qtimezoneprivate.cpp
+++ b/src/corelib/time/qtimezoneprivate.cpp
@@ -171,7 +171,7 @@ QByteArray QTimeZonePrivate::id() const
return m_id;
}
-QLocale::Country QTimeZonePrivate::country() const
+QLocale::Territory QTimeZonePrivate::territory() const
{
// Default fall-back mode, use the zoneTable to find Region of known Zones
for (int i = 0; i < zoneDataTableSize; ++i) {
@@ -181,11 +181,11 @@ QLocale::Country QTimeZonePrivate::country() const
qsizetype index = idView.indexOf(' ');
QByteArrayView next = index == -1 ? idView : idView.first(index);
if (next == m_id)
- return (QLocale::Country)data->country;
+ return (QLocale::Territory)data->territory;
idView = index == -1 ? QByteArrayView() : idView.sliced(index + 1);
}
}
- return QLocale::AnyCountry;
+ return QLocale::AnyTerritory;
}
QString QTimeZonePrivate::comment() const
@@ -524,14 +524,14 @@ QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds() const
return QList<QByteArray>();
}
-QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
// Default fall-back mode, use the zoneTable to find Region of know Zones
QList<QByteArray> regions;
// First get all Zones in the Zones table belonging to the Region
for (int i = 0; i < zoneDataTableSize; ++i) {
- if (zoneData(i)->country == country)
+ if (zoneData(i)->territory == territory)
regions += ianaId(zoneData(i)).split(' ');
}
@@ -739,9 +739,9 @@ QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsI
}
QByteArray QTimeZonePrivate::windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country)
+ QLocale::Territory territory)
{
- const QList<QByteArray> list = windowsIdToIanaIds(windowsId, country);
+ const QList<QByteArray> list = windowsIdToIanaIds(windowsId, territory);
if (list.count() > 0)
return list.first();
else
@@ -765,13 +765,13 @@ QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windows
}
QList<QByteArray> QTimeZonePrivate::windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country)
+ QLocale::Territory territory)
{
const quint16 windowsIdKey = toWindowsIdKey(windowsId);
for (int i = 0; i < zoneDataTableSize; ++i) {
const QZoneData *data = zoneData(i);
// Return the region matches in preference order
- if (data->windowsIdKey == windowsIdKey && data->country == (quint16) country)
+ if (data->windowsIdKey == windowsIdKey && data->territory == static_cast<quint16>(territory))
return ianaId(data).split(' ');
}
@@ -793,7 +793,7 @@ template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone()
QUtcTimeZonePrivate::QUtcTimeZonePrivate()
{
const QString name = utcQString();
- init(utcQByteArray(), 0, name, name, QLocale::AnyCountry, name);
+ init(utcQByteArray(), 0, name, name, QLocale::AnyTerritory, name);
}
// Create a named UTC time zone
@@ -805,7 +805,7 @@ QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &id)
const QByteArray uid = utcId(data);
if (uid == id) {
QString name = QString::fromUtf8(id);
- init(id, data->offsetFromUtc, name, name, QLocale::AnyCountry, name);
+ init(id, data->offsetFromUtc, name, name, QLocale::AnyTerritory, name);
break;
}
}
@@ -848,21 +848,21 @@ qint64 QUtcTimeZonePrivate::offsetFromUtcString(const QByteArray &id)
QUtcTimeZonePrivate::QUtcTimeZonePrivate(qint32 offsetSeconds)
{
QString utcId = isoOffsetFormat(offsetSeconds, QTimeZone::ShortName);
- init(utcId.toUtf8(), offsetSeconds, utcId, utcId, QLocale::AnyCountry, utcId);
+ init(utcId.toUtf8(), offsetSeconds, utcId, utcId, QLocale::AnyTerritory, utcId);
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSeconds,
const QString &name, const QString &abbreviation,
- QLocale::Country country, const QString &comment)
+ QLocale::Territory territory, const QString &comment)
{
- init(zoneId, offsetSeconds, name, abbreviation, country, comment);
+ init(zoneId, offsetSeconds, name, abbreviation, territory, comment);
}
QUtcTimeZonePrivate::QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other)
: QTimeZonePrivate(other), m_name(other.m_name),
m_abbreviation(other.m_abbreviation),
m_comment(other.m_comment),
- m_country(other.m_country),
+ m_territory(other.m_territory),
m_offsetFromUtc(other.m_offsetFromUtc)
{
}
@@ -892,20 +892,20 @@ void QUtcTimeZonePrivate::init(const QByteArray &zoneId)
}
void QUtcTimeZonePrivate::init(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment)
{
m_id = zoneId;
m_offsetFromUtc = offsetSeconds;
m_name = name;
m_abbreviation = abbreviation;
- m_country = country;
+ m_territory = territory;
m_comment = comment;
}
-QLocale::Country QUtcTimeZonePrivate::country() const
+QLocale::Territory QUtcTimeZonePrivate::territory() const
{
- return m_country;
+ return m_territory;
}
QString QUtcTimeZonePrivate::comment() const
@@ -974,10 +974,10 @@ QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(QLocale::Territory country) const
{
- // If AnyCountry then is request for all non-region offset codes
- if (country == QLocale::AnyCountry)
+ // If AnyTerritory then is request for all non-region offset codes
+ if (country == QLocale::AnyTerritory)
return availableTimeZoneIds();
return QList<QByteArray>();
}
@@ -1002,7 +1002,7 @@ QList<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds(qint32 offsetSeconds
void QUtcTimeZonePrivate::serialize(QDataStream &ds) const
{
ds << QStringLiteral("OffsetFromUtc") << QString::fromUtf8(m_id) << m_offsetFromUtc << m_name
- << m_abbreviation << (qint32) m_country << m_comment;
+ << m_abbreviation << static_cast<qint32>(m_territory) << m_comment;
}
#endif // QT_NO_DATASTREAM
diff --git a/src/corelib/time/qtimezoneprivate_android.cpp b/src/corelib/time/qtimezoneprivate_android.cpp
index d10433ff23..9be5ea4a73 100644
--- a/src/corelib/time/qtimezoneprivate_android.cpp
+++ b/src/corelib/time/qtimezoneprivate_android.cpp
@@ -90,14 +90,14 @@ static QJniObject getDisplayName(QJniObject zone, jint style, jboolean dst,
{
QJniObject jlanguage
= QJniObject::fromString(QLocale::languageToString(locale.language()));
- QJniObject jcountry
- = QJniObject::fromString(QLocale::countryToString(locale.country()));
+ QJniObject jterritory
+ = QJniObject::fromString(QLocale::territoryToString(locale.territory()));
QJniObject
jvariant = QJniObject::fromString(QLocale::scriptToString(locale.script()));
QJniObject jlocale("java.util.Locale",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
static_cast<jstring>(jlanguage.object()),
- static_cast<jstring>(jcountry.object()),
+ static_cast<jstring>(jterritory.object()),
static_cast<jstring>(jvariant.object()));
return zone.callObjectMethod("getDisplayName",
diff --git a/src/corelib/time/qtimezoneprivate_data_p.h b/src/corelib/time/qtimezoneprivate_data_p.h
index 16af5625f1..9438984f34 100644
--- a/src/corelib/time/qtimezoneprivate_data_p.h
+++ b/src/corelib/time/qtimezoneprivate_data_p.h
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
struct QZoneData {
quint16 windowsIdKey; // Windows ID Key
- quint16 country; // Country of IANA ID's, AnyCountry means No Country
+ quint16 territory; // Territory of IANA ID's, AnyTerritory means No Territory
quint16 ianaIdIndex; // All IANA ID's for the Windows ID and Country, space separated
};
diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp
index 198e1530e4..706deb2b17 100644
--- a/src/corelib/time/qtimezoneprivate_icu.cpp
+++ b/src/corelib/time/qtimezoneprivate_icu.cpp
@@ -475,9 +475,9 @@ QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
- const QLatin1String regionCode = QLocalePrivate::countryToCode(country);
+ const QLatin1String regionCode = QLocalePrivate::territoryToCode(territory);
const QByteArray regionCodeUtf8 = QString(regionCode).toUtf8();
UErrorCode status = U_ZERO_ERROR;
UEnumeration *uenum = ucal_openCountryTimeZones(regionCodeUtf8.data(), &status);
diff --git a/src/corelib/time/qtimezoneprivate_p.h b/src/corelib/time/qtimezoneprivate_p.h
index 164a1b790f..feb6ab5369 100644
--- a/src/corelib/time/qtimezoneprivate_p.h
+++ b/src/corelib/time/qtimezoneprivate_p.h
@@ -101,7 +101,7 @@ public:
bool isValid() const;
QByteArray id() const;
- virtual QLocale::Country country() const;
+ virtual QLocale::Territory territory() const;
virtual QString comment() const;
virtual QString displayName(qint64 atMSecsSinceEpoch,
@@ -131,7 +131,7 @@ public:
virtual bool isTimeZoneIdAvailable(const QByteArray &ianaId) const;
virtual QList<QByteArray> availableTimeZoneIds() const;
- virtual QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const;
+ virtual QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const;
virtual QList<QByteArray> availableTimeZoneIds(int utcOffset) const;
virtual void serialize(QDataStream &ds) const;
@@ -151,10 +151,10 @@ public:
static QByteArray ianaIdToWindowsId(const QByteArray &ianaId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId);
static QByteArray windowsIdToDefaultIanaId(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId);
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
- QLocale::Country country);
+ QLocale::Territory territory);
// returns "UTC" QString and QByteArray
[[nodiscard]] static inline QString utcQString()
@@ -185,7 +185,7 @@ public:
QUtcTimeZonePrivate(qint32 offsetSeconds);
// Create custom offset from UTC
QUtcTimeZonePrivate(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment);
QUtcTimeZonePrivate(const QUtcTimeZonePrivate &other);
virtual ~QUtcTimeZonePrivate();
@@ -197,7 +197,7 @@ public:
Data data(qint64 forMSecsSinceEpoch) const override;
- QLocale::Country country() const override;
+ QLocale::Territory territory() const override;
QString comment() const override;
QString displayName(QTimeZone::TimeType timeType,
@@ -212,7 +212,7 @@ public:
bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory country) const override;
QList<QByteArray> availableTimeZoneIds(int utcOffset) const override;
void serialize(QDataStream &ds) const override;
@@ -220,13 +220,13 @@ public:
private:
void init(const QByteArray &zoneId);
void init(const QByteArray &zoneId, int offsetSeconds, const QString &name,
- const QString &abbreviation, QLocale::Country country,
+ const QString &abbreviation, QLocale::Territory territory,
const QString &comment);
QString m_name;
QString m_abbreviation;
QString m_comment;
- QLocale::Country m_country;
+ QLocale::Territory m_territory;
int m_offsetFromUtc;
};
@@ -263,7 +263,7 @@ public:
QByteArray systemTimeZoneId() const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
QList<QByteArray> availableTimeZoneIds(int offsetFromUtc) const override;
private:
@@ -315,7 +315,7 @@ public:
QTzTimeZonePrivate *clone() const override;
- QLocale::Country country() const override;
+ QLocale::Territory territory() const override;
QString comment() const override;
QString displayName(qint64 atMSecsSinceEpoch,
@@ -343,7 +343,7 @@ public:
bool isTimeZoneIdAvailable(const QByteArray &ianaId) const override;
QList<QByteArray> availableTimeZoneIds() const override;
- QList<QByteArray> availableTimeZoneIds(QLocale::Country country) const override;
+ QList<QByteArray> availableTimeZoneIds(QLocale::Territory territory) const override;
private:
void init(const QByteArray &ianaId);
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index 72ac0fe8de..9daffbad5d 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
*/
struct QTzTimeZone {
- QLocale::Country country;
+ QLocale::Territory territory;
QByteArray comment;
};
@@ -98,7 +98,7 @@ static QTzTimeZoneHash loadTzTimeZones()
if (Q_LIKELY(cut > 0)) {
QTzTimeZone zone;
// TODO: QLocale & friends could do this look-up without UTF8-conversion:
- zone.country = QLocalePrivate::codeToCountry(QString::fromUtf8(text.first(cut)));
+ zone.territory = QLocalePrivate::codeToTerritory(QString::fromUtf8(text.first(cut)));
text = text.sliced(cut + 1);
cut = text.indexOf('\t');
if (Q_LIKELY(cut >= 0)) { // Skip over Coordinates, read ID and comment
@@ -916,9 +916,9 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
}
}
-QLocale::Country QTzTimeZonePrivate::country() const
+QLocale::Territory QTzTimeZonePrivate::territory() const
{
- return tzZones->value(m_id).country;
+ return tzZones->value(m_id).territory;
}
QString QTzTimeZonePrivate::comment() const
@@ -1165,12 +1165,12 @@ QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds() const
return result;
}
-QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
+QList<QByteArray> QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{
- // TODO AnyCountry
+ // TODO AnyTerritory
QList<QByteArray> result;
for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end; ++it) {
- if (it.value().country == country)
+ if (it.value().territory == territory)
result << it.key();
}
std::sort(result.begin(), result.end());
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index 7c80dbc38b..0846890b60 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -376,13 +376,13 @@ int yearEndOffset(const QWinTimeZonePrivate::QWinTransitionRule &rule, int year)
return offset;
}
-QLocale::Country userCountry()
+QLocale::Territory userTerritory()
{
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
- return (size == 3) ? QLocalePrivate::codeToCountry(QStringView(code, size))
- : QLocale::AnyCountry;
+ return (size == 3) ? QLocalePrivate::codeToTerritory(QStringView(code, size))
+ : QLocale::AnyTerritory;
}
// Index of last rule in rules with .startYear <= year:
@@ -727,13 +727,13 @@ QTimeZonePrivate::Data QWinTimeZonePrivate::previousTransition(qint64 beforeMSec
QByteArray QWinTimeZonePrivate::systemTimeZoneId() const
{
- const QLocale::Country country = userCountry();
+ const QLocale::Territory territory = userTerritory();
const QByteArray windowsId = windowsSystemZoneId();
QByteArray ianaId;
- // If we have a real country, then try get a specific match for that country
- if (country != QLocale::AnyCountry)
- ianaId = windowsIdToDefaultIanaId(windowsId, country);
- // If we don't have a real country, or there wasn't a specific match, try the global default
+ // If we have a real territory, then try get a specific match for that territory
+ if (territory != QLocale::AnyTerritory)
+ ianaId = windowsIdToDefaultIanaId(windowsId, territory);
+ // If we don't have a real territory, or there wasn't a specific match, try the global default
if (ianaId.isEmpty())
ianaId = windowsIdToDefaultIanaId(windowsId);
return ianaId;
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index 01c119d544..1825c77b53 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -108,7 +108,7 @@ public:
RCCFileInfo(const QString &name = QString(), const QFileInfo &fileInfo = QFileInfo(),
QLocale::Language language = QLocale::C,
- QLocale::Country country = QLocale::AnyCountry,
+ QLocale::Territory territory = QLocale::AnyTerritory,
uint flags = NoFlags,
RCCResourceLibrary::CompressionAlgorithm compressAlgo = CONSTANT_COMPRESSALGO_DEFAULT,
int compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT,
@@ -126,7 +126,7 @@ public:
int m_flags;
QString m_name;
QLocale::Language m_language;
- QLocale::Country m_country;
+ QLocale::Territory m_territory;
QFileInfo m_fileInfo;
RCCFileInfo *m_parent;
QMultiHash<QString, RCCFileInfo *> m_children;
@@ -141,14 +141,14 @@ public:
};
RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo,
- QLocale::Language language, QLocale::Country country, uint flags,
+ QLocale::Language language, QLocale::Territory territory, uint flags,
RCCResourceLibrary::CompressionAlgorithm compressAlgo, int compressLevel, int compressThreshold,
bool noZstd)
{
m_name = name;
m_fileInfo = fileInfo;
m_language = language;
- m_country = country;
+ m_territory = territory;
m_flags = flags;
m_parent = nullptr;
m_nameOffset = 0;
@@ -184,7 +184,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
lib.writeString(" // ");
lib.writeByteArray(resourceName().toLocal8Bit());
lib.writeString(" [");
- lib.writeByteArray(QByteArray::number(m_country));
+ lib.writeByteArray(QByteArray::number(m_territory));
lib.writeString("::");
lib.writeByteArray(QByteArray::number(m_language));
lib.writeString("[\n ");
@@ -216,7 +216,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
lib.writeNumber2(m_flags);
// locale
- lib.writeNumber2(m_country);
+ lib.writeNumber2(m_territory);
lib.writeNumber2(m_language);
//data offset
@@ -508,7 +508,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
QString prefix;
QLocale::Language language = QLocale::c().language();
- QLocale::Country country = QLocale::c().country();
+ QLocale::Territory territory = QLocale::c().territory();
QString alias;
auto compressAlgo = m_compressionAlgo;
int compressLevel = m_compressLevel;
@@ -531,7 +531,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
QXmlStreamAttributes attributes = reader.attributes();
language = QLocale::c().language();
- country = QLocale::c().country();
+ territory = QLocale::c().territory();
if (attributes.hasAttribute(m_strings.ATTRIBUTE_LANG)) {
QString attribute = attributes.value(m_strings.ATTRIBUTE_LANG).toString();
@@ -539,9 +539,9 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
language = lang.language();
if (2 == attribute.length()) {
// Language only
- country = QLocale::AnyCountry;
+ territory = QLocale::AnyTerritory;
} else {
- country = lang.country();
+ territory = lang.territory();
}
}
@@ -656,7 +656,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
QFileInfo child(filePath);
const bool arc =
addFile(alias + child.fileName(),
- RCCFileInfo(child.fileName(), child, language, country,
+ RCCFileInfo(child.fileName(), child, language, territory,
child.isDir() ? RCCFileInfo::Directory
: RCCFileInfo::NoFlags,
compressAlgo, compressLevel, compressThreshold,
@@ -670,7 +670,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
RCCFileInfo(alias.section(slash, -1),
file,
language,
- country,
+ territory,
RCCFileInfo::NoFlags,
compressAlgo,
compressLevel,
@@ -715,7 +715,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
if (!listMode && m_format == Binary) {
// create dummy entry, otherwise loading with QResource will crash
m_root = new RCCFileInfo(QString(), QFileInfo(),
- QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory);
}
}
@@ -731,7 +731,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file)
return false;
}
if (!m_root)
- m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory);
RCCFileInfo *parent = m_root;
const QStringList nodes = alias.split(QLatin1Char('/'));
@@ -740,7 +740,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file)
if (node.isEmpty())
continue;
if (!parent->m_children.contains(node)) {
- RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory);
s->m_parent = parent;
parent->m_children.insert(node, s);
parent = s;
@@ -756,7 +756,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file)
auto cend = parent->m_children.constEnd();
for (auto it = cbegin; it != cend; ++it) {
if (it.key() == filename && it.value()->m_language == s->m_language &&
- it.value()->m_country == s->m_country) {
+ it.value()->m_territory == s->m_territory) {
for (const QString &name : qAsConst(m_fileNames)) {
qWarning("%s: Warning: potential duplicate alias detected: '%s'",
qPrintable(name), qPrintable(filename));
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 83aa5b2c19..3700304772 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -225,15 +225,15 @@ void tst_QLocale::ctor()
{
QLocale default_locale = QLocale::system();
QLocale::Language default_lang = default_locale.language();
- QLocale::Country default_country = default_locale.country();
+ QLocale::Territory default_country = default_locale.territory();
qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(),
- QLocale::countryToString(default_country).toLatin1().constData());
+ QLocale::territoryToString(default_country).toLatin1().constData());
{
QLocale l;
QVERIFY(l.language() == default_lang);
- QVERIFY(l.country() == default_country);
+ QVERIFY(l.territory() == default_country);
}
#define TEST_CTOR(req_lang, req_script, req_country, exp_lang, exp_script, exp_country) \
@@ -241,7 +241,7 @@ void tst_QLocale::ctor()
QLocale l(QLocale::req_lang, QLocale::req_script, QLocale::req_country); \
QCOMPARE(l.language(), QLocale::exp_lang); \
QCOMPARE(l.script(), QLocale::exp_script); \
- QCOMPARE(l.country(), QLocale::exp_country); \
+ QCOMPARE(l.territory(), QLocale::exp_country); \
} while (false)
// Exact matches
@@ -252,10 +252,10 @@ void tst_QLocale::ctor()
TEST_CTOR(Chinese, TraditionalHanScript, HongKong,
Chinese, TraditionalHanScript, HongKong);
- // Best match for AnyCountry
- TEST_CTOR(Chinese, SimplifiedHanScript, AnyCountry,
+ // Best match for AnyTerritory
+ TEST_CTOR(Chinese, SimplifiedHanScript, AnyTerritory,
Chinese, SimplifiedHanScript, China);
- TEST_CTOR(Chinese, TraditionalHanScript, AnyCountry,
+ TEST_CTOR(Chinese, TraditionalHanScript, AnyTerritory,
Chinese, TraditionalHanScript, Taiwan);
// Best match for AnyScript (and change country to supported one, if necessary)
@@ -295,36 +295,36 @@ void tst_QLocale::defaulted_ctor()
{
QLocale default_locale = QLocale::system();
QLocale::Language default_lang = default_locale.language();
- QLocale::Country default_country = default_locale.country();
+ QLocale::Territory default_country = default_locale.territory();
qDebug("Default: %s/%s", QLocale::languageToString(default_lang).toLatin1().constData(),
- QLocale::countryToString(default_country).toLatin1().constData());
+ QLocale::territoryToString(default_country).toLatin1().constData());
{
- QLocale l(QLocale::C, QLocale::AnyCountry);
+ QLocale l(QLocale::C, QLocale::AnyTerritory);
QCOMPARE(l.language(), QLocale::C);
- QCOMPARE(l.country(), QLocale::AnyCountry);
+ QCOMPARE(l.territory(), QLocale::AnyTerritory);
}
#define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \
{ \
QLocale l(QLocale::req_lang, QLocale::req_country); \
QCOMPARE((int)l.language(), (int)exp_lang); \
- QCOMPARE((int)l.country(), (int)exp_country); \
+ QCOMPARE((int)l.territory(), (int)exp_country); \
}
- TEST_CTOR(AnyLanguage, AnyCountry, default_lang, default_country)
- TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(Aymara, AnyCountry, default_lang, default_country)
+ TEST_CTOR(AnyLanguage, AnyTerritory, default_lang, default_country)
+ TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(Aymara, AnyTerritory, default_lang, default_country)
TEST_CTOR(Aymara, France, default_lang, default_country)
- TEST_CTOR(English, AnyCountry, QLocale::English, QLocale::UnitedStates)
+ TEST_CTOR(English, AnyTerritory, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedStates, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, France, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(French, France, QLocale::French, QLocale::France)
- TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry)
+ TEST_CTOR(C, France, QLocale::C, QLocale::AnyTerritory)
TEST_CTOR(Spanish, LatinAmerica, QLocale::Spanish,
QLocale::LatinAmerica)
@@ -333,94 +333,94 @@ void tst_QLocale::defaulted_ctor()
{
QLocale l;
QVERIFY(l.language() == QLocale::English);
- QVERIFY(l.country() == QLocale::UnitedStates);
+ QVERIFY(l.territory() == QLocale::UnitedStates);
}
TEST_CTOR(French, France, QLocale::French, QLocale::France)
TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(French, France, QLocale::French, QLocale::France)
- TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedStates)
+ TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(C, France, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(Aymara, AnyTerritory, QLocale::English, QLocale::UnitedStates)
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
{
QLocale l;
QVERIFY(l.language() == QLocale::English);
- QVERIFY(l.country() == QLocale::UnitedKingdom);
+ QVERIFY(l.territory() == QLocale::UnitedKingdom);
}
TEST_CTOR(French, France, QLocale::French, QLocale::France)
TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom)
- TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry)
+ TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(C, France, QLocale::C, QLocale::AnyTerritory)
QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::France));
{
QLocale l;
QVERIFY(l.language() == QLocale::English);
- QVERIFY(l.country() == QLocale::UnitedKingdom);
+ QVERIFY(l.territory() == QLocale::UnitedKingdom);
}
- TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom)
+ TEST_CTOR(Aymara, AnyTerritory, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom)
- TEST_CTOR(English, AnyCountry, QLocale::English, QLocale::UnitedStates)
+ TEST_CTOR(English, AnyTerritory, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedStates, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, France, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(French, France, QLocale::French, QLocale::France)
- TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry)
+ TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(C, France, QLocale::C, QLocale::AnyTerritory)
- QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::AnyCountry));
+ QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::AnyTerritory));
{
QLocale l;
QVERIFY(l.language() == QLocale::English);
- QVERIFY(l.country() == QLocale::UnitedKingdom);
+ QVERIFY(l.territory() == QLocale::UnitedKingdom);
}
- TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom)
+ TEST_CTOR(Aymara, AnyTerritory, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom)
- TEST_CTOR(English, AnyCountry, QLocale::English, QLocale::UnitedStates)
+ TEST_CTOR(English, AnyTerritory, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedStates, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, France, QLocale::English, QLocale::UnitedStates)
TEST_CTOR(English, UnitedKingdom, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(French, France, QLocale::French, QLocale::France)
- TEST_CTOR(C, AnyCountry, QLocale::C, QLocale::AnyCountry)
- TEST_CTOR(C, France, QLocale::C, QLocale::AnyCountry)
-
- TEST_CTOR(Arabic, AnyCountry, QLocale::Arabic, QLocale::Egypt)
- TEST_CTOR(Dutch, AnyCountry, QLocale::Dutch, QLocale::Netherlands)
- TEST_CTOR(German, AnyCountry, QLocale::German, QLocale::Germany)
- TEST_CTOR(Greek, AnyCountry, QLocale::Greek, QLocale::Greece)
- TEST_CTOR(Malay, AnyCountry, QLocale::Malay, QLocale::Malaysia)
- TEST_CTOR(Persian, AnyCountry, QLocale::Persian, QLocale::Iran)
- TEST_CTOR(Portuguese, AnyCountry, QLocale::Portuguese, QLocale::Brazil)
- TEST_CTOR(Serbian, AnyCountry, QLocale::Serbian, QLocale::Serbia)
- TEST_CTOR(Somali, AnyCountry, QLocale::Somali, QLocale::Somalia)
- TEST_CTOR(Spanish, AnyCountry, QLocale::Spanish, QLocale::Spain)
- TEST_CTOR(Swedish, AnyCountry, QLocale::Swedish, QLocale::Sweden)
- TEST_CTOR(Uzbek, AnyCountry, QLocale::Uzbek, QLocale::Uzbekistan)
+ TEST_CTOR(C, AnyTerritory, QLocale::C, QLocale::AnyTerritory)
+ TEST_CTOR(C, France, QLocale::C, QLocale::AnyTerritory)
+
+ TEST_CTOR(Arabic, AnyTerritory, QLocale::Arabic, QLocale::Egypt)
+ TEST_CTOR(Dutch, AnyTerritory, QLocale::Dutch, QLocale::Netherlands)
+ TEST_CTOR(German, AnyTerritory, QLocale::German, QLocale::Germany)
+ TEST_CTOR(Greek, AnyTerritory, QLocale::Greek, QLocale::Greece)
+ TEST_CTOR(Malay, AnyTerritory, QLocale::Malay, QLocale::Malaysia)
+ TEST_CTOR(Persian, AnyTerritory, QLocale::Persian, QLocale::Iran)
+ TEST_CTOR(Portuguese, AnyTerritory, QLocale::Portuguese, QLocale::Brazil)
+ TEST_CTOR(Serbian, AnyTerritory, QLocale::Serbian, QLocale::Serbia)
+ TEST_CTOR(Somali, AnyTerritory, QLocale::Somali, QLocale::Somalia)
+ TEST_CTOR(Spanish, AnyTerritory, QLocale::Spanish, QLocale::Spain)
+ TEST_CTOR(Swedish, AnyTerritory, QLocale::Swedish, QLocale::Sweden)
+ TEST_CTOR(Uzbek, AnyTerritory, QLocale::Uzbek, QLocale::Uzbekistan)
#undef TEST_CTOR
#define TEST_CTOR(req_lc, exp_lang, exp_country) \
{ \
QLocale l(req_lc); \
QVERIFY2(l.language() == QLocale::exp_lang \
- && l.country() == QLocale::exp_country, \
+ && l.territory() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ QLatin1Char('/') \
- + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ + QLocale::territoryToString(l.territory())).toLatin1().constData()); \
QCOMPARE(l, QLocale(QLocale::exp_lang, QLocale::exp_country)); \
QCOMPARE(qHash(l), qHash(QLocale(QLocale::exp_lang, QLocale::exp_country))); \
}
@@ -428,14 +428,14 @@ void tst_QLocale::defaulted_ctor()
QLocale::setDefault(QLocale(QLocale::C));
const QString empty;
- TEST_CTOR("C", C, AnyCountry)
- TEST_CTOR("bla", C, AnyCountry)
- TEST_CTOR("zz", C, AnyCountry)
- TEST_CTOR("zz_zz", C, AnyCountry)
- TEST_CTOR("zz...", C, AnyCountry)
- TEST_CTOR("", C, AnyCountry)
- TEST_CTOR("en/", C, AnyCountry)
- TEST_CTOR(empty, C, AnyCountry)
+ TEST_CTOR("C", C, AnyTerritory)
+ TEST_CTOR("bla", C, AnyTerritory)
+ TEST_CTOR("zz", C, AnyTerritory)
+ TEST_CTOR("zz_zz", C, AnyTerritory)
+ TEST_CTOR("zz...", C, AnyTerritory)
+ TEST_CTOR("", C, AnyTerritory)
+ TEST_CTOR("en/", C, AnyTerritory)
+ TEST_CTOR(empty, C, AnyTerritory)
TEST_CTOR("en", English, UnitedStates)
TEST_CTOR("en", English, UnitedStates)
TEST_CTOR("en.", English, UnitedStates)
@@ -480,11 +480,11 @@ void tst_QLocale::defaulted_ctor()
QLocale l(req_lc); \
QVERIFY2(l.language() == QLocale::exp_lang \
&& l.script() == QLocale::exp_script \
- && l.country() == QLocale::exp_country, \
+ && l.territory() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ QLatin1Char('/') + QLocale::scriptToString(l.script()) \
- + QLatin1Char('/') + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ + QLatin1Char('/') + QLocale::territoryToString(l.territory())).toLatin1().constData()); \
}
TEST_CTOR("zh_CN", Chinese, SimplifiedHanScript, China)
@@ -664,11 +664,11 @@ void tst_QLocale::legacyNames()
{ \
QLocale l(req_lc); \
QVERIFY2(l.language() == QLocale::exp_lang \
- && l.country() == QLocale::exp_country, \
+ && l.territory() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \
+ QLatin1Char('/') \
- + QLocale::countryToString(l.country())).toLatin1().constData()); \
+ + QLocale::territoryToString(l.territory())).toLatin1().constData()); \
}
TEST_CTOR("mo_MD", Romanian, Moldova)
@@ -684,9 +684,9 @@ void tst_QLocale::consistentC()
{
const QLocale c(QLocale::C);
QCOMPARE(c, QLocale::c());
- QCOMPARE(c, QLocale(QLocale::C, QLocale::AnyScript, QLocale::AnyCountry));
+ QCOMPARE(c, QLocale(QLocale::C, QLocale::AnyScript, QLocale::AnyTerritory));
QVERIFY(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
- QLocale::AnyCountry).contains(c));
+ QLocale::AnyTerritory).contains(c));
}
void tst_QLocale::matchingLocales()
@@ -694,7 +694,7 @@ void tst_QLocale::matchingLocales()
const QLocale c(QLocale::C);
const QLocale ru_RU(QLocale::Russian, QLocale::Russia);
- QList<QLocale> locales = QLocale::matchingLocales(QLocale::C, QLocale::AnyScript, QLocale::AnyCountry);
+ QList<QLocale> locales = QLocale::matchingLocales(QLocale::C, QLocale::AnyScript, QLocale::AnyTerritory);
QCOMPARE(locales.size(), 1);
QVERIFY(locales.contains(c));
@@ -702,12 +702,12 @@ void tst_QLocale::matchingLocales()
QCOMPARE(locales.size(), 1);
QVERIFY(locales.contains(ru_RU));
- locales = QLocale::matchingLocales(QLocale::Russian, QLocale::AnyScript, QLocale::AnyCountry);
+ locales = QLocale::matchingLocales(QLocale::Russian, QLocale::AnyScript, QLocale::AnyTerritory);
QVERIFY(!locales.isEmpty());
QVERIFY(!locales.contains(c));
QVERIFY(locales.contains(ru_RU));
- locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::CyrillicScript, QLocale::AnyCountry);
+ locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::CyrillicScript, QLocale::AnyTerritory);
QVERIFY(!locales.isEmpty());
QVERIFY(!locales.contains(c));
QVERIFY(locales.contains(ru_RU));
@@ -721,14 +721,14 @@ void tst_QLocale::matchingLocales()
void tst_QLocale::unixLocaleName_data()
{
QTest::addColumn<QLocale::Language>("lang");
- QTest::addColumn<QLocale::Country>("land");
+ QTest::addColumn<QLocale::Territory>("land");
QTest::addColumn<QString>("expect");
#define ADDROW(nom, lang, land, name) \
QTest::newRow(nom) << QLocale::lang << QLocale::land << QStringLiteral(name)
- ADDROW("C_any", C, AnyCountry, "C");
- ADDROW("en_any", English, AnyCountry, "en_US");
+ ADDROW("C_any", C, AnyTerritory, "C");
+ ADDROW("en_any", English, AnyTerritory, "en_US");
ADDROW("en_GB", English, UnitedKingdom, "en_GB");
ADDROW("ay_GB", Aymara, UnitedKingdom, "C");
#undef ADDROW
@@ -737,7 +737,7 @@ void tst_QLocale::unixLocaleName_data()
void tst_QLocale::unixLocaleName()
{
QFETCH(QLocale::Language, lang);
- QFETCH(QLocale::Country, land);
+ QFETCH(QLocale::Territory, land);
QFETCH(QString, expect);
QLocale::setDefault(QLocale(QLocale::C));
@@ -1456,17 +1456,17 @@ void tst_QLocale::negativeZero_data()
{
QTest::addColumn<QLocale::Language>("language");
QTest::addColumn<QLocale::Script>("script");
- QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QLocale::Territory>("territory");
QTest::addColumn<QStringView>("expect");
QTest::newRow("C")
- << QLocale::C << QLocale::AnyScript << QLocale::AnyCountry
+ << QLocale::C << QLocale::AnyScript << QLocale::AnyTerritory
<< QStringView(u"0");
QTest::newRow("Arabic")
- << QLocale::Arabic << QLocale::ArabicScript << QLocale::AnyCountry
+ << QLocale::Arabic << QLocale::ArabicScript << QLocale::AnyTerritory
<< QStringView(u"\u0660");
QTest::newRow("Chakma")
- << QLocale::Chakma << QLocale::ChakmaScript << QLocale::AnyCountry
+ << QLocale::Chakma << QLocale::ChakmaScript << QLocale::AnyTerritory
<< QStringView(u"\xD804\xDD36"); // A surrogate pair.
}
@@ -1474,7 +1474,7 @@ void tst_QLocale::negativeZero()
{
QFETCH(QLocale::Language, language);
QFETCH(QLocale::Script, script);
- QFETCH(QLocale::Country, territory);
+ QFETCH(QLocale::Territory, territory);
QFETCH(QStringView, expect);
QLocale locale(language, script, territory);
QCOMPARE(locale.toString(std::copysign(0.0, -1.0)), expect);
@@ -2315,7 +2315,7 @@ static const int locale_data_count = sizeof(locale_data)/sizeof(locale_data[0]);
void tst_QLocale::testNames_data()
{
QTest::addColumn<QLocale::Language>("language");
- QTest::addColumn<QLocale::Country>("country");
+ QTest::addColumn<QLocale::Territory>("country");
QLocale::setDefault(QLocale(QLocale::C)); // Ensures predictable fall-backs
@@ -2324,39 +2324,39 @@ void tst_QLocale::testNames_data()
const QByteArray lang =
QLocale::languageToString(QLocale::Language(item.m_language_id)).toLatin1();
const QByteArray land =
- QLocale::countryToString(QLocale::Country(item.m_country_id)).toLatin1();
+ QLocale::territoryToString(QLocale::Territory(item.m_territory_id)).toLatin1();
QTest::addRow("data_%d (%s/%s)", i, lang.constData(), land.constData())
- << QLocale::Language(item.m_language_id) << QLocale::Country(item.m_country_id);
+ << QLocale::Language(item.m_language_id) << QLocale::Territory(item.m_territory_id);
}
}
void tst_QLocale::testNames()
{
QFETCH(QLocale::Language, language);
- QFETCH(const QLocale::Country, country);
+ QFETCH(const QLocale::Territory, country);
const QLocale l1(language, country);
- if (language == QLocale::AnyLanguage && country == QLocale::AnyCountry)
+ if (language == QLocale::AnyLanguage && country == QLocale::AnyTerritory)
language = QLocale::C;
QCOMPARE(l1.language(), language);
- QCOMPARE(l1.country(), country);
+ QCOMPARE(l1.territory(), country);
const QString name = l1.name();
const QLocale l2(name);
QCOMPARE(l2.language(), language);
- QCOMPARE(l2.country(), country);
+ QCOMPARE(l2.territory(), country);
QCOMPARE(l2.name(), name);
const QLocale l3(name + QLatin1String("@foo"));
QCOMPARE(l3.language(), language);
- QCOMPARE(l3.country(), country);
+ QCOMPARE(l3.territory(), country);
QCOMPARE(l3.name(), name);
const QLocale l4(name + QLatin1String(".foo"));
QCOMPARE(l4.language(), language);
- QCOMPARE(l4.country(), country);
+ QCOMPARE(l4.territory(), country);
QCOMPARE(l4.name(), name);
if (language != QLocale::C) {
@@ -2915,7 +2915,7 @@ void tst_QLocale::textDirection()
QFETCH(int, script);
QFETCH(bool, rightToLeft);
- QLocale locale(QLocale::Language(language), QLocale::Script(script), QLocale::AnyCountry);
+ QLocale locale(QLocale::Language(language), QLocale::Script(script), QLocale::AnyTerritory);
QCOMPARE(locale.textDirection() == Qt::RightToLeft, rightToLeft);
}
@@ -3243,9 +3243,9 @@ void tst_QLocale::lcsToCode()
QCOMPARE(QLocale::languageToCode(QLocale::C), QString("C"));
QCOMPARE(QLocale::languageToCode(QLocale::English), QString("en"));
- QCOMPARE(QLocale::countryToCode(QLocale::AnyCountry), QString());
- QCOMPARE(QLocale::countryToCode(QLocale::UnitedStates), QString("US"));
- QCOMPARE(QLocale::countryToCode(QLocale::EuropeanUnion), QString("EU"));
+ QCOMPARE(QLocale::territoryToCode(QLocale::AnyTerritory), QString());
+ QCOMPARE(QLocale::territoryToCode(QLocale::UnitedStates), QString("US"));
+ QCOMPARE(QLocale::territoryToCode(QLocale::EuropeanUnion), QString("EU"));
QCOMPARE(QLocale::scriptToCode(QLocale::AnyScript), QString());
QCOMPARE(QLocale::scriptToCode(QLocale::SimplifiedHanScript), QString("Hans"));
@@ -3263,14 +3263,14 @@ void tst_QLocale::codeToLcs()
QCOMPARE(QLocale::codeToLanguage(QString("ha")), QLocale::Hausa);
QCOMPARE(QLocale::codeToLanguage(QString("haw")), QLocale::Hawaiian);
- QCOMPARE(QLocale::codeToCountry(QString()), QLocale::AnyCountry);
- QCOMPARE(QLocale::codeToCountry(QString("ZZ")), QLocale::AnyCountry);
- QCOMPARE(QLocale::codeToCountry(QString("US")), QLocale::UnitedStates);
- QCOMPARE(QLocale::codeToCountry(QString("us")), QLocale::UnitedStates);
- QCOMPARE(QLocale::codeToCountry(QString("USA")), QLocale::AnyCountry);
- QCOMPARE(QLocale::codeToCountry(QString("EU")), QLocale::EuropeanUnion);
- QCOMPARE(QLocale::codeToCountry(QString("001")), QLocale::World);
- QCOMPARE(QLocale::codeToCountry(QString("150")), QLocale::Europe);
+ QCOMPARE(QLocale::codeToTerritory(QString()), QLocale::AnyTerritory);
+ QCOMPARE(QLocale::codeToTerritory(QString("ZZ")), QLocale::AnyTerritory);
+ QCOMPARE(QLocale::codeToTerritory(QString("US")), QLocale::UnitedStates);
+ QCOMPARE(QLocale::codeToTerritory(QString("us")), QLocale::UnitedStates);
+ QCOMPARE(QLocale::codeToTerritory(QString("USA")), QLocale::AnyTerritory);
+ QCOMPARE(QLocale::codeToTerritory(QString("EU")), QLocale::EuropeanUnion);
+ QCOMPARE(QLocale::codeToTerritory(QString("001")), QLocale::World);
+ QCOMPARE(QLocale::codeToTerritory(QString("150")), QLocale::Europe);
QCOMPARE(QLocale::codeToScript(QString()), QLocale::AnyScript);
QCOMPARE(QLocale::codeToScript(QString("Zzzz")), QLocale::AnyScript);
diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
index 5e272f2400..92676108e0 100644
--- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
@@ -103,7 +103,7 @@ void tst_QTimeZone::printTimeZone(const QTimeZone &tz)
qDebug() << "Is Valid = " << tz.isValid();
qDebug() << "";
qDebug() << "Zone ID = " << tz.id();
- qDebug() << "Country = " << QLocale::countryToString(tz.country());
+ qDebug() << "Territory = " << QLocale::territoryToString(tz.territory());
qDebug() << "Comment = " << tz.comment();
qDebug() << "";
qDebug() << "Locale = " << QLocale().name();
@@ -178,7 +178,7 @@ void tst_QTimeZone::createTest()
QCOMPARE((tz == other), false);
QCOMPARE((tz != other), true);
- QCOMPARE(tz.country(), QLocale::NewZealand);
+ QCOMPARE(tz.territory(), QLocale::NewZealand);
QDateTime jan = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC);
QDateTime jun = QDateTime(QDate(2012, 6, 1), QTime(0, 0, 0), Qt::UTC);
@@ -275,7 +275,7 @@ void tst_QTimeZone::nullTest()
QCOMPARE(utc.isValid(), false);
QCOMPARE(nullTz1.id(), QByteArray());
- QCOMPARE(nullTz1.country(), QLocale::AnyCountry);
+ QCOMPARE(nullTz1.territory(), QLocale::AnyTerritory);
QCOMPARE(nullTz1.comment(), QString());
QDateTime jan = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC);
@@ -359,7 +359,7 @@ void tst_QTimeZone::dataStreamTest()
}
QCOMPARE(tz2.id(), QByteArray("QST"));
QCOMPARE(tz2.comment(), QString("Qt Testing"));
- QCOMPARE(tz2.country(), QLocale::Norway);
+ QCOMPARE(tz2.territory(), QLocale::Norway);
QCOMPARE(tz2.abbreviation(QDateTime::currentDateTime()), QString("QST"));
QCOMPARE(tz2.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()),
QString("Qt Standard Time"));
@@ -642,7 +642,7 @@ void tst_QTimeZone::transitionEachZone()
if (here * 1000 != stamp) {
// (The +1 is due to using _1_:30 as baseSecs.)
qDebug("Failing at half past %d UTC (offset %d in %s)", i + 1, when.offsetFromUtc(),
- QLocale::countryToString(named.country()).toUtf8().constData());
+ QLocale::territoryToString(named.territory()).toUtf8().constData());
}
QCOMPARE(stamp % 1000, 0);
QCOMPARE(here - stamp / 1000, 0);
@@ -732,7 +732,7 @@ void tst_QTimeZone::stressTest()
QCOMPARE(testZone.isValid(), true);
QCOMPARE(testZone.id(), id);
QDateTime testDate = QDateTime(QDate(2015, 1, 1), QTime(0, 0, 0), Qt::UTC);
- testZone.country();
+ testZone.territory();
testZone.comment();
testZone.displayName(testDate);
testZone.displayName(QTimeZone::DaylightTime);
@@ -783,7 +783,7 @@ void tst_QTimeZone::windowsId()
USA "America/Chicago America/Indiana/Knox America/Indiana/Tell_City America/Menominee"
"America/North_Dakota/Beulah America/North_Dakota/Center"
"America/North_Dakota/New_Salem"
- AnyCountry "CST6CDT"
+ AnyTerritory "CST6CDT"
*/
QCOMPARE(QTimeZone::ianaIdToWindowsId("America/Chicago"),
QByteArray("Central Standard Time"));
@@ -800,7 +800,7 @@ void tst_QTimeZone::windowsId()
QByteArray("America/Chicago"));
QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::Canada),
QByteArray("America/Winnipeg"));
- QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::AnyCountry),
+ QCOMPARE(QTimeZone::windowsIdToDefaultIanaId("Central Standard Time", QLocale::AnyTerritory),
QByteArray("CST6CDT"));
QCOMPARE(QTimeZone::windowsIdToDefaultIanaId(QByteArray()), QByteArray());
@@ -837,13 +837,13 @@ void tst_QTimeZone::windowsId()
list.clear();
list << "CST6CDT";
- QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyCountry),
+ QCOMPARE(QTimeZone::windowsIdToIanaIds("Central Standard Time", QLocale::AnyTerritory),
list);
// Check no windowsId return empty
list.clear();
QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray()), list);
- QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyCountry), list);
+ QCOMPARE(QTimeZone::windowsIdToIanaIds(QByteArray(), QLocale::AnyTerritory), list);
}
void tst_QTimeZone::isValidId_data()
@@ -1009,7 +1009,7 @@ void tst_QTimeZone::utcTest()
QUtcTimeZonePrivate tzp;
QCOMPARE(tzp.isValid(), true);
QCOMPARE(tzp.id(), QByteArray("UTC"));
- QCOMPARE(tzp.country(), QLocale::AnyCountry);
+ QCOMPARE(tzp.territory(), QLocale::AnyTerritory);
QCOMPARE(tzp.abbreviation(0), QString("UTC"));
QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()), QString("UTC"));
QCOMPARE(tzp.offsetFromUtc(0), 0);
@@ -1050,7 +1050,7 @@ void tst_QTimeZone::utcTest()
QCOMPARE(tz.isValid(), true);
QCOMPARE(tz.id(), QByteArray("QST"));
QCOMPARE(tz.comment(), QString("Qt Testing"));
- QCOMPARE(tz.country(), QLocale::Norway);
+ QCOMPARE(tz.territory(), QLocale::Norway);
QCOMPARE(tz.abbreviation(now), QString("QST"));
QCOMPARE(tz.displayName(QTimeZone::StandardTime, QTimeZone::LongName, QLocale()),
QString("Qt Standard Time"));
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index f9572b85e3..ffe171d5f0 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -430,7 +430,7 @@ void tst_QDateTimeEdit::initTestCase()
if (system.language() != QLocale::C && system.language() != QLocale::English)
qWarning("Running under locale %s/%s -- this test may generate failures due to language differences",
qPrintable(QLocale::languageToString(system.language())),
- qPrintable(QLocale::countryToString(system.country())));
+ qPrintable(QLocale::territoryToString(system.territory())));
testWidget = new EditorDateEdit(0);
testFocusWidget = new QWidget(0);
testFocusWidget->resize(200, 100);
@@ -3881,7 +3881,7 @@ void tst_QDateTimeEdit::setLocaleOnCalendarWidget()
QList<QLocale> allLocales = QLocale::matchingLocales(
QLocale::AnyLanguage,
QLocale::AnyScript,
- QLocale::AnyCountry);
+ QLocale::AnyTerritory);
QLocale c = QLocale::c();
dateEdit.setCalendarPopup(true);
dateEdit.setLocale(c);
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
index 09fc8343b5..a3f4f353d1 100644
--- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -1208,7 +1208,7 @@ void tst_QDoubleSpinBox::taskQTBUG_6496_fiddlingWithPrecision()
void tst_QDoubleSpinBox::setGroupSeparatorShown_data()
{
QTest::addColumn<QLocale::Language>("lang");
- QTest::addColumn<QLocale::Country>("country");
+ QTest::addColumn<QLocale::Territory>("country");
QTest::newRow("data0") << QLocale::English << QLocale::UnitedStates;
QTest::newRow("data1") << QLocale::Swedish << QLocale::Sweden;
@@ -1220,7 +1220,7 @@ void tst_QDoubleSpinBox::setGroupSeparatorShown_data()
void tst_QDoubleSpinBox::setGroupSeparatorShown()
{
QFETCH(QLocale::Language, lang);
- QFETCH(QLocale::Country, country);
+ QFETCH(QLocale::Territory, country);
QLocale loc(lang, country);
QLocale::setDefault(loc);
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
index 724eff608f..c877454440 100644
--- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -1310,7 +1310,7 @@ void tst_QSpinBox::interpretOnLosingFocus()
void tst_QSpinBox::setGroupSeparatorShown_data()
{
QTest::addColumn<QLocale::Language>("lang");
- QTest::addColumn<QLocale::Country>("country");
+ QTest::addColumn<QLocale::Territory>("country");
QTest::newRow("data0") << QLocale::English << QLocale::UnitedStates;
QTest::newRow("data1") << QLocale::Swedish << QLocale::Sweden;
@@ -1322,7 +1322,7 @@ void tst_QSpinBox::setGroupSeparatorShown_data()
void tst_QSpinBox::setGroupSeparatorShown()
{
QFETCH(QLocale::Language, lang);
- QFETCH(QLocale::Country, country);
+ QFETCH(QLocale::Territory, country);
QLocale loc(lang, country);
QLocale::setDefault(loc);
diff --git a/tests/benchmarks/corelib/text/qlocale/main.cpp b/tests/benchmarks/corelib/text/qlocale/main.cpp
index 0ddaa33110..887053ae4a 100644
--- a/tests/benchmarks/corelib/text/qlocale/main.cpp
+++ b/tests/benchmarks/corelib/text/qlocale/main.cpp
@@ -111,11 +111,11 @@ void tst_QLocale::fromTags_data()
{
QTest::addColumn<QLocale::Language>("language");
QTest::addColumn<QLocale::Script>("script");
- QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QLocale::Territory>("territory");
#define ROW(name, lang, text, land) \
QTest::newRow(name) << QLocale::lang << QLocale::text << QLocale::land
- ROW("C", C, AnyScript, AnyCountry);
+ ROW("C", C, AnyScript, AnyTerritory);
ROW("en-Latn-DE", English, LatinScript, Germany);
ROW("sd-Deva-IN", Sindhi, DevanagariScript, India);
ROW("az-Cyrl-AZ", Azerbaijani, CyrillicScript, Azerbaijan);
@@ -151,7 +151,7 @@ void tst_QLocale::fromTags()
{
QFETCH(const QLocale::Language, language);
QFETCH(const QLocale::Script, script);
- QFETCH(const QLocale::Country, territory);
+ QFETCH(const QLocale::Territory, territory);
QBENCHMARK { LOOP(QLocale loc(language, script, territory)) }
}
@@ -192,17 +192,17 @@ void tst_QLocale::fromLangScript()
{
QFETCH(const QLocale::Language, language);
QFETCH(const QLocale::Script, script);
- QBENCHMARK { LOOP(QLocale loc(language, script, QLocale::AnyCountry)) }
+ QBENCHMARK { LOOP(QLocale loc(language, script, QLocale::AnyTerritory)) }
}
void tst_QLocale::fromLangLand_data()
{
QTest::addColumn<QLocale::Language>("language");
- QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QLocale::Territory>("territory");
#define ROW(name, lang, land) \
QTest::newRow(name) << QLocale::lang << QLocale::land
- ROW("C", C, AnyCountry);
+ ROW("C", C, AnyTerritory);
ROW("en-DE", English, Germany);
ROW("sd-IN", Sindhi, India);
ROW("az-AZ", Azerbaijani, Azerbaijan);
@@ -230,18 +230,18 @@ void tst_QLocale::fromLangLand_data()
void tst_QLocale::fromLangLand()
{
QFETCH(const QLocale::Language, language);
- QFETCH(const QLocale::Country, territory);
+ QFETCH(const QLocale::Territory, territory);
QBENCHMARK { LOOP(QLocale loc(language, territory)) }
}
void tst_QLocale::fromScriptLand_data()
{
QTest::addColumn<QLocale::Script>("script");
- QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QLocale::Territory>("territory");
#define ROW(name, text, land) \
QTest::newRow(name) << QLocale::text << QLocale::land
- ROW("Any", AnyScript, AnyCountry);
+ ROW("Any", AnyScript, AnyTerritory);
ROW("Latn-DE", LatinScript, Germany);
ROW("Deva-IN", DevanagariScript, India);
ROW("Cyrl-AZ", CyrillicScript, Azerbaijan);
@@ -276,7 +276,7 @@ void tst_QLocale::fromScriptLand_data()
void tst_QLocale::fromScriptLand()
{
QFETCH(const QLocale::Script, script);
- QFETCH(const QLocale::Country, territory);
+ QFETCH(const QLocale::Territory, territory);
QBENCHMARK { LOOP(QLocale loc(QLocale::AnyLanguage, script, territory)) }
}
@@ -330,16 +330,16 @@ void tst_QLocale::fromScript_data()
void tst_QLocale::fromScript()
{
QFETCH(const QLocale::Script, script);
- QBENCHMARK { LOOP(QLocale loc(QLocale::AnyLanguage, script, QLocale::AnyCountry)) }
+ QBENCHMARK { LOOP(QLocale loc(QLocale::AnyLanguage, script, QLocale::AnyTerritory)) }
}
void tst_QLocale::fromLand_data()
{
- QTest::addColumn<QLocale::Country>("territory");
+ QTest::addColumn<QLocale::Territory>("territory");
#define ROW(name, land) \
QTest::newRow(name) << QLocale::land
- ROW("Any", AnyCountry);
+ ROW("Any", AnyTerritory);
ROW("DE", Germany);
ROW("IN", India);
ROW("AZ", Azerbaijan);
@@ -361,7 +361,7 @@ void tst_QLocale::fromLand_data()
void tst_QLocale::fromLand()
{
- QFETCH(const QLocale::Country, territory);
+ QFETCH(const QLocale::Territory, territory);
QBENCHMARK { LOOP(QLocale loc(QLocale::AnyLanguage, territory)) }
}
diff --git a/tests/manual/qlocale/info.cpp b/tests/manual/qlocale/info.cpp
index 4d082577d4..3f23403350 100644
--- a/tests/manual/qlocale/info.cpp
+++ b/tests/manual/qlocale/info.cpp
@@ -53,8 +53,8 @@ InfoWidget::InfoWidget()
languageName = addItem("Language name:");
nativeLanguageName = addItem("Native language name:");
scriptName = addItem("Script name:");
- countryName = addItem("Country name:");
- nativeCountryName = addItem("Native country name:");
+ territoryName = addItem("Territory name:");
+ nativeTerritoryName = addItem("Native territory name:");
}
void InfoWidget::localeChanged(QLocale locale)
@@ -65,8 +65,8 @@ void InfoWidget::localeChanged(QLocale locale)
languageName->setText(QLocale::languageToString(locale.language()));
nativeLanguageName->setText(locale.nativeLanguageName());
scriptName->setText(QLocale::scriptToString(locale.script()));
- countryName->setText(QLocale::countryToString(locale.country()));
- nativeCountryName->setText(locale.nativeCountryName());
+ territoryName->setText(QLocale::territoryToString(locale.territory()));
+ nativeTerritoryName->setText(locale.nativeTerritoryName());
}
void InfoWidget::addItem(const QString &label, QWidget *w)
diff --git a/tests/manual/qlocale/info.h b/tests/manual/qlocale/info.h
index 1003f84c4f..a477afdb55 100644
--- a/tests/manual/qlocale/info.h
+++ b/tests/manual/qlocale/info.h
@@ -55,8 +55,8 @@ private:
QLineEdit *languageName;
QLineEdit *nativeLanguageName;
QLineEdit *scriptName;
- QLineEdit *countryName;
- QLineEdit *nativeCountryName;
+ QLineEdit *territoryName;
+ QLineEdit *nativeTerritoryName;
private slots:
void localeChanged(QLocale locale);
diff --git a/tests/manual/qlocale/languages.cpp b/tests/manual/qlocale/languages.cpp
index 6a750b9f7b..e3bd8a68f2 100644
--- a/tests/manual/qlocale/languages.cpp
+++ b/tests/manual/qlocale/languages.cpp
@@ -53,7 +53,7 @@ void LanguagesWidget::localeChanged(QLocale locale)
QLocale l(lang);
if (l.language() != QLocale::C) {
QString language = QLocale::languageToString(l.language());
- QString country = QLocale::countryToString(l.country());
+ QString country = QLocale::territoryToString(l.territory());
QString tooltip = QString(QLatin1String("%1: %2/%3")).arg(l.name(), language, country);
item->setToolTip(tooltip);
}
diff --git a/tests/manual/qlocale/window.cpp b/tests/manual/qlocale/window.cpp
index 059192492c..b222fcbfd8 100644
--- a/tests/manual/qlocale/window.cpp
+++ b/tests/manual/qlocale/window.cpp
@@ -41,7 +41,7 @@ Window::Window()
localeCombo->addItem("System", QLocale::system());
- QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
+ QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyTerritory);
foreach (const QLocale &locale, locales) {
QString label = QLocale::languageToString(locale.language());
label += QLatin1Char('/');
@@ -49,7 +49,7 @@ Window::Window()
label += QLocale::scriptToString(locale.script());
label += QLatin1Char('/');
}
- label += QLocale::countryToString(locale.country());
+ label += QLocale::territoryToString(locale.territory());
localeCombo->addItem(label, locale);
}
@@ -103,11 +103,11 @@ void Window::systemLocaleChanged()
QLocale l = QLocale::system();
QString lang = QLocale::languageToString(l.language());
QString script = QLocale::scriptToString(l.script());
- QString country = QLocale::countryToString(l.country());
+ QString territory = QLocale::territoryToString(l.territory());
if (l.script() != QLocale::AnyScript)
- localeCombo->setItemText(0, QString("System: %1-%2-%3").arg(lang, script, country));
+ localeCombo->setItemText(0, QString("System: %1-%2-%3").arg(lang, script, territory));
else
- localeCombo->setItemText(0, QString("System: %1-%2").arg(lang, country));
+ localeCombo->setItemText(0, QString("System: %1-%2").arg(lang, territory));
emit localeChanged(0);
}
diff --git a/util/locale_database/cldr.py b/util/locale_database/cldr.py
index f2b6616fce..9b08d8a652 100644
--- a/util/locale_database/cldr.py
+++ b/util/locale_database/cldr.py
@@ -87,7 +87,7 @@ class CldrReader (object):
give = (give[0],
# Substitute according to http://www.unicode.org/reports/tr35/#Likely_Subtags
have[1] if give[1] == 'AnyScript' else give[1],
- have[2] if give[2] == 'AnyCountry' else give[2],
+ have[2] if give[2] == 'AnyTerritory' else give[2],
give[3]) # AnyVariant similarly ?
yield have, give
@@ -676,7 +676,7 @@ enumdata.py (keeping the old name as an alias):
from enumdata import language_list, script_list, country_list
for form, book, empty in (('language', language_list, 'AnyLanguage'),
('script', script_list, 'AnyScript'),
- ('country', country_list, 'AnyCountry')):
+ ('country', country_list, 'AnyTerritory')):
cache[form] = dict((pair[1], (num, pair[0]))
for num, pair in book.items() if pair[0] != 'C')
# (Have to filter out the C locale, as we give it the
diff --git a/util/locale_database/enumdata.py b/util/locale_database/enumdata.py
index ab0f4a3eae..4181e290ac 100644
--- a/util/locale_database/enumdata.py
+++ b/util/locale_database/enumdata.py
@@ -409,7 +409,7 @@ language_aliases = {
}
country_list = {
- 0: ("AnyCountry", "ZZ"),
+ 0: ("AnyTerritory", "ZZ"),
1: ("Afghanistan", "AF"),
2: ("Aland Islands", "AX"),
@@ -700,6 +700,12 @@ country_aliases = {
'UnitedStatesMinorOutlyingIslands': 'UnitedStatesOutlyingIslands',
'CuraSao': 'Curacao',
'CzechRepublic': 'Czechia',
+
+ # Backwards compatibility with old Country enum, prior to Qt 6.2:
+ 'AnyCountry': 'AnyTerritory',
+ 'NauruCountry': 'NauruTerritory',
+ 'TokelauCountry': 'TokelauTerritory',
+ 'TuvaluCountry': 'TuvaluTerritory',
}
script_list = {
diff --git a/util/locale_database/qlocalexml.py b/util/locale_database/qlocalexml.py
index e5aadba995..4fcfe32a43 100644
--- a/util/locale_database/qlocalexml.py
+++ b/util/locale_database/qlocalexml.py
@@ -155,7 +155,7 @@ class QLocaleXmlReader (object):
try:
to = likely[(locale.language, 'AnyScript', locale.country)]
except KeyError:
- to = likely[(locale.language, 'AnyScript', 'AnyCountry')]
+ to = likely[(locale.language, 'AnyScript', 'AnyTerritory')]
except KeyError:
pass
else:
@@ -196,7 +196,7 @@ class QLocaleXmlReader (object):
sub-tags mapping says language's default locale uses the given
script and country."""
for have, give in self.__likely:
- if have[1:] == ('AnyScript', 'AnyCountry') and give[2] != 'AnyCountry':
+ if have[1:] == ('AnyScript', 'AnyTerritory') and give[2] != 'AnyTerritory':
assert have[0] == give[0], (have, give)
yield ((self.__langByName[give[0]][0],
self.__textByName[give[1]][0]),
@@ -590,7 +590,7 @@ class Locale (object):
return cls(cls.__monthNames(calendars),
language='C', language_code='0', languageEndonym='',
script='AnyScript', script_code='0',
- country='AnyCountry', country_code='0', countryEndonym='',
+ country='AnyTerritory', country_code='0', countryEndonym='',
groupSizes=(3, 3, 1),
decimal='.', group=',', list=';', percent='%',
zero='0', minus='-', plus='+', exp='e',
diff --git a/util/locale_database/qlocalexml2cpp.py b/util/locale_database/qlocalexml2cpp.py
index 1483545ce7..c15d6d2f55 100755
--- a/util/locale_database/qlocalexml2cpp.py
+++ b/util/locale_database/qlocalexml2cpp.py
@@ -394,7 +394,7 @@ class LocaleDataWriter (LocaleSourceEditor):
self.__writeNameData(self.writer.write, scripts, 'script')
def countryNames(self, countries):
- self.__writeNameData(self.writer.write, countries, 'country')
+ self.__writeNameData(self.writer.write, countries, 'territory')
# TODO: unify these next three into the previous three; kept
# separate for now to verify we're not changing data.
@@ -406,7 +406,7 @@ class LocaleDataWriter (LocaleSourceEditor):
self.__writeCodeList(self.writer.write, scripts, 'script', 4)
def countryCodes(self, countries): # TODO: unify with countryNames()
- self.__writeCodeList(self.writer.write, countries, 'country', 3)
+ self.__writeCodeList(self.writer.write, countries, 'territory', 3)
class CalendarDataWriter (LocaleSourceEditor):
formatCalendar = (
@@ -469,7 +469,8 @@ class LocaleHeaderWriter (SourceFileEditor):
self.writer.write('\n')
def countries(self, countries):
- self.__enum('Country', countries, self.__country)
+ self.writer.write(" // ### Qt 7: Rename to Territory\n")
+ self.__enum('Country', countries, self.__country, 'Territory')
def scripts(self, scripts):
self.__enum('Script', scripts, self.__script)
@@ -480,8 +481,12 @@ class LocaleHeaderWriter (SourceFileEditor):
country_aliases as __country,
script_aliases as __script)
- def __enum(self, name, book, alias):
+ def __enum(self, name, book, alias, suffix = None):
assert book
+
+ if suffix is None:
+ suffix = name
+
out, dupes = self.writer.write, self.__dupes
out(' enum {} : ushort {{\n'.format(name))
for key, value in book.items():
@@ -495,13 +500,20 @@ class LocaleHeaderWriter (SourceFileEditor):
raise Error('The script name "{}" is messy'.format(member))
else:
member = ''.join(member.split())
- member = member + name if member in dupes else member
+ member = member + suffix if member in dupes else member
out(' {} = {},\n'.format(member, key))
out('\n '
+ ',\n '.join('{} = {}'.format(*pair)
for pair in sorted(alias.items()))
- + ',\n\n Last{} = {}\n }};\n'.format(name, member))
+ + ',\n\n Last{} = {}'.format(suffix, member))
+
+ # for "LastCountry = LastTerritory"
+ # ### Qt 7: Remove
+ if suffix != name:
+ out(',\n Last{} = Last{}'.format(name, suffix))
+
+ out('\n };\n')
def usage(name, err, message = ''):
err.write("""Usage: {} path/to/qlocale.xml root/of/qtbase
diff --git a/util/locale_database/testlocales/localemodel.cpp b/util/locale_database/testlocales/localemodel.cpp
index d380d01e09..d171bc9855 100644
--- a/util/locale_database/testlocales/localemodel.cpp
+++ b/util/locale_database/testlocales/localemodel.cpp
@@ -36,11 +36,11 @@ static const int g_model_cols = 6;
struct LocaleListItem
{
int language;
- int country;
+ int territory;
};
const LocaleListItem g_locale_list[] = {
- { 1, 0 }, // C/AnyCountry
+ { 1, 0 }, // C/AnyTerritory
{ 3, 69 }, // Afan/Ethiopia
{ 3, 111 }, // Afan/Kenya
{ 4, 59 }, // Afar/Djibouti
@@ -317,7 +317,7 @@ QVariant LocaleModel::data(const QModelIndex &index, int role) const
locale = QLocale::system();
} else {
LocaleListItem item = g_locale_list[index.row() - 2];
- locale = QLocale((QLocale::Language)item.language, (QLocale::Country)item.country);
+ locale = QLocale((QLocale::Language)item.language, (QLocale::Territory)item.territory);
}
switch (index.column()) {
@@ -386,7 +386,7 @@ QVariant LocaleModel::headerData(int section, Qt::Orientation orientation, int r
LocaleListItem item = g_locale_list[section - 2];
return QLocale::languageToString((QLocale::Language)item.language)
+ QLatin1Char('/')
- + QLocale::countryToString((QLocale::Country)item.country);
+ + QLocale::territoryToString((QLocale::Territory)item.territory);
}
}
diff --git a/util/xkbdatagen/main.cpp b/util/xkbdatagen/main.cpp
index 4eba2d8a54..d0b96b78d3 100644
--- a/util/xkbdatagen/main.cpp
+++ b/util/xkbdatagen/main.cpp
@@ -450,7 +450,7 @@ int main(int argc, char **argv)
" const char *variant; // 0 means any variant\n"
" Qt::LayoutDirection direction;\n"
" QLocale::Language language;\n"
- " QLocale::Country country;\n"
+ " QLocale::Territory territory;\n"
"} xkbLayoutData[] = {\n");
// contents
@@ -485,7 +485,7 @@ int main(int argc, char **argv)
}
// wrapping up
- printf(" { 0, 0, Qt::LeftToRight, QLocale::C, QLocale::AnyCountry }\n"
+ printf(" { 0, 0, Qt::LeftToRight, QLocale::C, QLocale::AnyTerritory }\n"
"};\n");
return 0;