summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/component.cpp
diff options
context:
space:
mode:
authorJarkko Lehtoranta <jarkko.lehtoranta@jolla.com>2019-03-04 11:52:32 +0200
committerKatja Marttila <katja.marttila@qt.io>2020-11-06 12:00:28 +0200
commitc16baa1128b1abf360e9c925c45f1580115cb5d1 (patch)
tree7c2f6d320a7a7f2ee7cb9cdc8ebcf720b2ad9f0e /src/libs/installer/component.cpp
parentc46a6424b8130583014d61424db7c79bc7ded1c8 (diff)
Arrange licenses and filter duplicates
- Add a "priority" attribute to the "License" element used in "package.xml" for arranging licenses by priority in the LicenseAgreementPage and in CLI. Priority >0 shows the license on top of others. - Arrange the licenses with the same priority alphabetically - Filter duplicate licenses from the LicenseAgreementPage and from CLI Change-Id: I1dcacdd417d2383b8dc18149e4de329fbf11cfe8 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src/libs/installer/component.cpp')
-rw-r--r--src/libs/installer/component.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 5c64d3cf1..e8f036ccd 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -642,13 +642,14 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis
/*!
Loads the text of the licenses contained in \a licenseHash from \a directory.
- This is saved into a new hash containing the filename and the text of that file.
+ This is saved into a new hash containing the filename, the text and the priority of that file.
*/
void Component::loadLicenses(const QString &directory, const QHash<QString, QVariant> &licenseHash)
{
QHash<QString, QVariant>::const_iterator it;
for (it = licenseHash.begin(); it != licenseHash.end(); ++it) {
- const QString &fileName = it.value().toString();
+ QVariantMap license = it.value().toMap();
+ const QString &fileName = license.value(QLatin1String("file")).toString();
if (!ProductKeyCheck::instance()->isValidLicenseTextFile(fileName))
continue;
@@ -682,7 +683,8 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
}
QTextStream stream(&file);
stream.setCodec("UTF-8");
- d->m_licenses.insert(it.key(), qMakePair(fileName, stream.readAll()));
+ license.insert(QLatin1String("content"), stream.readAll());
+ d->m_licenses.insert(it.key(), license);
}
}
@@ -698,9 +700,9 @@ QStringList Component::userInterfaces() const
}
/*!
- Returns a hash that contains the file names and text of license files for the component.
+ Returns a hash that contains the file names, text and priorities of license files for the component.
*/
-QHash<QString, QPair<QString, QString> > Component::licenses() const
+QHash<QString, QVariantMap> Component::licenses() const
{
return d->m_licenses;
}
@@ -965,9 +967,11 @@ OperationList Component::operations() const
d->m_licenseOperation->setValue(QLatin1String("component"), name());
QVariantMap licenses;
- const QList<QPair<QString, QString> > values = d->m_licenses.values();
- for (int i = 0; i < values.count(); ++i)
- licenses.insert(values.at(i).first, values.at(i).second);
+ const QList<QVariantMap> values = d->m_licenses.values();
+ for (int i = 0; i < values.count(); ++i) {
+ licenses.insert(values.at(i).value(QLatin1String("file")).toString(),
+ values.at(i).value(QLatin1String("content")));
+ }
d->m_licenseOperation->setValue(QLatin1String("licenses"), licenses);
d->m_operations.append(d->m_licenseOperation);
}