summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagercore.cpp
diff options
context:
space:
mode:
authorjkobus <jaroslaw.kobus@theqtcompany.com>2014-12-18 14:59:52 +0100
committerJarek Kobus <jaroslaw.kobus@theqtcompany.com>2015-01-19 16:27:58 +0100
commit668e053c62d4a2dae5f38e454fac00df74eeeb03 (patch)
tree6d7f8acffc163c44db404979d0db2d8f624536b5 /src/libs/installer/packagemanagercore.cpp
parent46b8eb8d6713e0e592c94b090baece0613b2503a (diff)
Introduce InstallAction property for component
Fixes calculation of component size inside maintenance tool. Don't manipulate check state of components while calculating dependencies. Prepare feature: live preview of dependencies. Change-Id: I0485df8383bc9149a996456e09878fc5676bb27b Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/packagemanagercore.cpp')
-rw-r--r--src/libs/installer/packagemanagercore.cpp87
1 files changed, 63 insertions, 24 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 4190efd18..8600dc114 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -424,7 +424,37 @@ void PackageManagerCore::cancelMetaInfoJob()
*/
void PackageManagerCore::componentsToInstallNeedsRecalculation()
{
- d->m_componentsToInstallCalculated = false;
+ d->clearInstallerCalculator();
+ d->clearUninstallerCalculator();
+ QList<Component*> selectedComponentsToInstall = componentsMarkedForInstallation();
+
+ d->m_componentsToInstallCalculated =
+ d->installerCalculator()->appendComponentsToInstall(selectedComponentsToInstall);
+
+ QList<Component *> componentsToInstall = d->installerCalculator()->orderedComponentsToInstall();
+
+ QList<Component *> selectedComponentsToUninstall;
+ foreach (Component *component, components(ComponentType::All)) {
+ if (component->uninstallationRequested() && !selectedComponentsToInstall.contains(component))
+ selectedComponentsToUninstall.append(component);
+ }
+
+ d->uninstallerCalculator()->appendComponentsToUninstall(selectedComponentsToUninstall);
+
+ QSet<Component *> componentsToUninstall = d->uninstallerCalculator()->componentsToUninstall();
+
+ foreach (Component *component, components(ComponentType::Root | ComponentType::Descendants))
+ component->setInstallAction(component->isInstalled()
+ ? ComponentModelHelper::KeepInstalled
+ : ComponentModelHelper::KeepUninstalled);
+ foreach (Component *component, componentsToUninstall)
+ component->setInstallAction(ComponentModelHelper::Uninstall);
+ foreach (Component *component, componentsToInstall)
+ component->setInstallAction(ComponentModelHelper::Install);
+
+ // update all nodes uncompressed size
+ foreach (Component *const component, components(ComponentType::Root))
+ component->updateUncompressedSize(); // this is a recursive call
}
/*!
@@ -468,9 +498,9 @@ void PackageManagerCore::setMessageBoxAutomaticAnswer(const QString &identifier,
quint64 size(QInstaller::Component *component, const QString &value)
{
- if (!component->isSelected() || component->isInstalled())
- return quint64(0);
- return component->value(value).toLongLong();
+ if (component->installAction() == ComponentModelHelper::Install)
+ return component->value(value).toLongLong();
+ return quint64(0);
}
/*!
@@ -1235,6 +1265,30 @@ Component *PackageManagerCore::componentByName(const QString &name, const QList<
return 0;
}
+QList<Component *> PackageManagerCore::componentsMarkedForInstallation() const
+{
+ QList<Component*> markedForInstallation;
+ const QList<Component*> relevant = components(ComponentType::Root | ComponentType::Descendants);
+ if (isUpdater()) {
+ foreach (Component *component, relevant) {
+ if (component->updateRequested())
+ markedForInstallation.append(component);
+ }
+ } else {
+ // relevant means all components which are not replaced
+ foreach (Component *component, relevant) {
+ // ask for all components which will be installed to get all dependencies
+ // even dependencies which are changed without an increased version
+ if (component->installationRequested()
+ || (component->isInstalled()
+ && !component->uninstallationRequested())) {
+ markedForInstallation.append(component);
+ }
+ }
+ }
+ return markedForInstallation;
+}
+
/*!
\qmlmethod boolean installer::calculateComponentsToInstall()
@@ -1248,28 +1302,11 @@ bool PackageManagerCore::calculateComponentsToInstall() const
emit aboutCalculateComponentsToInstall();
if (!d->m_componentsToInstallCalculated) {
d->clearInstallerCalculator();
- QList<Component*> componentsToInstall;
- const QList<Component*> relevant = components(ComponentType::Root | ComponentType::Descendants);
- if (isUpdater()) {
- foreach (Component *component, relevant) {
- if (component->updateRequested())
- componentsToInstall.append(component);
- }
- } else if (!isUpdater()) {
- // relevant means all components which are not replaced
- foreach (Component *component, relevant) {
- // ask for all components which will be installed to get all dependencies
- // even dependencies which are changed without an increased version
- if (component->installationRequested() || (component->isInstalled()
- && !component->uninstallationRequested())) {
- componentsToInstall.append(component);
- }
- }
- }
+ QList<Component*> selectedComponentsToInstall = componentsMarkedForInstallation();
d->storeCheckState();
d->m_componentsToInstallCalculated =
- d->installerCalculator()->appendComponentsToInstall(componentsToInstall);
+ d->installerCalculator()->appendComponentsToInstall(selectedComponentsToInstall);
}
emit finishedCalculateComponentsToInstall();
return d->m_componentsToInstallCalculated;
@@ -2441,11 +2478,13 @@ QString PackageManagerCore::findDisplayVersion(const QString &componentName,
ComponentModel *PackageManagerCore::componentModel(PackageManagerCore *core, const QString &objectName) const
{
- ComponentModel *model = new ComponentModel(5, core);
+ ComponentModel *model = new ComponentModel(ComponentModelHelper::LastColumn, core);
model->setObjectName(objectName);
model->setHeaderData(ComponentModelHelper::NameColumn, Qt::Horizontal,
ComponentModel::tr("Component Name"));
+ model->setHeaderData(ComponentModelHelper::ActionColumn, Qt::Horizontal,
+ ComponentModel::tr("Action"));
model->setHeaderData(ComponentModelHelper::InstalledVersionColumn, Qt::Horizontal,
ComponentModel::tr("Installed Version"));
model->setHeaderData(ComponentModelHelper::NewVersionColumn, Qt::Horizontal,