diff --git a/src/core/operationstack.cpp b/src/core/operationstack.cpp index b1a6d9d..258f62d 100644 --- a/src/core/operationstack.cpp +++ b/src/core/operationstack.cpp @@ -449,6 +449,22 @@ void OperationStack::pop() emit operationsChanged(); } +/** Check whether previous operations involve given partition. + + @param p Pointer to the Partition. Must not be nullptr. +*/ +bool OperationStack::contains(const Partition* p) const +{ + Q_ASSERT(p); + + foreach(Operation * o, operations()) { + if (o->targets(*p)) + return true; + } + + return false; +} + /** Removes all Operations from the OperationStack, calling Operation::undo() on them and deleting them. */ void OperationStack::clearOperations() { diff --git a/src/core/operationstack.h b/src/core/operationstack.h index f83d457..b6fbfac 100644 --- a/src/core/operationstack.h +++ b/src/core/operationstack.h @@ -61,6 +61,7 @@ Q_SIGNALS: public: void push(Operation* o); void pop(); + bool contains(const Partition* p) const; void clearOperations(); int size() const { return operations().size(); /**< @return number of operations */