Files
BionxControl/nodes/services/ntxundostack.h

56 lines
1.0 KiB
C
Raw Permalink Normal View History

2026-04-02 15:15:28 +02:00
#ifndef NTX_UNDO_STACK_H
#define NTX_UNDO_STACK_H
#include <ntxicommand.h>
#include <vector>
#include <functional>
namespace ntx
{
class NtxUndoStack
{
public:
NtxUndoStack();
~NtxUndoStack() = default;
NtxUndoStack(const NtxUndoStack&) = delete;
NtxUndoStack& operator=(const NtxUndoStack&) = delete;
void push(NtxCommandUPtr command);
bool canUndo() const;
bool canRedo() const;
void undo();
void redo();
int index() const;
int count() const;
NtxString undoText() const;
NtxString redoText() const;
void clear();
void setClean();
bool isClean() const;
void setUndoLimit(int limit);
int undoLimit() const;
const NtxICommand* command(int index) const;
private:
std::vector<NtxCommandUPtr> m_commands;
int m_index;
int m_cleanIndex;
int m_undoLimit;
void checkUndoLimit();
};
} // namespace ntx
#endif // NTX_UNDO_STACK_H