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