2016-03-08 09:48:44 +00:00
|
|
|
|
|
|
|
#include "commandmacro.hpp"
|
|
|
|
|
|
|
|
#include <QUndoCommand>
|
2022-09-22 18:26:05 +00:00
|
|
|
#include <QUndoStack>
|
2016-03-08 09:48:44 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
CSMWorld::CommandMacro::CommandMacro(QUndoStack& undoStack, const QString& description)
|
|
|
|
: mUndoStack(undoStack)
|
|
|
|
, mDescription(description)
|
|
|
|
, mStarted(false)
|
|
|
|
{
|
|
|
|
}
|
2016-03-08 09:48:44 +00:00
|
|
|
|
|
|
|
CSMWorld::CommandMacro::~CommandMacro()
|
|
|
|
{
|
|
|
|
if (mStarted)
|
|
|
|
mUndoStack.endMacro();
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
void CSMWorld::CommandMacro::push(QUndoCommand* command)
|
2016-03-08 09:48:44 +00:00
|
|
|
{
|
|
|
|
if (!mStarted)
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
mUndoStack.beginMacro(mDescription.isEmpty() ? command->text() : mDescription);
|
2016-03-08 09:48:44 +00:00
|
|
|
mStarted = true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
mUndoStack.push(command);
|
2016-03-08 09:48:44 +00:00
|
|
|
}
|