Sat, 03 Aug 2013 04:44:30 +0300
now with changelog entry
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
4 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
9 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
14 | * |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "history.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "ldtypes.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include "file.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "misc.h" |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "gui.h" |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
24 | #include "gldraw.h" |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
26 | bool g_fullRefresh = false; |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
27 | |
411 | 28 | History::History() : |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
412
diff
changeset
|
29 | m_pos (-1), |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
412
diff
changeset
|
30 | m_opened (false) {} |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
376 | 32 | void History::undo() { |
33 | if (m_changesets.size() == 0 || pos() == -1) | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
34 | return; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
376 | 36 | const list& set = changeset (pos()); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
37 | g_fullRefresh = false; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
38 | |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
39 | // Iterate the list in reverse and undo all actions |
376 | 40 | for (const AbstractHistoryEntry * change : c_rev<AbstractHistoryEntry*> (set)) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
41 | change->undo(); |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
42 | |
376 | 43 | setPos (pos() - 1); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
44 | |
376 | 45 | if (!g_fullRefresh) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
46 | g_win->refresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
47 | else |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
48 | g_win->fullRefresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
49 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
50 | updateActions(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
376 | 53 | void History::redo() { |
54 | if (pos() == (long) m_changesets.size()) | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
55 | return; |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
376 | 57 | const list& set = changeset (pos() + 1); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
58 | g_fullRefresh = false; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
59 | |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
60 | // Redo things - in the order as they were done in the first place |
376 | 61 | for (const AbstractHistoryEntry * change : set) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
62 | change->redo(); |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
63 | |
376 | 64 | setPos (pos() + 1); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
65 | |
376 | 66 | if (!g_fullRefresh) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
67 | g_win->refresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
68 | else |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
69 | g_win->fullRefresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
70 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
71 | updateActions(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | |
376 | 74 | void History::clear() { |
402
ec95fc95e5f3
Renamed vector to List, changed it to wrap around std::deque.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
399
diff
changeset
|
75 | for (List<AbstractHistoryEntry*> set : m_changesets) |
376 | 76 | for (AbstractHistoryEntry * change : set) |
77 | delete change; | |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
79 | m_changesets.clear(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | |
376 | 82 | void History::updateActions() const { |
382
c1642530ea35
Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
83 | ACTION (Undo)->setEnabled (pos() != -1); |
c1642530ea35
Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
84 | ACTION (Redo)->setEnabled (pos() < (long) m_changesets.size() - 1); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | |
376 | 87 | void History::open() { |
88 | if (opened()) | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
89 | return; |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
90 | |
376 | 91 | setOpened (true); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
92 | } |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
93 | |
376 | 94 | void History::close() { |
95 | if (!opened()) | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
96 | return; |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
97 | |
376 | 98 | setOpened (false); |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
99 | |
376 | 100 | if (m_currentArchive.size() == 0) |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
101 | return; |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
102 | |
376 | 103 | while (pos() < size() - 1) |
104 | m_changesets.erase (size() - 1); | |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
105 | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
106 | m_changesets << m_currentArchive; |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
107 | m_currentArchive.clear(); |
376 | 108 | setPos (pos() + 1); |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
109 | updateActions(); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
110 | } |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
111 | |
376 | 112 | void History::add (AbstractHistoryEntry* entry) { |
113 | if (!opened()) { | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
114 | delete entry; |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
115 | return; |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
116 | } |
348
20134b519f90
fixed: stuff that was changed during file open was written to history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
347
diff
changeset
|
117 | |
376 | 118 | entry->setParent (this); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
119 | m_currentArchive << entry; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
120 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
121 | |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
122 | // ============================================================================= |
376 | 123 | void AddHistory::undo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
124 | LDFile* f = parent()->file(); |
376 | 125 | LDObject* obj = f->object (index()); |
126 | f->forgetObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
127 | delete obj; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
128 | |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
129 | g_fullRefresh = true; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
130 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
131 | |
376 | 132 | void AddHistory::redo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
133 | LDFile* f = parent()->file(); |
376 | 134 | LDObject* obj = parseLine (code()); |
135 | f->insertObj (index(), obj); | |
136 | g_win->R()->compileObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
137 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
138 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
139 | AddHistory::~AddHistory() {} |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
140 | |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
141 | // ============================================================================= |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
142 | // heh |
376 | 143 | void DelHistory::undo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
144 | LDFile* f = parent()->file(); |
376 | 145 | LDObject* obj = parseLine (code()); |
146 | f->insertObj (index(), obj); | |
147 | g_win->R()->compileObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
148 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
149 | |
376 | 150 | void DelHistory::redo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
151 | LDFile* f = parent()->file(); |
376 | 152 | LDObject* obj = f->object (index()); |
153 | f->forgetObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
154 | delete obj; |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
155 | |
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
156 | g_fullRefresh = true; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
157 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
158 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
159 | DelHistory::~DelHistory() {} |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
160 | |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
161 | // ============================================================================= |
376 | 162 | void EditHistory::undo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
163 | LDObject* obj = LDFile::current()->object (index()); |
376 | 164 | LDObject* newobj = parseLine (oldCode()); |
165 | obj->replace (newobj); | |
166 | g_win->R()->compileObject (newobj); | |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
167 | } |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
168 | |
376 | 169 | void EditHistory::redo() const { |
409
8da2563c645a
Renamed LDOpenFile to LDFile
Santeri Piippo <crimsondusk64@gmail.com>
parents:
402
diff
changeset
|
170 | LDObject* obj = LDFile::current()->object (index()); |
376 | 171 | LDObject* newobj = parseLine (newCode()); |
172 | obj->replace (newobj); | |
173 | g_win->R()->compileObject (newobj); | |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
174 | } |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
175 | |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
176 | EditHistory::~EditHistory() {} |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
177 | |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
178 | // ============================================================================= |
376 | 179 | void SwapHistory::undo() const { |
180 | LDObject::fromID (a)->swap (LDObject::fromID (b)); | |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
181 | } |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
182 | |
376 | 183 | void SwapHistory::redo() const { |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
184 | undo(); // :v |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
185 | } |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
186 | |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
187 | SwapHistory::~SwapHistory() {} |