diff options
author | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-08-28 14:25:27 +0300 |
---|---|---|
committer | Konstantin Podsvirov <konstantin@podsvirov.pro> | 2017-10-30 05:42:19 +0000 |
commit | ee24c7aefce6acbcac7a51f7c8c53c84ecdc7eca (patch) | |
tree | 529d1636bcf7f122952327c8ca2015ca3665d78f | |
parent | 741d16a9bd088497a0ae1eb172e3d865e09fd57b (diff) |
Add Component::addAutoDependOn method
Changes:
- Add addAutoDependOn method to Component class;
- Add method documentation;
- Improve tst_Solver test.
Change-Id: I5ed62368d62567f1056e20d89ba03c2639e0eaee
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r-- | src/libs/installer/component.cpp | 16 | ||||
-rw-r--r-- | src/libs/installer/component.h | 1 | ||||
-rw-r--r-- | tests/auto/installer/solver/tst_solver.cpp | 10 |
3 files changed, 24 insertions, 3 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index da0230ade..5f2fe9fbc 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -1170,6 +1170,22 @@ QStringList Component::dependencies() const return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), QString::SkipEmptyParts); } +/*! + Adds the component specified by \a newDependOn to the automatic depend-on list. + + \sa {component::addAutoDependOn}{component.addAutoDependOn} + \sa dependencies +*/ + +void Component::addAutoDependOn(const QString &newDependOn) +{ + QString oldDependOn = d->m_vars.value(scAutoDependOn); + if (oldDependOn.isEmpty()) + setValue(scAutoDependOn, newDependOn); + else + setValue(scAutoDependOn, oldDependOn + QLatin1String(", ") + newDependOn); +} + QStringList Component::autoDependencies() const { return d->m_vars.value(scAutoDependOn).split(QInstaller::commaRegExp(), QString::SkipEmptyParts); diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index 01622548f..b11fd4cef 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -154,6 +154,7 @@ public: Q_INVOKABLE void addDependency(const QString &newDependency); QStringList dependencies() const; + Q_INVOKABLE void addAutoDependOn(const QString &newDependOn); QStringList autoDependencies() const; void languageChanged(); diff --git a/tests/auto/installer/solver/tst_solver.cpp b/tests/auto/installer/solver/tst_solver.cpp index 5829621f2..7ae502a5e 100644 --- a/tests/auto/installer/solver/tst_solver.cpp +++ b/tests/auto/installer/solver/tst_solver.cpp @@ -156,19 +156,23 @@ private slots: componentA->appendComponent(componentAB); NamedComponent *componentB = new NamedComponent(core, QLatin1String("B")); NamedComponent *componentB_NewVersion = new NamedComponent(core, QLatin1String("B_version"), QLatin1String("2.0.0")); + NamedComponent *componentB_Auto = new NamedComponent(core, QLatin1String("B_auto")); componentB->addDependency(QLatin1String("A.B")); componentAB->addDependency(QLatin1String("B_version->=2.0.0")); + componentB_Auto->addAutoDependOn(QLatin1String("B_version")); core->appendRootComponent(componentA); core->appendRootComponent(componentB); core->appendRootComponent(componentB_NewVersion); + core->appendRootComponent(componentB_Auto); QTest::newRow("Installer resolved") << core << (QList<Component *>() << componentB) - << (QList<Component *>() << componentB_NewVersion << componentAB << componentB) + << (QList<Component *>() << componentB_NewVersion << componentAB << componentB << componentB_Auto) << (QList<int>() << InstallerCalculator::Dependent << InstallerCalculator::Dependent - << InstallerCalculator::Resolved); + << InstallerCalculator::Resolved + << InstallerCalculator::Automatic); } void resolveInstaller() @@ -299,7 +303,7 @@ private slots: NamedComponent *componentA = new NamedComponent(core, QLatin1String("A")); NamedComponent *componentB = new NamedComponent(core, QLatin1String("B")); - componentB->setValue(QLatin1String("AutoDependOn"), QLatin1String("A")); + componentB->addAutoDependOn(QLatin1String("A")); componentB->setValue(QLatin1String("Default"), QLatin1String("true")); core->appendRootComponent(componentA); core->appendRootComponent(componentB); |