From 063c50aec608be430d868a451677c07d567d117d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 18 May 2016 14:56:13 +0100 Subject: [PATCH] Add a method to check whether partition is part of operationStack. --- src/core/operationstack.cpp | 16 ++++++++++++++++ src/core/operationstack.h | 1 + 2 files changed, 17 insertions(+) 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 */