QLocale: clean out assorted over-namespacing

The code of a class doesn't need that class's prefix to access members
of the class.

Change-Id: I4cc2f72c90cff48b331dc12d390c45c0639606b3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Edward Welbourne 2023-08-08 17:02:57 +02:00
parent 006fecc824
commit 9c07faed2c
3 changed files with 55 additions and 56 deletions

View File

@ -1070,7 +1070,7 @@ QLocale::QLocale()
*/ */
QLocale::QLocale(Language language, Territory territory) QLocale::QLocale(Language language, Territory territory)
: d(findLocalePrivate(language, QLocale::AnyScript, territory)) : d(findLocalePrivate(language, AnyScript, territory))
{ {
} }
@ -1197,10 +1197,10 @@ QString QLocale::quoteString(QStringView str, QuotationStyle style) const
#ifndef QT_NO_SYSTEMLOCALE #ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == &systemLocaleData) { if (d->m_data == &systemLocaleData) {
QVariant res; QVariant res;
if (style == QLocale::AlternateQuotation) if (style == AlternateQuotation)
res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation, res = systemLocale()->query(QSystemLocale::StringToAlternateQuotation,
QVariant::fromValue(str)); QVariant::fromValue(str));
if (res.isNull() || style == QLocale::StandardQuotation) if (res.isNull() || style == StandardQuotation)
res = systemLocale()->query(QSystemLocale::StringToStandardQuotation, res = systemLocale()->query(QSystemLocale::StringToStandardQuotation,
QVariant::fromValue(str)); QVariant::fromValue(str));
if (!res.isNull()) if (!res.isNull())
@ -1209,7 +1209,7 @@ QString QLocale::quoteString(QStringView str, QuotationStyle style) const
#endif #endif
QLocaleData::DataRange start, end; QLocaleData::DataRange start, end;
if (style == QLocale::StandardQuotation) { if (style == StandardQuotation) {
start = d->m_data->quoteStart(); start = d->m_data->quoteStart();
end = d->m_data->quoteEnd(); end = d->m_data->quoteEnd();
} else { } else {
@ -1566,7 +1566,7 @@ QLocale::Script QLocale::codeToScript(QStringView scriptCode) noexcept
QString QLocale::languageToString(Language language) QString QLocale::languageToString(Language language)
{ {
if (language > QLocale::LastLanguage) if (language > LastLanguage)
return "Unknown"_L1; return "Unknown"_L1;
return QString::fromUtf8(language_name_list + language_name_index[language]); return QString::fromUtf8(language_name_list + language_name_index[language]);
} }
@ -1578,9 +1578,9 @@ QString QLocale::languageToString(Language language)
\sa languageToString(), scriptToString(), territory(), bcp47Name() \sa languageToString(), scriptToString(), territory(), bcp47Name()
*/ */
QString QLocale::territoryToString(QLocale::Territory territory) QString QLocale::territoryToString(Territory territory)
{ {
if (territory > QLocale::LastTerritory) if (territory > LastTerritory)
return "Unknown"_L1; return "Unknown"_L1;
return QString::fromUtf8(territory_name_list + territory_name_index[territory]); return QString::fromUtf8(territory_name_list + territory_name_index[territory]);
} }
@ -1606,9 +1606,9 @@ QString QLocale::countryToString(Country country)
\sa languageToString(), territoryToString(), script(), bcp47Name() \sa languageToString(), territoryToString(), script(), bcp47Name()
*/ */
QString QLocale::scriptToString(QLocale::Script script) QString QLocale::scriptToString(Script script)
{ {
if (script > QLocale::LastScript) if (script > LastScript)
return "Unknown"_L1; return "Unknown"_L1;
return QString::fromUtf8(script_name_list + script_name_index[script]); return QString::fromUtf8(script_name_list + script_name_index[script]);
} }
@ -2795,15 +2795,14 @@ QLocale QLocale::system()
QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
QLocale::Russia); QLocale::Russia);
*/ */
QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Script script, QList<QLocale> QLocale::matchingLocales(Language language, Script script, Territory territory)
QLocale::Territory territory)
{ {
const QLocaleId filter { language, script, territory }; const QLocaleId filter { language, script, territory };
if (!filter.isValid()) if (!filter.isValid())
return QList<QLocale>(); return QList<QLocale>();
if (language == QLocale::C) if (language == C)
return QList<QLocale>() << QLocale(QLocale::C); return QList<QLocale>{QLocale(C)};
QList<QLocale> result; QList<QLocale> result;
if (filter.matchesAll()) if (filter.matchesAll())
@ -2826,7 +2825,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Scr
if (filter.acceptLanguage(syslocaledata->m_language_id)) { if (filter.acceptLanguage(syslocaledata->m_language_id)) {
const QLocaleId id = syslocaledata->id(); const QLocaleId id = syslocaledata->id();
if (filter.acceptScriptTerritory(id)) if (filter.acceptScriptTerritory(id))
result.append(QLocale::system()); result.append(system());
} }
return result; return result;
@ -2846,7 +2845,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language, QLocale::Scr
QList<QLocale::Country> QLocale::countriesForLanguage(Language language) QList<QLocale::Country> QLocale::countriesForLanguage(Language language)
{ {
const auto locales = matchingLocales(language, AnyScript, AnyCountry); const auto locales = matchingLocales(language, AnyScript, AnyCountry);
QList<QLocale::Country> result; QList<Country> result;
result.reserve(locales.size()); result.reserve(locales.size());
for (const auto &locale : locales) for (const auto &locale : locales)
result.append(locale.territory()); result.append(locale.territory());
@ -3240,34 +3239,34 @@ QLocale::MeasurementSystem QLocale::measurementSystem() const
Qt::LayoutDirection QLocale::textDirection() const Qt::LayoutDirection QLocale::textDirection() const
{ {
switch (script()) { switch (script()) {
case QLocale::AdlamScript: case AdlamScript:
case QLocale::ArabicScript: case ArabicScript:
case QLocale::AvestanScript: case AvestanScript:
case QLocale::CypriotScript: case CypriotScript:
case QLocale::HatranScript: case HatranScript:
case QLocale::HebrewScript: case HebrewScript:
case QLocale::ImperialAramaicScript: case ImperialAramaicScript:
case QLocale::InscriptionalPahlaviScript: case InscriptionalPahlaviScript:
case QLocale::InscriptionalParthianScript: case InscriptionalParthianScript:
case QLocale::KharoshthiScript: case KharoshthiScript:
case QLocale::LydianScript: case LydianScript:
case QLocale::MandaeanScript: case MandaeanScript:
case QLocale::ManichaeanScript: case ManichaeanScript:
case QLocale::MendeKikakuiScript: case MendeKikakuiScript:
case QLocale::MeroiticCursiveScript: case MeroiticCursiveScript:
case QLocale::MeroiticScript: case MeroiticScript:
case QLocale::NabataeanScript: case NabataeanScript:
case QLocale::NkoScript: case NkoScript:
case QLocale::OldHungarianScript: case OldHungarianScript:
case QLocale::OldNorthArabianScript: case OldNorthArabianScript:
case QLocale::OldSouthArabianScript: case OldSouthArabianScript:
case QLocale::OrkhonScript: case OrkhonScript:
case QLocale::PalmyreneScript: case PalmyreneScript:
case QLocale::PhoenicianScript: case PhoenicianScript:
case QLocale::PsalterPahlaviScript: case PsalterPahlaviScript:
case QLocale::SamaritanScript: case SamaritanScript:
case QLocale::SyriacScript: case SyriacScript:
case QLocale::ThaanaScript: case ThaanaScript:
return Qt::RightToLeft; return Qt::RightToLeft;
default: default:
break; break;
@ -4421,7 +4420,7 @@ QSimpleParsedNumber<quint64> QLocaleData::bytearrayToUnsLongLong(QByteArrayView
\since 4.8 \since 4.8
Returns a currency symbol according to the \a format. Returns a currency symbol according to the \a format.
*/ */
QString QLocale::currencySymbol(QLocale::CurrencySymbolFormat format) const QString QLocale::currencySymbol(CurrencySymbolFormat format) const
{ {
#ifndef QT_NO_SYSTEMLOCALE #ifndef QT_NO_SYSTEMLOCALE
if (d->m_data == &systemLocaleData) { if (d->m_data == &systemLocaleData) {
@ -4472,7 +4471,7 @@ QString QLocale::toCurrencyString(qlonglong value, const QString &symbol) const
QString str = toString(value); QString str = toString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol; QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty()) if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode); sym = currencySymbol(CurrencyIsoCode);
return range.viewData(currency_format_data).arg(str, sym); return range.viewData(currency_format_data).arg(str, sym);
} }
@ -4494,7 +4493,7 @@ QString QLocale::toCurrencyString(qulonglong value, const QString &symbol) const
QString str = toString(value); QString str = toString(value);
QString sym = symbol.isNull() ? currencySymbol() : symbol; QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty()) if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode); sym = currencySymbol(CurrencyIsoCode);
return d->m_data->currencyFormat().getData(currency_format_data).arg(str, sym); return d->m_data->currencyFormat().getData(currency_format_data).arg(str, sym);
} }
@ -4527,7 +4526,7 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci
QString str = toString(value, 'f', precision == -1 ? d->m_data->m_currency_digits : precision); QString str = toString(value, 'f', precision == -1 ? d->m_data->m_currency_digits : precision);
QString sym = symbol.isNull() ? currencySymbol() : symbol; QString sym = symbol.isNull() ? currencySymbol() : symbol;
if (sym.isEmpty()) if (sym.isEmpty())
sym = currencySymbol(QLocale::CurrencyIsoCode); sym = currencySymbol(CurrencyIsoCode);
return range.viewData(currency_format_data).arg(str, sym); return range.viewData(currency_format_data).arg(str, sym);
} }

View File

@ -639,7 +639,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case CurrencySymbol: case CurrencySymbol:
return macCurrencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); return macCurrencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: case CurrencyToString:
return macFormatCurrency(in.value<QSystemLocale::CurrencyToStringArgument>()); return macFormatCurrency(in.value<CurrencyToStringArgument>());
case UILanguages: { case UILanguages: {
QStringList result; QStringList result;
QCFType<CFArrayRef> languages = CFLocaleCopyPreferredLanguages(); QCFType<CFArrayRef> languages = CFLocaleCopyPreferredLanguages();

View File

@ -187,25 +187,25 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution()
if (substitutionType == SUnknown) { if (substitutionType == SUnknown) {
wchar_t buf[8]; wchar_t buf[8];
if (!getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, buf, 8)) { if (!getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, buf, 8)) {
substitutionType = QSystemLocalePrivate::SNever; substitutionType = SNever;
return substitutionType; return substitutionType;
} }
if (buf[0] == '1') if (buf[0] == '1')
substitutionType = QSystemLocalePrivate::SNever; substitutionType = SNever;
else if (buf[0] == '0') else if (buf[0] == '0')
substitutionType = QSystemLocalePrivate::SContext; substitutionType = SContext;
else if (buf[0] == '2') else if (buf[0] == '2')
substitutionType = QSystemLocalePrivate::SAlways; substitutionType = SAlways;
else { else {
wchar_t digits[11]; // See zeroDigit() for why 11. wchar_t digits[11]; // See zeroDigit() for why 11.
if (!getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) { if (!getLocaleInfo(LOCALE_SNATIVEDIGITS, digits, 11)) {
substitutionType = QSystemLocalePrivate::SNever; substitutionType = SNever;
return substitutionType; return substitutionType;
} }
if (buf[0] == digits[0] + 2) if (buf[0] == digits[0] + 2)
substitutionType = QSystemLocalePrivate::SAlways; substitutionType = SAlways;
else else
substitutionType = QSystemLocalePrivate::SNever; substitutionType = SNever;
} }
} }
return substitutionType; return substitutionType;
@ -869,7 +869,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case CurrencySymbol: case CurrencySymbol:
return d->currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); return d->currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: case CurrencyToString:
return d->toCurrencyString(in.value<QSystemLocale::CurrencyToStringArgument>()); return d->toCurrencyString(in.value<CurrencyToStringArgument>());
case UILanguages: case UILanguages:
return d->uiLanguages(); return d->uiLanguages();
case LocaleChanged: case LocaleChanged: