1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 18:53:54 +00:00
openmw/apps/opencs/model/world/commandmacro.cpp

30 lines
582 B
C++
Raw Normal View History

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
}