diff options
4 files changed, 43 insertions, 30 deletions
diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs index 4ccf7a047..7907a268a 100644 --- a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs +++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/installscript.qs @@ -2,8 +2,3 @@ function Component() { } - -Component.prototype.isDefault = function() -{ - return true; -} diff --git a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml index 3da78f49d..d60cf21f4 100644 --- a/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml +++ b/examples/testapp/packages/com.nokia.testapp.subcomponent.virtual/meta/package.xml @@ -6,5 +6,4 @@ <Name>com.nokia.testapp.subcomponent.virtual</Name> <Virtual>true</Virtual> <Script>installscript.qs</Script> - <Default>script</Default> </Package> 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); } } diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index 76d547526..733323a79 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -172,13 +172,20 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt blackList << QLatin1String("UserInterfaces") << QLatin1String("Translations") << QLatin1String("Licenses") << QLatin1String("Name"); + bool foundDefault = false; + bool foundVirtual = false; const QDomNodeList childNodes = package.childNodes(); for (int i = 0; i < childNodes.count(); ++i) { const QDomNode node = childNodes.at(i); const QString key = node.nodeName(); - // just skip comments and some tags... + + if (key == QLatin1String("Default")) + foundDefault = true; + if (key == QLatin1String("Virtual")) + foundVirtual = true; if (node.isComment() || blackList.contains(key)) - continue; + continue; // just skip comments and some tags... + const QString value = node.toElement().text(); QDomElement element = doc.createElement(key); for (int i = 0; i < node.attributes().size(); i++) { @@ -188,6 +195,11 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt update.appendChild(element).appendChild(doc.createTextNode(value)); } + if (foundDefault && foundVirtual) { + throw QInstaller::Error(QString::fromLatin1("Error: <Default> and <Virtual> elements are " + "mutually exclusive. File: '%0'").arg(packageXmlPath)); + } + // get the size of the data quint64 componentSize = 0; quint64 compressedComponentSize = 0; |