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 { |
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 |