Editor API
UnigineEditor public API
Undo.h
1 // Copyright (C), UNIGINE. All rights reserved.
2 #pragma once
3 
4 
5 #include <EditorGlobal.h>
6 #include <QObject>
7 
8 
10 // Forward decl.
12 namespace Editor
13 {
14 class Presenter;
15 class Action;
16 }
17 
18 
19 namespace Editor
20 {
24 class EDITOR_API Undo : public QObject
25 {
26  Q_OBJECT
27 public:
36  static Undo *instance();
37 
40  static void apply(Action *action);
43  static void push(Action *action);
45  static void undo();
47  static void redo();
48 
50  static void reset();
56  static void begin();
61  static void commit();
66  static void rollback();
67 
68 signals:
70  void worldModified();
72  void activity();
73 
74 private:
75  explicit Undo(QObject *parent);
76  ~Undo() override;
77 
78  friend class Editor::Presenter;
79 };
80 
82 class EDITOR_API Action
83 {
84 public:
85  Action();
86  virtual ~Action();
88  virtual void apply() = 0;
90  virtual void undo() = 0;
92  virtual void redo() = 0;
93 
100  virtual bool validate() { return true; }
107  virtual bool modifiesWorld() const { return true; }
108 };
109 
110 
111 } // namespace Editor
Definition: Actions.h:9
virtual bool modifiesWorld() const
Indicates whether the action brings any changes to the scene. Actions like selection,...
Definition: Undo.h:107
Undo manager class. This class is used to manage undo/redo operations for user actions in the Editor.
Definition: Undo.h:24
This basic class is used to represent any possible user action.
Definition: Undo.h:82
virtual bool validate()
This method allows action to do some internal cleanup. Return value indicates whether the action is s...
Definition: Undo.h:100