summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/component.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/component.cpp')
-rw-r--r--src/libs/installer/component.cpp46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index 1a83291c1..d4750cee9 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -87,6 +87,8 @@ static const QLatin1String scUnstable("Unstable");
Component script has errors or loading fails.
\value MissingDependency
Component has dependencies to missing components.
+ \value InvalidTreeName
+ Component has an invalid tree name.
*/
/*!
@@ -285,7 +287,6 @@ void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package)
{
setValue(scName, package.name);
setValue(scDisplayName, package.title);
- setValue(scTreeName, package.treeName);
setValue(scDescription, package.description);
setValue(scVersion, package.version);
setValue(scInheritVersion, package.inheritVersionFrom);
@@ -302,6 +303,9 @@ void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package)
setValue(scCheckable, package.checkable ? scTrue : scFalse);
setValue(scExpandedByDefault, package.expandedByDefault ? scTrue : scFalse);
setValue(scContentSha1, package.contentSha1);
+
+ setValue(scTreeName, package.treeName.first);
+ d->m_treeNameMoveChildren = package.treeName.second;
}
/*!
@@ -316,7 +320,6 @@ void Component::loadDataFromPackage(const Package &package)
setValue(scName, package.data(scName).toString());
setValue(scDisplayName, package.data(scDisplayName).toString());
- setValue(scTreeName, package.data(scTreeName).toString());
setValue(scDescription, package.data(scDescription).toString());
setValue(scDefault, package.data(scDefault).toString());
setValue(scAutoDependOn, package.data(scAutoDependOn).toString());
@@ -347,17 +350,21 @@ void Component::loadDataFromPackage(const Package &package)
setValue(scForcedInstallation, forced);
setValue(scContentSha1, package.data(scContentSha1).toString());
+ const auto treeNamePair = package.data(QLatin1String(scTreeName)).value<QPair<QString, bool>>();
+ setValue(scTreeName, treeNamePair.first);
+ d->m_treeNameMoveChildren = treeNamePair.second;
+
if (d->m_core->isPackageViewer())
return;
setLocalTempPath(QInstaller::pathFromUrl(package.packageSource().url));
const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString()
- .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
+ .split(QInstaller::commaRegExp(), Qt::SkipEmptyParts);
if (!uis.isEmpty())
loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis);
#ifndef IFW_DISABLE_TRANSLATIONS
const QStringList qms = package.data(QLatin1String("Translations")).toString()
- .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
+ .split(QInstaller::commaRegExp(), Qt::SkipEmptyParts);
if (!qms.isEmpty())
loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms);
#endif
@@ -425,6 +432,16 @@ QString Component::value(const QString &key, const QString &defaultValue) const
}
/*!
+ Removes all the values that have the \a key from the variables set for this component.
+ Returns the number of values removed which is 1 if the key exists in the variables,
+ and 0 otherwise.
+*/
+int Component::removeValue(const QString &key)
+{
+ return d->m_vars.remove(key);
+}
+
+/*!
Sets the value of the variable with \a key to \a value.
\sa {component::setValue}{component.setValue}
@@ -553,7 +570,18 @@ QString Component::displayName() const
*/
QString Component::treeName() const
{
- return d->m_vars.value(scTreeName, name());
+ const QString defaultValue = d->m_vars.value(scAutoTreeName, name());
+ return d->m_vars.value(scTreeName, defaultValue);
+}
+
+/*!
+ Returns \c true if descendants of this component should have automatically
+ created tree names in relation to the parent component's modified location,
+ \c false otherwise.
+*/
+bool Component::treeNameMoveChildren() const
+{
+ return d->m_treeNameMoveChildren;
}
/*!
@@ -699,7 +727,7 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
break;
QList<QFileInfo> fileCandidates;
- foreach (const QString &locale, QInstaller::localeCandidates(lang.toLower())) {
+ foreach (const QString &locale, QInstaller::localeCandidates(lang)) {
fileCandidates << QFileInfo(QString::fromLatin1("%1%2_%3.%4").arg(
directory, fileInfo.baseName(), locale,
fileInfo.completeSuffix()));
@@ -1329,7 +1357,7 @@ void Component::addDependency(const QString &newDependency)
QStringList Component::dependencies() const
{
- return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
+ return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), Qt::SkipEmptyParts);
}
/*!
@@ -1352,7 +1380,7 @@ void Component::addAutoDependOn(const QString &newDependOn)
QStringList Component::autoDependencies() const
{
- return d->m_vars.value(scAutoDependOn).split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
+ return d->m_vars.value(scAutoDependOn).split(QInstaller::commaRegExp(), Qt::SkipEmptyParts);
}
/*!
@@ -1383,7 +1411,7 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const
// essential updates needs to be installed first, otherwise non-essential components
// will be installed
if (packageManagerCore()->foundEssentialUpdate()) {
- const QSet<QString> autoDependOnSet = autoDependOnList.toSet();
+ const QSet<QString> autoDependOnSet(autoDependOnList.begin(), autoDependOnList.end());
if (componentsToInstall.contains(autoDependOnSet)) {
foreach (const QString &autoDep, autoDependOnSet) {
Component *component = packageManagerCore()->componentByName(autoDep);