125 m_currentChangeset << entry; |
125 m_currentChangeset << entry; |
126 dlog ("History: added entry of type %1", entry->getTypeName()); |
126 dlog ("History: added entry of type %1", entry->getTypeName()); |
127 } |
127 } |
128 |
128 |
129 // ============================================================================= |
129 // ============================================================================= |
130 // ----------------------------------------------------------------------------- |
130 // |
131 void AddHistory::undo() const |
131 void AddHistory::undo() const |
132 { |
132 { |
133 LDObject* obj = getParent()->getFile()->getObject (getIndex()); |
133 LDObject* obj = getParent()->getDocument()->getObject (getIndex()); |
134 obj->deleteSelf(); |
134 obj->deleteSelf(); |
135 } |
135 } |
136 |
136 |
137 // ============================================================================= |
137 // ============================================================================= |
138 // ----------------------------------------------------------------------------- |
138 // |
139 void AddHistory::redo() const |
139 void AddHistory::redo() const |
140 { |
140 { |
141 LDObject* obj = parseLine (getCode()); |
141 LDObject* obj = parseLine (getCode()); |
142 getParent()->getFile()->insertObj (getIndex(), obj); |
142 getParent()->getDocument()->insertObj (getIndex(), obj); |
143 g_win->R()->compileObject (obj); |
143 g_win->R()->compileObject (obj); |
144 } |
144 } |
145 |
145 |
146 // ============================================================================= |
146 // ============================================================================= |
147 // ----------------------------------------------------------------------------- |
147 // |
148 DelHistory::DelHistory (int idx, LDObject* obj) : |
148 DelHistory::DelHistory (int idx, LDObject* obj) : |
149 m_Index (idx), |
149 m_Index (idx), |
150 m_Code (obj->raw()) {} |
150 m_Code (obj->raw()) {} |
151 |
151 |
152 // ============================================================================= |
152 // ============================================================================= |
153 // heh |
153 // heh |
154 // ----------------------------------------------------------------------------- |
154 // |
155 void DelHistory::undo() const |
155 void DelHistory::undo() const |
156 { |
156 { |
157 LDObject* obj = parseLine (getCode()); |
157 LDObject* obj = parseLine (getCode()); |
158 getParent()->getFile()->insertObj (getIndex(), obj); |
158 getParent()->getDocument()->insertObj (getIndex(), obj); |
159 g_win->R()->compileObject (obj); |
159 g_win->R()->compileObject (obj); |
160 } |
160 } |
161 |
161 |
162 // ============================================================================= |
162 // ============================================================================= |
163 // ----------------------------------------------------------------------------- |
163 // |
164 void DelHistory::redo() const |
164 void DelHistory::redo() const |
165 { |
165 { |
166 LDObject* obj = getParent()->getFile()->getObject (getIndex()); |
166 LDObject* obj = getParent()->getDocument()->getObject (getIndex()); |
167 obj->deleteSelf(); |
167 obj->deleteSelf(); |
168 } |
168 } |
169 |
169 |
170 // ============================================================================= |
170 // ============================================================================= |
171 // ----------------------------------------------------------------------------- |
171 // |
172 void EditHistory::undo() const |
172 void EditHistory::undo() const |
173 { |
173 { |
174 LDObject* obj = getCurrentDocument()->getObject (getIndex()); |
174 LDObject* obj = getCurrentDocument()->getObject (getIndex()); |
175 LDObject* newobj = parseLine (getOldCode()); |
175 LDObject* newobj = parseLine (getOldCode()); |
176 obj->replace (newobj); |
176 obj->replace (newobj); |
177 g_win->R()->compileObject (newobj); |
177 g_win->R()->compileObject (newobj); |
178 } |
178 } |
179 |
179 |
180 // ============================================================================= |
180 // ============================================================================= |
181 // ----------------------------------------------------------------------------- |
181 // |
182 void EditHistory::redo() const |
182 void EditHistory::redo() const |
183 { |
183 { |
184 LDObject* obj = getCurrentDocument()->getObject (getIndex()); |
184 LDObject* obj = getCurrentDocument()->getObject (getIndex()); |
185 LDObject* newobj = parseLine (getNewCode()); |
185 LDObject* newobj = parseLine (getNewCode()); |
186 obj->replace (newobj); |
186 obj->replace (newobj); |
187 g_win->R()->compileObject (newobj); |
187 g_win->R()->compileObject (newobj); |
188 } |
188 } |
189 |
189 |
190 // ============================================================================= |
190 // ============================================================================= |
191 // ----------------------------------------------------------------------------- |
191 // |
192 void SwapHistory::undo() const |
192 void SwapHistory::undo() const |
193 { |
193 { |
194 LDObject::fromID (a)->swap (LDObject::fromID (b)); |
194 LDObject::fromID (a)->swap (LDObject::fromID (b)); |
195 } |
195 } |
196 |
196 |
|
197 // ============================================================================= |
|
198 // |
197 void SwapHistory::redo() const |
199 void SwapHistory::redo() const |
198 { |
200 { |
199 undo(); // :v |
201 undo(); |
200 } |
202 } |