summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorkh1 <qt-info@nokia.com>2011-08-11 16:02:47 +0200
committerkh1 <qt-info@nokia.com>2011-08-12 11:03:10 +0200
commit69d522b9d580f72e908b532736cf85d01fdf2680 (patch)
tree5657f6cf3f662a182d852c2e7a2728164d1ab889 /installerbuilder
parent7a90678d58b7b4a92d6fd8362a0d7c1da27429d1 (diff)
Added some comments. Small change to keep the code compact.
Review-By: Niels Weber
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/libinstaller/component.cpp41
-rw-r--r--installerbuilder/libinstaller/component.h5
2 files changed, 25 insertions, 21 deletions
diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp
index c2ebabec8..4034a3000 100644
--- a/installerbuilder/libinstaller/component.cpp
+++ b/installerbuilder/libinstaller/component.cpp
@@ -918,38 +918,41 @@ void Component::setInstalled()
}
/*!
- Determines if the component comes as an auto dependency.
+ Determines if the component comes as an auto dependency. Returns true if the component needs to be
+ installed.
*/
-bool Component::isAutoDependOn(const QSet<QString> &toInstallComponentIds) const
+bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const
{
- // the script can override this method
+ // The script can override this method and determines if the component needs to be installed.
if (value(scAutoDependOn).compare(QLatin1String("script"), Qt::CaseInsensitive) == 0) {
const QScriptValue valueFromScript = callScriptMethod(QLatin1String("isAutoDependOn"));
- if (valueFromScript.isValid()) {
+ if (valueFromScript.isValid())
return valueFromScript.toBool();
- }
verbose() << "value from script is not valid " << std::endl;
return false;
}
- QStringList autoDependOnDependencyList = value(scAutoDependOn).split(QRegExp(
- QLatin1String("\\b(,|, )\\b")), QString::SkipEmptyParts);
- if (autoDependOnDependencyList.isEmpty())
+
+ // If there is no auto depend on value or the value is empty, we have nothing todo. The component does
+ // not need to be installed as an auto dependency.
+ QStringList autoDependOnList = value(scAutoDependOn).split(QRegExp(QLatin1String("\\b(,|, )\\b")),
+ QString::SkipEmptyParts);
+ if (autoDependOnList.isEmpty())
return false;
- QSet<QString> installedComponentIds;
+ QSet<QString> components = componentsToInstall;
foreach (const Component *component, d->m_core->availableComponents()) {
- if (component->isInstalled()) {
- installedComponentIds.insert(component->name());
- }
+ if (component->isInstalled())
+ components.insert(component->name());
}
- installedComponentIds.unite(toInstallComponentIds);
- //if we found all autodependons we know that this one wants to be installed
- foreach (QString componentName, installedComponentIds) {
- if (autoDependOnDependencyList.contains(componentName)) {
- autoDependOnDependencyList.removeAll(componentName);
- //found all "when"-components
- if (autoDependOnDependencyList.isEmpty())
+
+ foreach (const QString &component, components) {
+ if (autoDependOnList.contains(component)) {
+ autoDependOnList.removeAll(component);
+ if (autoDependOnList.isEmpty()) {
+ // If all components in the isAutoDependOn field are already installed or selected for
+ // installation, this component needs to be installed as well.
return true;
+ }
}
}
diff --git a/installerbuilder/libinstaller/component.h b/installerbuilder/libinstaller/component.h
index 7d7bf7d4d..200f70916 100644
--- a/installerbuilder/libinstaller/component.h
+++ b/installerbuilder/libinstaller/component.h
@@ -173,9 +173,10 @@ public:
bool autoCreateOperations() const;
bool operationsCreatedSuccessfully() const;
- Q_INVOKABLE void setInstalled();
Q_INVOKABLE bool isDefault() const;
- Q_INVOKABLE bool isAutoDependOn(const QSet<QString> &toInstallComponentIds) const;
+ Q_INVOKABLE bool isAutoDependOn(const QSet<QString> &componentsToInstall) const;
+
+ Q_INVOKABLE void setInstalled();
Q_INVOKABLE bool isInstalled() const;
Q_INVOKABLE bool installationRequested() const;