summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets
diff options
context:
space:
mode:
authorJiDe Zhang <zhangjide@uniontech.com>2021-03-09 16:19:54 +0800
committerJiDe Zhang <zhangjide@uniontech.com>2021-04-15 20:17:49 +0800
commit50a7eb8cf75a2f9cebde6d0d23c108e5e7f1870b (patch)
treec947e4746bb55f723c4005534cb98501f083036a /examples/widgets/widgets
parent7c8d45cb2635ab44d85d85288fd74ef72909264c (diff)
Add the "Territory" enumerated type for QLocale
The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/widgets/widgets')
-rw-r--r--examples/widgets/widgets/calendarwidget/window.cpp11
-rw-r--r--examples/widgets/widgets/validators/localeselector.cpp10
2 files changed, 10 insertions, 11 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;
}