diff options
author | Jarkko Lehtoranta <jarkko.lehtoranta@jolla.com> | 2019-03-04 11:52:32 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2020-11-06 12:00:28 +0200 |
commit | c16baa1128b1abf360e9c925c45f1580115cb5d1 (patch) | |
tree | 7c2f6d320a7a7f2ee7cb9cdc8ebcf720b2ad9f0e /src/libs/installer/packagemanagercore_p.cpp | |
parent | c46a6424b8130583014d61424db7c79bc7ded1c8 (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/packagemanagercore_p.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 3a9386816..f6897d692 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -2586,21 +2586,31 @@ bool PackageManagerCorePrivate::acceptLicenseAgreements() const if (isUninstaller()) return true; - typedef QHash<QString, QPair<QString, QString> > LicensesHash; foreach (Component *component, m_core->orderedComponentsToInstall()) { // Package manager or updater, no need to accept again as long as // the component is installed. if (m_core->isMaintainer() && component->isInstalled()) continue; + m_core->addLicenseItem(component->licenses()); + } + + QHash<QString, QMap<QString, QString>> priorityHash = m_core->sortedLicenses(); + QStringList priorities = priorityHash.keys(); + priorities.sort(); + for (int i = priorities.length() - 1; i >= 0; --i) { + QString priority = priorities.at(i); + QMap<QString, QString> licenses = priorityHash.value(priority); - LicensesHash hash = component->licenses(); - for (LicensesHash::iterator it = hash.begin(); it != hash.end(); ++it) { - if (m_autoAcceptLicenses || askUserAcceptLicense(it.key(), it.value().second)) { + QStringList licenseNames = licenses.keys(); + licenseNames.sort(Qt::CaseInsensitive); + for (QString licenseName : licenseNames) { + if (m_autoAcceptLicenses + || askUserAcceptLicense(licenseName, licenses.value(licenseName))) { qCDebug(QInstaller::lcInstallerInstallLog) << "License" - << it.key() << "accepted by user."; + << licenseName << "accepted by user."; } else { qCDebug(QInstaller::lcInstallerInstallLog) << "License" - << it.key() << "not accepted by user. Aborting."; + << licenseName<< "not accepted by user. Aborting."; return false; } } |