Editor API
UnigineEditor public API
UnigineUndo.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/UnigineEditorGlobal.h>
6 
7 #include <QObject>
8 
9 
11 // Forward decl.
13 namespace UnigineEditor
14 {
15 class Presenter;
16 class Action;
17 }
18 
19 
20 namespace UnigineEditor
21 {
25 class UNIGINE_EDITOR_API Undo : public QObject
26 {
27  Q_OBJECT
28 public:
37  static Undo *instance();
38 
41  static void apply(Action *action);
44  static void push(Action *action);
46  static void undo();
48  static void redo();
49 
51  static void reset();
57  static void begin();
62  static void commit();
67  static void rollback();
68 
69 signals:
71  void worldModified();
73  void activity();
74 
75 private:
76  explicit Undo(QObject *parent);
77  ~Undo() override;
78 
79  friend class ::UnigineEditor::Presenter;
80 };
81 
83 class UNIGINE_EDITOR_API Action
84 {
85 public:
86  Action();
87  virtual ~Action();
89  virtual void apply() = 0;
91  virtual void undo() = 0;
93  virtual void redo() = 0;
94 
101  virtual bool validate() { return true; }
108  virtual bool modifiesWorld() const { return true; }
109 };
110 
111 } // namespace UnigineEditor
This basic class is used to represent any possible user action.
Definition: UnigineUndo.h:83
virtual bool validate()
This method allows action to do some internal cleanup. Return value indicates whether the action is s...
Definition: UnigineUndo.h:101
Undo manager class. This class is used to manage undo/redo operations for user actions in the Editor.
Definition: UnigineUndo.h:25
virtual bool modifiesWorld() const
Indicates whether the action brings any changes to the scene. Actions like selection,...
Definition: UnigineUndo.h:108