35 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
36 void History::undo() |
36 void History::undo() |
37 { if (m_changesets.isEmpty() || pos() == -1) |
37 { if (m_changesets.isEmpty() || pos() == -1) |
38 return; |
38 return; |
39 |
39 |
40 const Changeset& set = changeset (pos()); |
40 const Changeset& set = getChangeset (pos()); |
41 g_fullRefresh = false; |
41 g_fullRefresh = false; |
42 |
42 |
43 // Iterate the list in reverse and undo all actions |
43 // Iterate the list in reverse and undo all actions |
44 for (auto it = set.end() - 1; it != set.begin(); --it) |
44 for (auto it = set.end() - 1; it != set.begin(); --it) |
45 (*it)->undo(); |
45 (*it)->undo(); |
47 setPos (pos() - 1); |
47 setPos (pos() - 1); |
48 |
48 |
49 if (!g_fullRefresh) |
49 if (!g_fullRefresh) |
50 g_win->refresh(); |
50 g_win->refresh(); |
51 else |
51 else |
52 g_win->fullRefresh(); |
52 g_win->doFullRefresh(); |
53 |
53 |
54 updateActions(); |
54 updateActions(); |
55 } |
55 } |
56 |
56 |
57 // ============================================================================= |
57 // ============================================================================= |
58 // ----------------------------------------------------------------------------- |
58 // ----------------------------------------------------------------------------- |
59 void History::redo() |
59 void History::redo() |
60 { if (pos() == (long) m_changesets.size()) |
60 { if (pos() == (long) m_changesets.size()) |
61 return; |
61 return; |
62 |
62 |
63 const Changeset& set = changeset (pos() + 1); |
63 const Changeset& set = getChangeset (pos() + 1); |
64 g_fullRefresh = false; |
64 g_fullRefresh = false; |
65 |
65 |
66 // Redo things - in the order as they were done in the first place |
66 // Redo things - in the order as they were done in the first place |
67 for (const AbstractHistoryEntry* change : set) |
67 for (const AbstractHistoryEntry* change : set) |
68 change->redo(); |
68 change->redo(); |
112 setOpened (false); |
112 setOpened (false); |
113 |
113 |
114 if (m_currentArchive.isEmpty()) |
114 if (m_currentArchive.isEmpty()) |
115 return; |
115 return; |
116 |
116 |
117 while (pos() < size() - 1) |
117 while (pos() < getSize() - 1) |
118 m_changesets.removeLast(); |
118 m_changesets.removeLast(); |
119 |
119 |
120 m_changesets << m_currentArchive; |
120 m_changesets << m_currentArchive; |
121 m_currentArchive.clear(); |
121 m_currentArchive.clear(); |
122 setPos (pos() + 1); |
122 setPos (pos() + 1); |
137 |
137 |
138 // ============================================================================= |
138 // ============================================================================= |
139 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
140 void AddHistory::undo() const |
140 void AddHistory::undo() const |
141 { LDFile* f = parent()->file(); |
141 { LDFile* f = parent()->file(); |
142 LDObject* obj = f->object (index()); |
142 LDObject* obj = f->getObject (index()); |
143 f->forgetObject (obj); |
143 f->forgetObject (obj); |
144 delete obj; |
144 delete obj; |
145 |
145 |
146 g_fullRefresh = true; |
146 g_fullRefresh = true; |
147 } |
147 } |
169 |
169 |
170 // ============================================================================= |
170 // ============================================================================= |
171 // ----------------------------------------------------------------------------- |
171 // ----------------------------------------------------------------------------- |
172 void DelHistory::redo() const |
172 void DelHistory::redo() const |
173 { LDFile* f = parent()->file(); |
173 { LDFile* f = parent()->file(); |
174 LDObject* obj = f->object (index()); |
174 LDObject* obj = f->getObject (index()); |
175 f->forgetObject (obj); |
175 f->forgetObject (obj); |
176 delete obj; |
176 delete obj; |
177 |
177 |
178 g_fullRefresh = true; |
178 g_fullRefresh = true; |
179 } |
179 } |
181 DelHistory::~DelHistory() {} |
181 DelHistory::~DelHistory() {} |
182 |
182 |
183 // ============================================================================= |
183 // ============================================================================= |
184 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
185 void EditHistory::undo() const |
185 void EditHistory::undo() const |
186 { LDObject* obj = LDFile::current()->object (index()); |
186 { LDObject* obj = LDFile::current()->getObject (index()); |
187 LDObject* newobj = parseLine (oldCode()); |
187 LDObject* newobj = parseLine (oldCode()); |
188 obj->replace (newobj); |
188 obj->replace (newobj); |
189 g_win->R()->compileObject (newobj); |
189 g_win->R()->compileObject (newobj); |
190 } |
190 } |
191 |
191 |
192 // ============================================================================= |
192 // ============================================================================= |
193 // ----------------------------------------------------------------------------- |
193 // ----------------------------------------------------------------------------- |
194 void EditHistory::redo() const |
194 void EditHistory::redo() const |
195 { LDObject* obj = LDFile::current()->object (index()); |
195 { LDObject* obj = LDFile::current()->getObject (index()); |
196 LDObject* newobj = parseLine (newCode()); |
196 LDObject* newobj = parseLine (newCode()); |
197 obj->replace (newobj); |
197 obj->replace (newobj); |
198 g_win->R()->compileObject (newobj); |
198 g_win->R()->compileObject (newobj); |
199 } |
199 } |
200 |
200 |