Add a method to check whether partition is part of operationStack.

This commit is contained in:
Andrius Štikonas 2016-05-18 14:56:13 +01:00
parent ffa24e4451
commit 063c50aec6
2 changed files with 17 additions and 0 deletions

View File

@ -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()
{

View File

@ -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 */