Editor API
UnigineEditor public API
Undo.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <editor/EditorGlobal.h>
6 
7 #include <QObject>
8 
9 
11 // Forward decl.
13 namespace Editor
14 {
15 class Presenter;
16 class Action;
17 }
18 
19 
20 namespace Editor
21 {
25 class 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 Editor::Presenter;
80 };
81 
83 class 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 
112 } // namespace Editor
virtual bool modifiesWorld() const
Indicates whether the action brings any changes to the scene. Actions like selection,...
Definition: Undo.h:108
Undo manager class. This class is used to manage undo/redo operations for user actions in the Editor.
Definition: Undo.h:25
This basic class is used to represent any possible user action.
Definition: Undo.h:83
virtual bool validate()
This method allows action to do some internal cleanup. Return value indicates whether the action is s...
Definition: Undo.h:101