From 869a1c838ec58051f355552435049b58c6fbe354 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 28 Mar 2011 14:53:46 +0200 Subject: Changed the return value of QLocale::matchingLocales(). Instead of returning a QStringList, return the list of QLocale objects that can be used directly. Reviewed-by: axis --- src/corelib/tools/qlocale.cpp | 18 ++++++++++-------- src/corelib/tools/qlocale.h | 2 +- tests/manual/qlocale/window.cpp | 5 ++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 2e838bd..af95a75 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -1815,21 +1815,21 @@ QLocale QLocale::system() /*! \since 4.8 - Returns the list of valid locale names that match the given \a language, \a + Returns a list of valid locale objects that match the given \a language, \a script and \a country. Getting a list of all locales: - QStringList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); */ -QStringList QLocale::matchingLocales(QLocale::Language language, - QLocale::Script script, - QLocale::Country country) +QList QLocale::matchingLocales(QLocale::Language language, + QLocale::Script script, + QLocale::Country country) { if (uint(language) > QLocale::LastLanguage || uint(script) > QLocale::LastScript || uint(country) > QLocale::LastCountry) - return QStringList(); + return QList(); - QStringList result; + QList result; const QLocalePrivate *d = locale_data; if (language == QLocale::AnyLanguage && script == QLocale::AnyScript && country == QLocale::AnyCountry) result.reserve(locale_data_size); @@ -1837,7 +1837,9 @@ QStringList QLocale::matchingLocales(QLocale::Language language, d += locale_index[language]; while ( (d != locale_data + locale_data_size) && (language == QLocale::AnyLanguage || d->m_language_id == uint(language))) { - result.append(d->bcp47Name()); + QLocale locale(QLocale::C); + locale.p.index = localePrivateIndex(d); + result.append(locale); ++d; } return result; diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index ecb608e..4ac7630 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -743,7 +743,7 @@ public: static QLocale c() { return QLocale(C); } static QLocale system(); - static QStringList matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country); + static QList matchingLocales(QLocale::Language language, QLocale::Script script, QLocale::Country country); static QList countriesForLanguage(Language lang); void setNumberOptions(NumberOptions options); diff --git a/tests/manual/qlocale/window.cpp b/tests/manual/qlocale/window.cpp index 89e3ec6..38bbbe4 100644 --- a/tests/manual/qlocale/window.cpp +++ b/tests/manual/qlocale/window.cpp @@ -46,9 +46,8 @@ Window::Window() localeCombo->addItem("System", QLocale::system()); - QStringList locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); - foreach (const QString &name, locales) { - QLocale locale(name); + QList locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + foreach (const QLocale &locale, locales) { QString label = QLocale::languageToString(locale.language()); label += QLatin1Char('/'); if (locale.script() != QLocale::AnyScript) { -- cgit v0.12