src/history.cc

changeset 594
d9feccafcbf7
parent 563
10939452bf86
child 600
209e3f1f7b2c
equal deleted inserted replaced
593:108d7d21e155 594:d9feccafcbf7
21 #include "document.h" 21 #include "document.h"
22 #include "misc.h" 22 #include "misc.h"
23 #include "gui.h" 23 #include "gui.h"
24 #include "gldraw.h" 24 #include "gldraw.h"
25 25
26 bool g_fullRefresh = false;
27
28 // ============================================================================= 26 // =============================================================================
29 // ----------------------------------------------------------------------------- 27 // -----------------------------------------------------------------------------
30 History::History() : 28 History::History() :
31 m_Position (-1) {} 29 m_Position (-1) {}
32 30
38 36
39 // Don't take the changes done here as actual edits to the document 37 // Don't take the changes done here as actual edits to the document
40 setIgnoring (true); 38 setIgnoring (true);
41 39
42 const Changeset& set = getChangeset (getPosition()); 40 const Changeset& set = getChangeset (getPosition());
43 g_fullRefresh = false;
44 41
45 // Iterate the list in reverse and undo all actions 42 // Iterate the list in reverse and undo all actions
46 for (int i = set.size() - 1; i >= 0; --i) 43 for (int i = set.size() - 1; i >= 0; --i)
47 { AbstractHistoryEntry* change = set[i]; 44 { AbstractHistoryEntry* change = set[i];
48 change->undo(); 45 change->undo();
49 } 46 }
50 47
51 decreasePosition(); 48 decreasePosition();
52 49 g_win->refresh();
53 if (!g_fullRefresh)
54 g_win->refresh();
55 else
56 g_win->doFullRefresh();
57
58 g_win->updateActions(); 50 g_win->updateActions();
59 dlog ("Position is now %1", getPosition()); 51 dlog ("Position is now %1", getPosition());
60 setIgnoring (false); 52 setIgnoring (false);
61 } 53 }
62 54
66 { if (getPosition() == m_changesets.size()) 58 { if (getPosition() == m_changesets.size())
67 return; 59 return;
68 60
69 setIgnoring (true); 61 setIgnoring (true);
70 const Changeset& set = getChangeset (getPosition() + 1); 62 const Changeset& set = getChangeset (getPosition() + 1);
71 g_fullRefresh = false;
72 63
73 // Redo things - in the order as they were done in the first place 64 // Redo things - in the order as they were done in the first place
74 for (const AbstractHistoryEntry* change : set) 65 for (const AbstractHistoryEntry* change : set)
75 change->redo(); 66 change->redo();
76 67
77 setPosition (getPosition() + 1); 68 setPosition (getPosition() + 1);
78 69 g_win->refresh();
79 if (!g_fullRefresh)
80 g_win->refresh();
81 else
82 g_win->doFullRefresh();
83
84 g_win->updateActions(); 70 g_win->updateActions();
85 dlog ("Position is now %1", getPosition()); 71 dlog ("Position is now %1", getPosition());
86 setIgnoring (false); 72 setIgnoring (false);
87 } 73 }
88 74
135 // ============================================================================= 121 // =============================================================================
136 // ----------------------------------------------------------------------------- 122 // -----------------------------------------------------------------------------
137 void AddHistory::undo() const 123 void AddHistory::undo() const
138 { LDObject* obj = getParent()->getFile()->getObject (getIndex()); 124 { LDObject* obj = getParent()->getFile()->getObject (getIndex());
139 obj->deleteSelf(); 125 obj->deleteSelf();
140 g_fullRefresh = true;
141 } 126 }
142 127
143 // ============================================================================= 128 // =============================================================================
144 // ----------------------------------------------------------------------------- 129 // -----------------------------------------------------------------------------
145 void AddHistory::redo() const 130 void AddHistory::redo() const
166 // ============================================================================= 151 // =============================================================================
167 // ----------------------------------------------------------------------------- 152 // -----------------------------------------------------------------------------
168 void DelHistory::redo() const 153 void DelHistory::redo() const
169 { LDObject* obj = getParent()->getFile()->getObject (getIndex()); 154 { LDObject* obj = getParent()->getFile()->getObject (getIndex());
170 obj->deleteSelf(); 155 obj->deleteSelf();
171 g_fullRefresh = true;
172 } 156 }
173 157
174 // ============================================================================= 158 // =============================================================================
175 // ----------------------------------------------------------------------------- 159 // -----------------------------------------------------------------------------
176 void EditHistory::undo() const 160 void EditHistory::undo() const

mercurial