diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-04-08 10:11:51 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-04-16 10:23:23 +0200 |
commit | d4242b8af3e6eb5e9f68e5ff2efee97de11da892 (patch) | |
tree | 637a0fd77b774c7980ab26d0e7c04ba639c02ed1 /examples/widgets | |
parent | 530e0bd469e6859269c2d1a792b8ce819fbff389 (diff) |
Revise deprecation of countriesForLanguage()
It was originally marked \obsolete without any comment on what was to
be used to replace it, or deprecation markings in the declaration, so
it got missed at 6.0. More recently it's been deprecated in favor of a
territory-based name; but actually it was obsoleted by (iterating the
territory() of each return from) matchingLocales() in Qt 4.8.
So back out of adding territoriesForLanguage to replace it and,
instead, mark it as deprecated in the declaration, in favor of
matchingLocales(). Also rewrite the implementation to be exactly that
replacement. Rewrote the one example using it.
Fixes: QTBUG-92484
Change-Id: Iedaf30378446dd9adac5128b7ee5fee48aab1636
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/widgets/calendarwidget/window.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index e88e41beb2..38e9798d83 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.cpp @@ -237,6 +237,9 @@ void Window::createPreviewGroupBox() } //! [9] +// TODO: use loc.name() as label (but has underscore in place of slash) +// TODO: use locale() == loc instead of only comparing language and territory +// Needs someone familiar with this example to work out ramifications //! [10] void Window::createGeneralOptionsGroupBox() { @@ -247,15 +250,16 @@ void Window::createGeneralOptionsGroupBox() int index = 0; for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { QLocale::Language lang = static_cast<QLocale::Language>(_lang); - const auto territories = QLocale::territoriesForLanguage(lang); - for (auto territory : territories) { + const auto locales = + QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory); + for (auto loc : locales) { QString label = QLocale::languageToString(lang); + auto territory = loc.territory(); label += QLatin1Char('/'); label += QLocale::territoryToString(territory); - QLocale locale(lang, territory); - if (this->locale().language() == lang && this->locale().territory() == territory) + if (locale().language() == lang && locale().territory() == territory) curLocaleIndex = index; - localeCombo->addItem(label, locale); + localeCombo->addItem(label, loc); ++index; } } |