diff options
author | JiDe Zhang <zhangjide@uniontech.com> | 2021-03-09 16:19:54 +0800 |
---|---|---|
committer | JiDe Zhang <zhangjide@uniontech.com> | 2021-04-15 20:17:49 +0800 |
commit | 50a7eb8cf75a2f9cebde6d0d23c108e5e7f1870b (patch) | |
tree | c947e4746bb55f723c4005534cb98501f083036a /src/tools | |
parent | 7c8d45cb2635ab44d85d85288fd74ef72909264c (diff) |
Add the "Territory" enumerated type for QLocale
The use of "Country" is misleading as some entries in the enumeration
are not countries (eg, HongKong), for all that most are. The Unicode
Consortium's Common Locale Data Repository (CLDR, from which QLocale's
data is taken) calls these territories, so introduce territory-based
names and prepare to deprecate the country-based ones in due course.
[ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for
its Country enumeration, and associated territory-based names to match
its country-named methods, to better match the usage in relevant
standards. The country-based names shall in due course be deprecated
in favor of the territory-based names.
Fixes: QTBUG-91686
Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/rcc/rcc.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 01c119d544..1825c77b53 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -108,7 +108,7 @@ public: RCCFileInfo(const QString &name = QString(), const QFileInfo &fileInfo = QFileInfo(), QLocale::Language language = QLocale::C, - QLocale::Country country = QLocale::AnyCountry, + QLocale::Territory territory = QLocale::AnyTerritory, uint flags = NoFlags, RCCResourceLibrary::CompressionAlgorithm compressAlgo = CONSTANT_COMPRESSALGO_DEFAULT, int compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT, @@ -126,7 +126,7 @@ public: int m_flags; QString m_name; QLocale::Language m_language; - QLocale::Country m_country; + QLocale::Territory m_territory; QFileInfo m_fileInfo; RCCFileInfo *m_parent; QMultiHash<QString, RCCFileInfo *> m_children; @@ -141,14 +141,14 @@ public: }; RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo, - QLocale::Language language, QLocale::Country country, uint flags, + QLocale::Language language, QLocale::Territory territory, uint flags, RCCResourceLibrary::CompressionAlgorithm compressAlgo, int compressLevel, int compressThreshold, bool noZstd) { m_name = name; m_fileInfo = fileInfo; m_language = language; - m_country = country; + m_territory = territory; m_flags = flags; m_parent = nullptr; m_nameOffset = 0; @@ -184,7 +184,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) lib.writeString(" // "); lib.writeByteArray(resourceName().toLocal8Bit()); lib.writeString(" ["); - lib.writeByteArray(QByteArray::number(m_country)); + lib.writeByteArray(QByteArray::number(m_territory)); lib.writeString("::"); lib.writeByteArray(QByteArray::number(m_language)); lib.writeString("[\n "); @@ -216,7 +216,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib) lib.writeNumber2(m_flags); // locale - lib.writeNumber2(m_country); + lib.writeNumber2(m_territory); lib.writeNumber2(m_language); //data offset @@ -508,7 +508,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QString prefix; QLocale::Language language = QLocale::c().language(); - QLocale::Country country = QLocale::c().country(); + QLocale::Territory territory = QLocale::c().territory(); QString alias; auto compressAlgo = m_compressionAlgo; int compressLevel = m_compressLevel; @@ -531,7 +531,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QXmlStreamAttributes attributes = reader.attributes(); language = QLocale::c().language(); - country = QLocale::c().country(); + territory = QLocale::c().territory(); if (attributes.hasAttribute(m_strings.ATTRIBUTE_LANG)) { QString attribute = attributes.value(m_strings.ATTRIBUTE_LANG).toString(); @@ -539,9 +539,9 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, language = lang.language(); if (2 == attribute.length()) { // Language only - country = QLocale::AnyCountry; + territory = QLocale::AnyTerritory; } else { - country = lang.country(); + territory = lang.territory(); } } @@ -656,7 +656,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QFileInfo child(filePath); const bool arc = addFile(alias + child.fileName(), - RCCFileInfo(child.fileName(), child, language, country, + RCCFileInfo(child.fileName(), child, language, territory, child.isDir() ? RCCFileInfo::Directory : RCCFileInfo::NoFlags, compressAlgo, compressLevel, compressThreshold, @@ -670,7 +670,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, RCCFileInfo(alias.section(slash, -1), file, language, - country, + territory, RCCFileInfo::NoFlags, compressAlgo, compressLevel, @@ -715,7 +715,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (!listMode && m_format == Binary) { // create dummy entry, otherwise loading with QResource will crash m_root = new RCCFileInfo(QString(), QFileInfo(), - QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory); } } @@ -731,7 +731,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) return false; } if (!m_root) - m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory); RCCFileInfo *parent = m_root; const QStringList nodes = alias.split(QLatin1Char('/')); @@ -740,7 +740,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) if (node.isEmpty()) continue; if (!parent->m_children.contains(node)) { - RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); + RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyTerritory, RCCFileInfo::Directory); s->m_parent = parent; parent->m_children.insert(node, s); parent = s; @@ -756,7 +756,7 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) auto cend = parent->m_children.constEnd(); for (auto it = cbegin; it != cend; ++it) { if (it.key() == filename && it.value()->m_language == s->m_language && - it.value()->m_country == s->m_country) { + it.value()->m_territory == s->m_territory) { for (const QString &name : qAsConst(m_fileNames)) { qWarning("%s: Warning: potential duplicate alias detected: '%s'", qPrintable(name), qPrintable(filename)); |