mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 13:53:55 +00:00
30 lines
582 B
C++
30 lines
582 B
C++
|
|
||
|
#include "commandmacro.hpp"
|
||
|
|
||
|
#include <QUndoCommand>
|
||
|
#include <QUndoStack>
|
||
|
|
||
|
CSMWorld::CommandMacro::CommandMacro(QUndoStack& undoStack, const QString& description)
|
||
|
: mUndoStack(undoStack)
|
||
|
, mDescription(description)
|
||
|
, mStarted(false)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
CSMWorld::CommandMacro::~CommandMacro()
|
||
|
{
|
||
|
if (mStarted)
|
||
|
mUndoStack.endMacro();
|
||
|
}
|
||
|
|
||
|
void CSMWorld::CommandMacro::push(QUndoCommand* command)
|
||
|
{
|
||
|
if (!mStarted)
|
||
|
{
|
||
|
mUndoStack.beginMacro(mDescription.isEmpty() ? command->text() : mDescription);
|
||
|
mStarted = true;
|
||
|
}
|
||
|
|
||
|
mUndoStack.push(command);
|
||
|
}
|