PIValueTree::applyValues now can be recursive

This commit is contained in:
2023-03-21 14:55:55 +03:00
parent 0cd1206f94
commit 49f5de26eb
2 changed files with 3 additions and 2 deletions

View File

@@ -105,12 +105,13 @@ void PIValueTree::mergeAttributes(const PIVariantMap & a) {
} }
void PIValueTree::applyValues(const PIValueTree & root) { void PIValueTree::applyValues(const PIValueTree & root, bool recursive) {
if (_is_null) return; if (_is_null) return;
for (const auto & c: root._children) { for (const auto & c: root._children) {
for (auto & i: _children) { for (auto & i: _children) {
if (c.name() == i.name()) { if (c.name() == i.name()) {
i._value.setValueFromString(c.value().toString()); i._value.setValueFromString(c.value().toString());
if (recursive) i.applyValues(c, recursive);
break; break;
} }
} }

View File

@@ -88,7 +88,7 @@ public:
void setAttribute(const PIString & n, const PIVariant & a); void setAttribute(const PIString & n, const PIVariant & a);
void mergeAttributes(const PIVariantMap & a); void mergeAttributes(const PIVariantMap & a);
void applyValues(const PIValueTree & root); void applyValues(const PIValueTree & root, bool recursive = true);
const PIVector<PIValueTree> & children() const { return _children; } const PIVector<PIValueTree> & children() const { return _children; }
void clearChildren() { _children.clear(); } void clearChildren() { _children.clear(); }