Mon, 13 Jan 2014 10:07:39 +0200
- refactoring
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
600
209e3f1f7b2c
- updated copyright year. Best wishes for 2014!
Santeri Piippo <crimsondusk64@gmail.com>
parents:
594
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "history.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "ldtypes.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "document.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "misc.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "gui.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "gldraw.h" |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | // ============================================================================= |
622 | 27 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | History::History() : |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | m_Position (-1) {} |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | // ============================================================================= |
622 | 32 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | void History::undo() |
603 | 34 | { |
35 | if (m_changesets.isEmpty() || getPosition() == -1) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
563
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
38 | // Don't take the changes done here as actual edits to the document |
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
39 | setIgnoring (true); |
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
40 | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | const Changeset& set = getChangeset (getPosition()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | // Iterate the list in reverse and undo all actions |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
44 | for (int i = set.size() - 1; i >= 0; --i) |
603 | 45 | { |
46 | AbstractHistoryEntry* change = set[i]; | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
47 | change->undo(); |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
48 | } |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | decreasePosition(); |
594
d9feccafcbf7
- removed some unnecessary full refreshes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
563
diff
changeset
|
51 | g_win->refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | g_win->updateActions(); |
561
1d90296ad3fc
History should now behave properly..
Santeri Piippo <crimsondusk64@gmail.com>
parents:
560
diff
changeset
|
53 | dlog ("Position is now %1", getPosition()); |
563
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
54 | setIgnoring (false); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | // ============================================================================= |
622 | 58 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | void History::redo() |
603 | 60 | { |
61 | if (getPosition() == m_changesets.size()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | |
563
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
64 | setIgnoring (true); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | const Changeset& set = getChangeset (getPosition() + 1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | // Redo things - in the order as they were done in the first place |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | for (const AbstractHistoryEntry* change : set) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | change->redo(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | setPosition (getPosition() + 1); |
594
d9feccafcbf7
- removed some unnecessary full refreshes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
563
diff
changeset
|
72 | g_win->refresh(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | g_win->updateActions(); |
562
c4ff45e98551
- fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents:
561
diff
changeset
|
74 | dlog ("Position is now %1", getPosition()); |
563
10939452bf86
- made history ignore file loading and undo/redo calls instead of having hard-coded ignore on the actions, this will probably save a lot of hair
Santeri Piippo <crimsondusk64@gmail.com>
parents:
562
diff
changeset
|
75 | setIgnoring (false); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | // ============================================================================= |
622 | 79 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | void History::clear() |
603 | 81 | { |
82 | for (Changeset set : m_changesets) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | for (AbstractHistoryEntry* change : set) |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | delete change; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | m_changesets.clear(); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
87 | dlog ("History: cleared"); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | // ============================================================================= |
622 | 91 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | void History::addStep() |
603 | 93 | { |
94 | if (m_currentChangeset.isEmpty()) | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | while (getPosition() < getSize() - 1) |
603 | 98 | { |
99 | Changeset last = m_changesets.last(); | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
100 | |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
101 | for (AbstractHistoryEntry* entry : last) |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
102 | delete entry; |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
103 | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | m_changesets.removeLast(); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
105 | } |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
107 | dlog ("History: step added (%1 changes)", m_currentChangeset.size()); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | m_changesets << m_currentChangeset; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | m_currentChangeset.clear(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | setPosition (getPosition() + 1); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | g_win->updateActions(); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | // ============================================================================= |
622 | 115 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | void History::add (AbstractHistoryEntry* entry) |
603 | 117 | { |
118 | if (isIgnoring()) | |
119 | { | |
120 | delete entry; | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | return; |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | entry->setParent (this); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | m_currentChangeset << entry; |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
126 | dlog ("History: added entry of type %1", entry->getTypeName()); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | // ============================================================================= |
622 | 130 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | void AddHistory::undo() const |
603 | 132 | { |
622 | 133 | LDObject* obj = getParent()->getDocument()->getObject (getIndex()); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
134 | obj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | // ============================================================================= |
622 | 138 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | void AddHistory::redo() const |
603 | 140 | { |
141 | LDObject* obj = parseLine (getCode()); | |
622 | 142 | getParent()->getDocument()->insertObj (getIndex(), obj); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | g_win->R()->compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | // ============================================================================= |
622 | 147 | // |
562
c4ff45e98551
- fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents:
561
diff
changeset
|
148 | DelHistory::DelHistory (int idx, LDObject* obj) : |
c4ff45e98551
- fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents:
561
diff
changeset
|
149 | m_Index (idx), |
c4ff45e98551
- fixed: LDObject methods still used operator delete directly, causing *a very frustrating* crash to debug
Santeri Piippo <crimsondusk64@gmail.com>
parents:
561
diff
changeset
|
150 | m_Code (obj->raw()) {} |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
151 | |
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
152 | // ============================================================================= |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | // heh |
622 | 154 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
155 | void DelHistory::undo() const |
603 | 156 | { |
157 | LDObject* obj = parseLine (getCode()); | |
622 | 158 | getParent()->getDocument()->insertObj (getIndex(), obj); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | g_win->R()->compileObject (obj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | // ============================================================================= |
622 | 163 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | void DelHistory::redo() const |
603 | 165 | { |
622 | 166 | LDObject* obj = getParent()->getDocument()->getObject (getIndex()); |
560
39085791128f
- corrected history behavior. LDObject::clone() is now off-limits, createCopy() must be used instead. LDObject::deleteSelf() must be used to delete LDObjects (destructor is protected now)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
557
diff
changeset
|
167 | obj->deleteSelf(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | // ============================================================================= |
622 | 171 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | void EditHistory::undo() const |
603 | 173 | { |
174 | LDObject* obj = getCurrentDocument()->getObject (getIndex()); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | LDObject* newobj = parseLine (getOldCode()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | obj->replace (newobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | g_win->R()->compileObject (newobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | // ============================================================================= |
622 | 181 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | void EditHistory::redo() const |
603 | 183 | { |
184 | LDObject* obj = getCurrentDocument()->getObject (getIndex()); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | LDObject* newobj = parseLine (getNewCode()); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | obj->replace (newobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | g_win->R()->compileObject (newobj); |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | // ============================================================================= |
622 | 191 | // |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | void SwapHistory::undo() const |
603 | 193 | { |
194 | LDObject::fromID (a)->swap (LDObject::fromID (b)); | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | } |
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | |
622 | 197 | // ============================================================================= |
198 | // | |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | void SwapHistory::redo() const |
603 | 200 | { |
622 | 201 | undo(); |
557
04e140bdeb0b
- changed source file extension from .cpp to .cc
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | } |