src/history.h

changeset 362
344fe1da32c8
parent 274
d232fe4d88a6
child 367
3745caa5d87d
equal deleted inserted replaced
361:f4c029f2a75b 362:344fe1da32c8
21 21
22 #include "common.h" 22 #include "common.h"
23 #include "ldtypes.h" 23 #include "ldtypes.h"
24 24
25 #define IMPLEMENT_HISTORY_TYPE(N) \ 25 #define IMPLEMENT_HISTORY_TYPE(N) \
26 virtual ~N##History (); \ 26 virtual ~N##History(); \
27 virtual void undo () const; \ 27 virtual void undo() const; \
28 virtual void redo () const; \ 28 virtual void redo() const; \
29 virtual History::Type type () { return History::N; } 29 virtual History::Type type() { return History::N; }
30 30
31 class AbstractHistoryEntry; 31 class AbstractHistoryEntry;
32 32
33 // ============================================================================= 33 // =============================================================================
34 class History { 34 class History {
40 typedef vector<AbstractHistoryEntry*> list; 40 typedef vector<AbstractHistoryEntry*> list;
41 41
42 enum Type { 42 enum Type {
43 Del, 43 Del,
44 Edit, 44 Edit,
45 ListMove,
46 Add, 45 Add,
47 Move, 46 Move,
47 Swap,
48 }; 48 };
49 49
50 History (); 50 History ();
51 void undo (); 51 void undo ();
52 void redo (); 52 void redo ();
122 }; 122 };
123 123
124 // ============================================================================= 124 // =============================================================================
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
126 // ============================================================================= 126 // =============================================================================
127 class ListMoveHistory : public AbstractHistoryEntry {
128 public:
129 IMPLEMENT_HISTORY_TYPE (ListMove)
130
131 vector<ulong> idxs;
132 long dest;
133
134 ListMoveHistory (vector<ulong> idxs, long dest) :
135 idxs (idxs), dest (dest) {}
136 };
137
138 // =============================================================================
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
140 // =============================================================================
141 class AddHistory : public AbstractHistoryEntry { 127 class AddHistory : public AbstractHistoryEntry {
142 public: 128 public:
143 enum Type { 129 enum Type {
144 Other, // was "just added" 130 Other, // was "just added"
145 Paste, // was added through a paste operation 131 Paste, // was added through a paste operation
168 154
169 MoveHistory (vector<ulong> indices, vertex dest) : 155 MoveHistory (vector<ulong> indices, vertex dest) :
170 indices (indices), dest (dest) {} 156 indices (indices), dest (dest) {}
171 }; 157 };
172 158
159 class SwapHistory : public AbstractHistoryEntry
160 {
161 public:
162 IMPLEMENT_HISTORY_TYPE( Swap )
163 ulong a, b;
164
165 SwapHistory( ulong a, ulong b ) : a( a ), b( b ) {}
166 };
167
173 #endif // HISTORY_H 168 #endif // HISTORY_H

mercurial