diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-08-31 17:53:15 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-01 17:11:44 +0200 |
commit | 6da648ad836c6d2247ab37f440c0a4368cebc778 (patch) | |
tree | e121076e9c875633df88b1689a80ab31ec8fa708 /src/corelib/text/qlocale.cpp | |
parent | dc65267ad8c086950c23185c8cebc304a8d1c3dc (diff) |
Add a QLocale(QStringView) constructor
Only a few more internals just needed to change to take QStringView,
to connect up the constructor with internals already long since
converted.
[ChangeLog][QtCore][QLocale] Added QLocale(QStringView) constructor.
Change-Id: Iec31391e6168f333b4b6fc633c3d7d01872f83b3
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r-- | src/corelib/text/qlocale.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index bc32dfeaaa..145a2439e5 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -550,7 +550,7 @@ bool qt_splitLocaleName(QStringView name, QStringView *lang, QStringView *script return state != LangState; } -QLocaleId QLocaleId::fromName(const QString &name) +QLocaleId QLocaleId::fromName(QStringView name) { QStringView lang; QStringView script; @@ -786,9 +786,9 @@ QBasicAtomicInt QLocalePrivate::s_generation = Q_BASIC_ATOMIC_INITIALIZER(0); Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QLocalePrivate>, defaultLocalePrivate, (new QLocalePrivate(defaultData(), defaultIndex()))) -static QLocalePrivate *localePrivateByName(const QString &name) +static QLocalePrivate *localePrivateByName(QStringView name) { - if (name == QLatin1String("C")) + if (name == u"C") return c_private(); const int index = QLocaleData::findLocaleIndex(QLocaleId::fromName(name)); Q_ASSERT(index >= 0 && size_t(index) < std::size(locale_data) - 1); @@ -920,9 +920,12 @@ QLocale::QLocale(QLocalePrivate &dd) /*! - Constructs a QLocale object with the specified \a name, - which has the format - "language[_script][_territory][.codeset][@modifier]" or "C", where: + \since 6.3 + + Constructs a QLocale object with the specified \a name. + + The name has the format "language[_script][_territory][.codeset][@modifier]" + or "C", where: \list \li language is a lowercase, two-letter, ISO 639 language code (some @@ -945,19 +948,25 @@ QLocale::QLocale(QLocalePrivate &dd) \sa bcp47Name(), {Matching combinations of language, script and territory} */ - -QLocale::QLocale(const QString &name) +QLocale::QLocale(QStringView name) : d(localePrivateByName(name)) { } +#if QT_STRINGVIEW_LEVEL < 2 +/*! + \fn QLocale::QLocale(const QString &name) + \overload +*/ +#endif + /*! Constructs a QLocale object initialized with the default locale. If no default locale was set using setDefault(), this locale will be the same as the one returned by system(). - \sa setDefault() + \sa setDefault(), system() */ QLocale::QLocale() |