Utils: Make AspectContainer::setAutoApply sticky

So it applies to all subsequently registered subaspects.

Change-Id: I9cc215b6ed9637eefc3b1721db778d4097809faa
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-03-17 06:59:57 +01:00
parent a388769c00
commit bc3f8e9810

View File

@@ -2009,6 +2009,7 @@ class AspectContainerPrivate
{ {
public: public:
QList<BaseAspect *> m_items; // Not owned QList<BaseAspect *> m_items; // Not owned
bool m_autoApply = true;
}; };
} // Internal } // Internal
@@ -2027,13 +2028,14 @@ AspectContainer::~AspectContainer() = default;
*/ */
void AspectContainer::registerAspect(BaseAspect *aspect) void AspectContainer::registerAspect(BaseAspect *aspect)
{ {
aspect->setAutoApply(d->m_autoApply);
d->m_items.append(aspect); d->m_items.append(aspect);
} }
void AspectContainer::registerAspects(const AspectContainer &aspects) void AspectContainer::registerAspects(const AspectContainer &aspects)
{ {
for (BaseAspect *aspect : qAsConst(aspects.d->m_items)) for (BaseAspect *aspect : qAsConst(aspects.d->m_items))
d->m_items.append(aspect); registerAspect(aspect);
} }
void AspectContainer::fromMap(const QVariantMap &map) void AspectContainer::fromMap(const QVariantMap &map)
@@ -2086,6 +2088,7 @@ void AspectContainer::reset()
void AspectContainer::setAutoApply(bool on) void AspectContainer::setAutoApply(bool on)
{ {
d->m_autoApply = on;
for (BaseAspect *aspect : qAsConst(d->m_items)) for (BaseAspect *aspect : qAsConst(d->m_items))
aspect->setAutoApply(on); aspect->setAutoApply(on);
} }