diff options
author | Tim Jenssen <tim.jenssen@digia.com> | 2013-02-19 20:18:01 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-02-20 11:17:42 +0100 |
commit | 5c2d700cb134b34dbfb5b92e33ab86d1f6b03125 (patch) | |
tree | 4266cd94e3f185985ec9c048a9ab6b65e2a6bb53 /src/libs/installer/component.cpp | |
parent | 5d9b4fe6360e261b40e54e1acbba55a921414e22 (diff) |
Make Virtual and Default tag mutually exclusive.
Call m_vars value function directly.
1; To prevent recursive calls in case of key "Default".
2; To avoid the extra function call to fetch values from m_vars in
case of other values set in the object.
Change-Id: I8f40b53704d1f314071d7060d0c92829310c262d
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src/libs/installer/component.cpp')
-rw-r--r-- | src/libs/installer/component.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index a2ce4bc26..707381b39 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -200,7 +200,7 @@ quint64 Component::updateUncompressedSize() quint64 size = 0; if (isSelected()) - size = value(scUncompressedSize).toLongLong(); + size = d->m_vars.value(scUncompressedSize).toLongLong(); foreach (Component* comp, d->m_allChildComponents) size += comp->updateUncompressedSize(); @@ -225,11 +225,14 @@ QHash<QString,QString> Component::variables() const } /*! - Returns the value of variable name \a key. - If \a key is not known yet, \a defaultValue is returned. + Returns the value of variable name \a key. If \a key is not known yet, \a defaultValue is returned. + Note: If a component is virtual and you ask for the component value with key "Default", it will always + return false. */ QString Component::value(const QString &key, const QString &defaultValue) const { + if (key == scDefault) + return isDefault() ? scTrue : scFalse; return d->m_vars.value(key, defaultValue); } @@ -336,12 +339,12 @@ QString Component::name() const */ QString Component::displayName() const { - return value(scDisplayName); + return d->m_vars.value(scDisplayName); } void Component::loadComponentScript() { - const QString script = value(scScript); + const QString script = d->m_vars.value(scScript); if (!localTempPath().isEmpty() && !script.isEmpty()) loadComponentScript(QString::fromLatin1("%1/%2/%3").arg(localTempPath(), name(), script)); } @@ -677,9 +680,8 @@ void Component::addDownloadableArchive(const QString &path) { Q_ASSERT(isFromOnlineRepository()); - const QString versionPrefix = value(scRemoteVersion); qDebug() << "addDownloadable" << path; - d->m_downloadableArchives.append(versionPrefix + path); + d->m_downloadableArchives.append(d->m_vars.value(scRemoteVersion) + path); } /*! @@ -927,7 +929,7 @@ void Component::setAutoCreateOperations(bool autoCreateOperations) bool Component::isVirtual() const { - return value(scVirtual, scFalse).toLower() == scTrue; + return d->m_vars.value(scVirtual, scFalse).toLower() == scTrue; } /*! @@ -942,7 +944,7 @@ bool Component::isSelected() const bool Component::forcedInstallation() const { - return value(scForcedInstallation, scFalse).toLower() == scTrue; + return d->m_vars.value(scForcedInstallation, scFalse).toLower() == scTrue; } void Component::setValidatorCallbackName(const QString &name) @@ -968,7 +970,7 @@ void Component::setSelected(bool selected) void Component::addDependency(const QString &newDependency) { - QString oldDependencies = value(scDependencies); + QString oldDependencies = d->m_vars.value(scDependencies); if (oldDependencies.isEmpty()) setValue(scDependencies, newDependency); else @@ -982,13 +984,13 @@ void Component::addDependency(const QString &newDependency) */ QStringList Component::dependencies() const { - return value(scDependencies).split(scCommaRegExp, QString::SkipEmptyParts); + return d->m_vars.value(scDependencies).split(scCommaRegExp, QString::SkipEmptyParts); } QStringList Component::autoDependencies() const { QStringList autoDependencyStringList = - value(scAutoDependOn).split(scCommaRegExp, QString::SkipEmptyParts); + d->m_vars.value(scAutoDependOn).split(scCommaRegExp, QString::SkipEmptyParts); autoDependencyStringList.removeAll(QLatin1String("script")); return autoDependencyStringList; } @@ -1049,12 +1051,16 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const } /*! - Determines if the component is a default one. + Determines if the component is a default one. Note: if a component is virtual, this function will always + return false. */ bool Component::isDefault() const { + if (isVirtual()) + return false; + // the script can override this method - if (value(scDefault).compare(QLatin1String("script"), Qt::CaseInsensitive) == 0) { + if (d->m_vars.value(scDefault).compare(QLatin1String("script"), Qt::CaseInsensitive) == 0) { QScriptValue valueFromScript; try { valueFromScript = callScriptMethod(QLatin1String("isDefault")); @@ -1070,7 +1076,7 @@ bool Component::isDefault() const return false; } - return value(scDefault).compare(scTrue, Qt::CaseInsensitive) == 0; + return d->m_vars.value(scDefault).compare(scTrue, Qt::CaseInsensitive) == 0; } /*! @@ -1078,7 +1084,7 @@ bool Component::isDefault() const */ bool Component::isInstalled() const { - return scInstalled == value(scCurrentState); + return scInstalled == d->m_vars.value(scCurrentState); } /*! @@ -1127,7 +1133,7 @@ void Component::setUninstalled() */ bool Component::isUninstalled() const { - return scUninstalled == value(scCurrentState); + return scUninstalled == d->m_vars.value(scCurrentState); } /*! @@ -1196,16 +1202,17 @@ void Component::updateModelData(const QString &key, const QString &data) setData(data, LocalDisplayVersion); if (key == scUncompressedSize) { - quint64 size = value(scUncompressedSizeSum).toLongLong(); + quint64 size = d->m_vars.value(scUncompressedSizeSum).toLongLong(); setData(humanReadableSize(size), UncompressedSize); } - const QString &updateInfo = value(scUpdateText); + const QString &updateInfo = d->m_vars.value(scUpdateText); if (!d->m_core->isUpdater() || updateInfo.isEmpty()) { - setData(QLatin1String("<html><body>") + value(scDescription) + QLatin1String("</body></html>"), - Qt::ToolTipRole); + setData(QLatin1String("<html><body>") + d->m_vars.value(scDescription) + + QLatin1String("</body></html>"), Qt::ToolTipRole); } else { - setData(value(scDescription) + QLatin1String("<br><br>") + tr("Update Info: ") + updateInfo, Qt::ToolTipRole); + setData(d->m_vars.value(scDescription) + QLatin1String("<br><br>") + tr("Update Info: ") + + updateInfo, Qt::ToolTipRole); } } |