diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-05-22 14:49:30 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-06-11 02:50:16 +0200 |
commit | ecacb3c62f94d2b671a252aa177264f41f6869ea (patch) | |
tree | 9595f19bdeda1009ccf07155d51c2eaff679fe54 /src/corelib/text | |
parent | ce8c33e710a9003a1912ab09fc31417b50b7a4b5 (diff) |
Port QLocale::quoteString from QStringRef to QStringView
Task-number: QTBUG-84319
Change-Id: I29726ebfda7a5f51a0a6ee29e905b0b904256c8d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qlocale.cpp | 10 | ||||
-rw-r--r-- | src/corelib/text/qlocale.h | 5 | ||||
-rw-r--r-- | src/corelib/text/qlocale_mac.mm | 4 | ||||
-rw-r--r-- | src/corelib/text/qlocale_p.h | 6 | ||||
-rw-r--r-- | src/corelib/text/qlocale_unix.cpp | 4 |
5 files changed, 14 insertions, 15 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 96b6646c90..a2cf2caec0 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1124,22 +1124,20 @@ QLocale::NumberOptions QLocale::numberOptions() const } /*! + \fn QString QLocale::quoteString(const QString &str, QuotationStyle style) const + \since 4.8 Returns \a str quoted according to the current locale using the given quotation \a style. */ -QString QLocale::quoteString(const QString &str, QuotationStyle style) const -{ - return quoteString(QStringRef(&str), style); -} /*! - \since 4.8 + \since 6.0 \overload */ -QString QLocale::quoteString(const QStringRef &str, QuotationStyle style) const +QString QLocale::quoteString(QStringView str, QuotationStyle style) const { #ifndef QT_NO_SYSTEMLOCALE if (d->m_data == systemData()) { diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index e501a33764..509e19b4ba 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -1120,8 +1120,9 @@ public: NumberOptions numberOptions() const; enum QuotationStyle { StandardQuotation, AlternateQuotation }; - QString quoteString(const QString &str, QuotationStyle style = StandardQuotation) const; - QString quoteString(const QStringRef &str, QuotationStyle style = StandardQuotation) const; + QString quoteString(const QString &str, QuotationStyle style = StandardQuotation) const + { return quoteString(QStringView(str), style); } + QString quoteString(QStringView str, QuotationStyle style = StandardQuotation) const; QString createSeparatedList(const QStringList &strl) const; diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm index b1e067a8c2..95c8769096 100644 --- a/src/corelib/text/qlocale_mac.mm +++ b/src/corelib/text/qlocale_mac.mm @@ -380,7 +380,7 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument & return QString::fromCFString(result); } -static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str) +static QVariant macQuoteString(QSystemLocale::QueryType type, QStringView str) { QString begin, end; QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent(); @@ -494,7 +494,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const } case StringToStandardQuotation: case StringToAlternateQuotation: - return macQuoteString(type, in.value<QStringRef>()); + return macQuoteString(type, in.value<QStringView>()); default: break; } diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index 42d434eac4..751e254d53 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -116,8 +116,8 @@ public: CurrencyToString, // QString in: qlonglong, qulonglong or double Collation, // QString UILanguages, // QStringList - StringToStandardQuotation, // QString in: QStringRef to quote - StringToAlternateQuotation, // QString in: QStringRef to quote + StringToStandardQuotation, // QString in: QStringView to quote + StringToAlternateQuotation, // QString in: QStringView to quote ScriptId, // uint ListToSeparatedString, // QString LocaleChanged, // system locale changed @@ -515,7 +515,7 @@ Q_STATIC_ASSERT(!ascii_isspace(uchar('\377'))); QT_END_NAMESPACE -Q_DECLARE_METATYPE(QStringRef) +Q_DECLARE_METATYPE(QStringView) Q_DECLARE_METATYPE(QList<Qt::DayOfWeek>) #ifndef QT_NO_SYSTEMLOCALE Q_DECLARE_METATYPE(QSystemLocale::CurrencyToStringArgument) diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index 207331b8ac..51b23f1559 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -283,9 +283,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages); } case StringToStandardQuotation: - return lc_messages.quoteString(qvariant_cast<QStringRef>(in)); + return lc_messages.quoteString(qvariant_cast<QStringView>(in)); case StringToAlternateQuotation: - return lc_messages.quoteString(qvariant_cast<QStringRef>(in), QLocale::AlternateQuotation); + return lc_messages.quoteString(qvariant_cast<QStringView>(in), QLocale::AlternateQuotation); case ListToSeparatedString: return lc_messages.createSeparatedList(in.toStringList()); case LocaleChanged: |