Tome
A generic data editor for games supporting arbitrary input and output formats.
undocontroller.h
1 #ifndef UNDOCONTROLLER_H
2 #define UNDOCONTROLLER_H
3 
4 #include <QUndoCommand>
5 #include <QUndoStack>
6 
7 
8 namespace Tome
9 {
13  class UndoController : public QObject
14  {
15  Q_OBJECT
16 
17  public:
22 
26  void clear();
27 
34  QAction* createRedoAction(QObject* parent, const QString& prefix);
35 
42  QAction* createUndoAction(QObject* parent, const QString& prefix);
43 
48  void doCommand(QUndoCommand* command);
49 
54  bool isClean() const;
55 
59  void setClean();
60 
61  signals:
66  void undoStackChanged(bool clean);
67 
68  private slots:
69  void onCleanChanged(bool clean);
70 
71  private:
72  QUndoStack* undoStack;
73  };
74 }
75 
76 #endif // UNDOCONTROLLER_H
Definition: commandlineoptions.h:6
void undoStackChanged(bool clean)
Undo stack has become dirty or clean.
bool isClean() const
Whether any commands have been applied since the project was opened or saved.
Definition: undocontroller.cpp:34
UndoController()
Constructs a new controller for performing undo-able commands.
Definition: undocontroller.cpp:6
Controller for performing undo-able commands.
Definition: undocontroller.h:13
QAction * createRedoAction(QObject *parent, const QString &prefix)
Creates an action for re-doing the most recently undone command.
Definition: undocontroller.cpp:19
void doCommand(QUndoCommand *command)
Applies the passed command, pushing it to the undo stack.
Definition: undocontroller.cpp:29
void setClean()
Marks the undo stack as clean, as if no commands have been applied since the project was opened or sa...
Definition: undocontroller.cpp:39
void clear()
Removes all recent undo-able commands from the undo stack.
Definition: undocontroller.cpp:14
QAction * createUndoAction(QObject *parent, const QString &prefix)
Creates an action for un-doing the most recent command.
Definition: undocontroller.cpp:24