From a28cf55b5a5007c0dd952b3012c076d9da329f0f Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Fri, 25 Mar 2022 15:38:50 +0200 Subject: Speed up component selection in component selection pages If a lot of components are installed, maintenancetool was slow to select/unselect a single component. This was caused because the whole tree's components were recalculated. Fixed so that only the selected/unselected components and their dependencies and autodependencies are recalculated instead of whole tree. This change speeds up clicking tree item from zero to 90 percent, depending on how much components are already installed. The more components are installed as autodependency, the slower it gets to select the items. Task-number: QTIFW-2522 Change-Id: I5e824aed8787fd7ecdce72b15a1b13848f0a3923 Reviewed-by: Arttu Tarkiainen --- src/libs/installer/installercalculator.h | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src/libs/installer/installercalculator.h') diff --git a/src/libs/installer/installercalculator.h b/src/libs/installer/installercalculator.h index b2d05bdbe..2841d8671 100644 --- a/src/libs/installer/installercalculator.h +++ b/src/libs/installer/installercalculator.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -42,41 +42,50 @@ class Component; class INSTALLER_EXPORT InstallerCalculator { public: - InstallerCalculator(const QList &allComponents); + InstallerCalculator(const QList &allComponents, const QHash &autoDependencyComponentHash); enum InstallReasonType { + Selected, // "Selected Component(s) without Dependencies" Automatic, // "Component(s) added as automatic dependencies" Dependent, // "Added as dependency for %1." - Resolved, // "Component(s) that have resolved Dependencies" - Selected // "Selected Component(s) without Dependencies" + Resolved // "Component(s) that have resolved Dependencies" }; - InstallReasonType installReasonType(Component *component) const; - QString installReasonReferencedComponent(Component *component) const; - QString installReason(Component *component) const; + InstallReasonType installReasonType(const Component *c) const; + QString installReason(const Component *component) const; QList orderedComponentsToInstall() const; QString componentsToInstallError() const; - bool appendComponentsToInstall(const QList &components); + bool appendComponentsToInstall(const QList &components, bool modelReset = false, const bool revertFromInstall = false); + bool removeComponentsFromInstall(const QList &components); private: - void insertInstallReason(Component *component, - InstallReasonType installReasonType, - const QString &referencedComponentName = QString()); - void realAppendToInstallComponents(Component *component, const QString &version = QString()); - bool appendComponentToInstall(Component *components, const QString &version = QString()); - QString recursionError(Component *component); + QString installReasonReferencedComponent(const Component *component) const; + void insertInstallReason(const Component *component, + const InstallReasonType installReason, + const QString &referencedComponentName = QString(), + const bool revertFromInstall = false); + void realAppendToInstallComponents(Component *component, const QString &version, const bool revertFromInstall); + bool appendComponentToInstall(Component *component, const QString &version, const bool revertFromInstall); + QString recursionError(const Component *component) const; + QSet autodependencyComponents(const bool revertFromInstall); +private: QList m_allComponents; QHash > m_visitedComponents; - QSet m_toInstallComponentIds; //for faster lookups + QList m_componentsForAutodepencencyCheck; + //for faster lookups. + QSet m_toInstallComponentIds; + QHash m_referenceCount; QString m_componentsToInstallError; //calculate installation order variables QList m_orderedComponentsToInstall; //we can't use this reason hash as component id hash, because some reasons are ready before //the component is added QHash > m_toInstallComponentIdReasonHash; + //Helper hash for quicker search for autodependency components + QHash m_autoDependencyComponentHash; }; } -- cgit v1.2.3