| 72 | } |
| 73 | |
| 74 | void UndoSystem::undo() |
| 75 | { |
| 76 | if (_undoStack.empty()) |
| 77 | { |
| 78 | rMessage() << "Undo: no undo available" << std::endl; |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | if (operationStarted()) |
| 83 | { |
| 84 | rWarning() << "Undo not available while an operation is still in progress" << std::endl; |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | const auto& operation = _undoStack.back(); |
| 89 | auto operationName = operation->getName(); // copy this name, we need it after op destruction |
| 90 | rMessage() << "Undo: " << operationName << std::endl; |
| 91 | |
| 92 | startRedo(); |
| 93 | operation->restoreSnapshot(); |
| 94 | finishRedo(operationName); |
| 95 | _undoStack.pop_back(); |
| 96 | _eventSignal.emit(EventType::OperationUndone, operationName); |
| 97 | } |
| 98 | |
| 99 | void UndoSystem::redo() |
| 100 | { |