diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-02-19 16:03:35 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-02-20 11:18:26 +0100 |
commit | 2635cb74cfe3c14a2f0acc385de8b022ec9ddded (patch) | |
tree | cfbdc438eaf92a22f2aba4e566e987ebbef277a6 /src/libs/installer | |
parent | 8092e354949370be204071258661aefad6f2b58e (diff) |
Fix boolean parameter which lead to less readable code.
Change-Id: Ie680654f39fce130c607929f98db372dbe3c6ea1
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/libs/installer')
-rw-r--r-- | src/libs/installer/component.cpp | 23 | ||||
-rw-r--r-- | src/libs/installer/component.h | 8 | ||||
-rw-r--r-- | src/libs/installer/component_p.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 2 |
5 files changed, 26 insertions, 19 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index ddc74328d..824d6ead5 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -303,23 +303,22 @@ void Component::removeComponent(Component *component) } /*! - Returns a list of child components. If \a recursive is set to true, the returned list contains not only - the direct children, but all ancestors. Note: The returned list does include ALL children, non virtual - components as well as virtual components. + Returns a list of child components. If \a kind is set to DirectChildrenOnly, the returned list contains + only the direct children, if set to Descendants it will also include all descendants of the components + children. Note: The returned list does include ALL children, non virtual components as well as virtual + components. */ -QList<Component*> Component::childComponents(bool recursive) const +QList<Component *> Component::childComponents(Kind kind) const { - QList<Component*> result; if (d->m_core->isUpdater()) - return result; + return QList<Component*>(); - if (!recursive) - return d->m_allChildComponents; + QList<Component *> result = d->m_allChildComponents; + if (kind == Kind::DirectChildrenOnly) + return result; - foreach (Component *component, d->m_allChildComponents) { - result.append(component); - result += component->childComponents(true); - } + foreach (Component *component, d->m_allChildComponents) + result += component->childComponents(kind); return result; } diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index 7e5541970..343e1a3af 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -85,6 +85,12 @@ class INSTALLER_EXPORT Component : public QObject, public QScriptable, public Co Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) public: + enum Kind + { + Descendants = 0x1000, // all descendants of the current component (children, grandchildren, etc.) + DirectChildrenOnly = 0x2000 // all child components of the current component + }; + explicit Component(PackageManagerCore *core); ~Component(); @@ -117,7 +123,7 @@ public: Component *parentComponent() const; void appendComponent(Component *component); void removeComponent(Component *component); - QList<Component*> childComponents(bool recursive) const; + QList<Component*> childComponents(Component::Kind kind) const; void loadComponentScript(); diff --git a/src/libs/installer/component_p.cpp b/src/libs/installer/component_p.cpp index 93f79e025..51455c27f 100644 --- a/src/libs/installer/component_p.cpp +++ b/src/libs/installer/component_p.cpp @@ -218,8 +218,10 @@ int ComponentModelHelper::childCount() const int ComponentModelHelper::indexInParent() const { int index = 0; - if (Component *parent = m_componentPrivate->m_parentComponent->parentComponent()) - index = parent->childComponents(false).indexOf(m_componentPrivate->m_parentComponent); + if (Component *parent = m_componentPrivate->m_parentComponent->parentComponent()) { + index = parent->childComponents(Component::DirectChildrenOnly) + .indexOf(m_componentPrivate->m_parentComponent); + } return (index >= 0 ? index : 0); } diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index ebce458e2..b10d194de 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -134,7 +134,7 @@ Component *PackageManagerCore::subComponentByName(const QInstaller::PackageManag if (check == 0) rootComponents = installer->rootComponents(); else - rootComponents = check->childComponents(false); + rootComponents = check->childComponents(Component::DirectChildrenOnly); foreach (QInstaller::Component *component, rootComponents) { Component *const result = subComponentByName(installer, name, version, component); @@ -922,7 +922,7 @@ QList<Component*> PackageManagerCore::availableComponents() const QList<Component*> result = d->m_rootComponents; foreach (QInstaller::Component *component, d->m_rootComponents) - result += component->childComponents(true); + result += component->childComponents(Component::Descendants); return result + d->m_rootDependencyReplacements; } @@ -965,7 +965,7 @@ bool PackageManagerCore::calculateComponentsToInstall() const // relevant means all components which are not replaced QList<Component*> relevantComponents = rootComponents(); foreach (QInstaller::Component *component, rootComponents()) - relevantComponents += component->childComponents(true); + relevantComponents += component->childComponents(Component::Descendants); foreach (Component *component, relevantComponents) { // ask for all components which will be installed to get all dependencies // even dependencies which are changed without an increased version diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 65642a4d6..04faa051a 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -439,7 +439,7 @@ bool PackageManagerCorePrivate::appendComponentsToInstall(const QList<Component relevantComponentForAutoDependOn = m_updaterComponents + m_updaterComponentsDeps; else { foreach (QInstaller::Component *component, m_rootComponents) - relevantComponentForAutoDependOn += component->childComponents(true); + relevantComponentForAutoDependOn += component->childComponents(Component::Descendants); } QList<Component*> notAppendedComponents; // for example components with unresolved dependencies |