diff options
author | Katja Marttila <katja.marttila@qt.io> | 2016-11-10 12:04:17 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2016-11-15 06:43:54 +0000 |
commit | b5b0a8d2657f874f09f157246a592a270ea78d87 (patch) | |
tree | 457e2a0656eee2c40db6da53f63e3810f6a0a9c1 /src/libs/installer/packagemanagercore.cpp | |
parent | e7f93217182233383851a25ae21bd950d05b408a (diff) |
Introduces new --silentUpdate command line option
With this feature one can update all installed components
silently with maintenancetool by passing --silentUpdate parameter
Change-Id: If31d37ce24e794775c2fe47b603259da133c9ee7
Task-number: QTIFW-906
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'src/libs/installer/packagemanagercore.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 971ca694d..e02bc0add 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -1632,6 +1632,52 @@ QList<Component*> PackageManagerCore::orderedComponentsToInstall() const return d->installerCalculator()->orderedComponentsToInstall(); } +bool PackageManagerCore::calculateComponents(QString *displayString) +{ + QString htmlOutput; + QString lastInstallReason; + if (!calculateComponentsToUninstall() || + !calculateComponentsToInstall()) { + htmlOutput.append(QString::fromLatin1("<h2><font color=\"red\">%1</font></h2><ul>") + .arg(tr("Cannot resolve all dependencies."))); + //if we have a missing dependency or a recursion we can display it + if (!componentsToInstallError().isEmpty()) { + htmlOutput.append(QString::fromLatin1("<li> %1 </li>").arg( + componentsToInstallError())); + } + htmlOutput.append(QLatin1String("</ul>")); + if (displayString) + *displayString = htmlOutput; + return false; + } + + // In case of updater mode we don't uninstall components. + if (!isUpdater()) { + QList<Component*> componentsToRemove = componentsToUninstall(); + if (!componentsToRemove.isEmpty()) { + htmlOutput.append(QString::fromLatin1("<h3>%1</h3><ul>").arg(tr("Components about to " + "be removed."))); + foreach (Component *component, componentsToRemove) + htmlOutput.append(QString::fromLatin1("<li> %1 </li>").arg(component->name())); + htmlOutput.append(QLatin1String("</ul>")); + } + } + + foreach (Component *component, orderedComponentsToInstall()) { + const QString reason = installReason(component); + if (lastInstallReason != reason) { + if (!lastInstallReason.isEmpty()) // means we had to close the previous list + htmlOutput.append(QLatin1String("</ul>")); + htmlOutput.append(QString::fromLatin1("<h3>%1</h3><ul>").arg(reason)); + lastInstallReason = reason; + } + htmlOutput.append(QString::fromLatin1("<li> %1 </li>").arg(component->name())); + } + if (displayString) + *displayString = htmlOutput; + return true; +} + /*! Calculates a list of components to uninstall based on the current run mode. The aboutCalculateComponentsToUninstall() signal is emitted @@ -1755,6 +1801,28 @@ ComponentModel *PackageManagerCore::updaterComponentModel() const return d->m_updaterModel; } +void PackageManagerCore::updateComponentsSilently() +{ + autoAcceptMessageBoxes(); + fetchRemotePackagesTree(); + //Mark all components to be installed + const QList<QInstaller::Component*> componentList = components( + ComponentType::Root | ComponentType::Descendants); + + foreach (Component *comp, componentList) { + comp->setCheckState(Qt::Checked); + } + QString htmlOutput; + bool componentsOk = calculateComponents(&htmlOutput); + if (componentsOk) { + if (runPackageUpdater()) + qDebug() << "Components updated successfully."; + } + else { + qDebug() << htmlOutput; + } +} + /*! Returns the settings for the package manager. */ |