From 05bb1b8ccd3d12fb286f026406f076a41ec54965 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 3 Jun 2014 12:58:10 +0200 Subject: Make it possible to calculate dependencies from script. Task-number: QTIFW-503 Change-Id: Ic359d586f36669d4c1430c22e10b5a209ba6fc3c Reviewed-by: Samuli Piippo Reviewed-by: Kai Koehne Reviewed-by: Niels Weber --- src/libs/installer/packagemanagercore.cpp | 61 +++++++++++++++++++++++-------- src/libs/installer/packagemanagercore.h | 7 +++- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 61ce92467..82f852faf 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -128,6 +128,24 @@ Emitted before the ordered list of components to install is calculated. */ +/*! + \qmlsignal QInstaller::finishedCalculateComponentsToInstall() + + Emitted after the ordered list of components to install was calculated. +*/ + +/*! + \qmlsignal QInstaller::aboutCalculateComponentsToUninstall() + + Emitted before the ordered list of components to uninstall is calculated. +*/ + +/*! + \qmlsignal QInstaller::finishedCalculateComponentsToUninstall() + + Emitted after the ordered list of components to uninstall was calculated. +*/ + /*! \qmlsignal QInstaller::componentAdded(Component component) @@ -1247,8 +1265,12 @@ Component *PackageManagerCore::componentByName(const QString &name) const } /*! - Calculates an ordered list of components to install based on the current run mode. Also auto installed - dependencies are resolved. + \qmlmethod boolean QInstaller::calculateComponentsToInstall() + + Calculates an ordered list of components to install based on the current run mode. Also auto + installed dependencies are resolved. The aboutCalculateComponentsToInstall() signal is emitted + before the calculation starts, the finishedCalculateComponentsToInstall() signal once all + calculations are done. */ bool PackageManagerCore::calculateComponentsToInstall() const { @@ -1278,6 +1300,7 @@ bool PackageManagerCore::calculateComponentsToInstall() const d->m_componentsToInstallCalculated = d->appendComponentsToInstall(components); } + emit finishedCalculateComponentsToInstall(); return d->m_componentsToInstallCalculated; } @@ -1290,26 +1313,32 @@ QList PackageManagerCore::orderedComponentsToInstall() const } /*! - Calculates a list of components to uninstall based on the current run mode. Auto installed dependencies - are resolved as well. + \qmlmethod boolean QInstaller::calculateComponentsToUninstall() + + Calculates a list of components to uninstall based on the current run mode. Auto installed + dependencies are not yet resolved. The aboutCalculateComponentsToUninstall() signal is emitted + before the calculation starts, the finishedCalculateComponentsToUninstall() signal once all + calculations are done. */ bool PackageManagerCore::calculateComponentsToUninstall() const { - if (isUpdater()) - return true; + bool result = true; + emit aboutCalculateComponentsToUninstall(); + if (!isUpdater()) { + // hack to avoid removing needed dependencies + QSet componentsToInstall = d->m_orderedComponentsToInstall.toSet(); - // hack to avoid removing needed dependencies - QSet componentsToInstall = d->m_orderedComponentsToInstall.toSet(); + QList components; + foreach (Component *component, availableComponents()) { + if (component->uninstallationRequested() && !componentsToInstall.contains(component)) + components.append(component); + } - QList components; - foreach (Component *component, availableComponents()) { - if (component->uninstallationRequested() && !componentsToInstall.contains(component)) - components.append(component); + d->m_componentsToUninstall.clear(); + result = d->appendComponentsToUninstall(components); } - - - d->m_componentsToUninstall.clear(); - return d->appendComponentsToUninstall(components); + emit finishedCalculateComponentsToUninstall(); + return result; } /*! diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index a3f2b7eb0..7b45b008e 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -199,10 +199,10 @@ public: QList availableComponents() const; Component *componentByName(const QString &identifier) const; - bool calculateComponentsToInstall() const; + Q_INVOKABLE bool calculateComponentsToInstall() const; QList orderedComponentsToInstall() const; - bool calculateComponentsToUninstall() const; + Q_INVOKABLE bool calculateComponentsToUninstall() const; QList componentsToUninstall() const; QString componentsToInstallError() const; @@ -270,6 +270,9 @@ public Q_SLOTS: Q_SIGNALS: void aboutCalculateComponentsToInstall() const; + void finishedCalculateComponentsToInstall() const; + void aboutCalculateComponentsToUninstall() const; + void finishedCalculateComponentsToUninstall() const; void componentAdded(QInstaller::Component *comp); void rootComponentsAdded(QList components); void updaterComponentsAdded(QList components); -- cgit v1.2.3