diff options
author | Dmitry Mordvinov <dvvsrd@gmail.com> | 2015-05-07 05:25:07 +0300 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@theqtcompany.com> | 2015-05-08 11:42:02 +0000 |
commit | ff19df37415ead8d26597d861b4d0311ac971c74 (patch) | |
tree | 677388c7d6e8e71fcf8467b1e2bc6e8af5337626 /src/libs/kdtools | |
parent | d74b5e575dfbc3d39f5a2970cc698cc389542116 (diff) |
Implemented xml:lang attribute support for DisplayName tag.
Components in tree view are often need to be localized. Therefore
packages.xml syntax is extended with possibility to specify xml:lang
attribute for DisplayName tag (similarly to Description one).
Test data extended with root component localization.
Added new testcase that changes default locale and checks that
loaded component names correspond to hard-coded ones.
Docs updated with new feature description.
Change-Id: Ic330c3c6684e763eb48a2e99e71784913544e686
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r-- | src/libs/kdtools/kdupdaterupdatesinfo.cpp | 21 | ||||
-rw-r--r-- | src/libs/kdtools/kdupdaterupdatesinfodata_p.h | 3 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/libs/kdtools/kdupdaterupdatesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesinfo.cpp index b46d96943..ffc907923 100644 --- a/src/libs/kdtools/kdupdaterupdatesinfo.cpp +++ b/src/libs/kdtools/kdupdaterupdatesinfo.cpp @@ -140,14 +140,10 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE) info.data.insert(QLatin1String("inheritVersionFrom"), childE.attribute(QLatin1String("inheritVersionFrom"))); info.data[childE.tagName()] = childE.text(); + } else if (childE.tagName() == QLatin1String("DisplayName")) { + processLocalizedTag(childE, info.data); } else if (childE.tagName() == QLatin1String("Description")) { - QString languageAttribute = childE.attribute(QLatin1String("xml:lang")).toLower(); - if (!info.data.contains(QLatin1String("Description")) && (languageAttribute.isEmpty())) - info.data[childE.tagName()] = childE.text(); - - // overwrite default if we have a language specific description - if (languageAttribute == QLocale().name().toLower()) - info.data[childE.tagName()] = childE.text(); + processLocalizedTag(childE, info.data); } else if (childE.tagName() == QLatin1String("UpdateFile")) { info.data[QLatin1String("CompressedSize")] = childE.attribute(QLatin1String("CompressedSize")); info.data[QLatin1String("UncompressedSize")] = childE.attribute(QLatin1String("UncompressedSize")); @@ -173,6 +169,17 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE) return true; } +void UpdatesInfoData::processLocalizedTag(const QDomElement &childE, QHash<QString, QVariant> &info) const +{ + QString languageAttribute = childE.attribute(QLatin1String("xml:lang")).toLower(); + if (!info.contains(childE.tagName()) && (languageAttribute.isEmpty())) + info[childE.tagName()] = childE.text(); + + // overwrite default if we have a language specific description + if (QLocale().name().startsWith(languageAttribute, Qt::CaseInsensitive)) + info[childE.tagName()] = childE.text(); +} + // // UpdatesInfo diff --git a/src/libs/kdtools/kdupdaterupdatesinfodata_p.h b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h index 19e44fa10..786c96f1c 100644 --- a/src/libs/kdtools/kdupdaterupdatesinfodata_p.h +++ b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h @@ -62,6 +62,9 @@ public: bool parsePackageUpdateElement(const QDomElement &updateE); void setInvalidContentError(const QString &detail); + +private: + void processLocalizedTag(const QDomElement &childE, QHash<QString, QVariant> &info) const; }; } // namespace KDUpdater |