Utils: Add AspectList::clear()

Change-Id: Ic3e90bc76d271c1bb3b84e545fae5ba1c7a10468
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-09-26 09:57:35 +02:00
parent 873a719174
commit 61048fa737
2 changed files with 16 additions and 0 deletions

View File

@@ -3154,6 +3154,21 @@ void AspectList::removeItem(const std::shared_ptr<BaseAspect> &item)
actualRemoveItem(item);
}
void AspectList::clear()
{
if (undoStack()) {
undoStack()->beginMacro("Clear");
for (auto item : volatileItems())
undoStack()->push(new RemoveItemCommand(this, item));
undoStack()->endMacro();
} else {
for (auto item : volatileItems())
actualRemoveItem(item);
}
}
void AspectList::apply()
{
d->items = d->volatileItems;

View File

@@ -1031,6 +1031,7 @@ public:
void removeItem(const std::shared_ptr<BaseAspect> &item);
void actualRemoveItem(const std::shared_ptr<BaseAspect> &item);
void clear();
void apply() override;