Sat, 05 Oct 2013 12:51:13 +0300
a bit more cleanup
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 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
28 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
29 | // ----------------------------------------------------------------------------- |
411 | 30 | History::History() : |
421
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
412
diff
changeset
|
31 | m_pos (-1), |
7d26db0be944
style cleanup - it should be all unified now
Santeri Piippo <crimsondusk64@gmail.com>
parents:
412
diff
changeset
|
32 | m_opened (false) {} |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
34 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
35 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
36 | void History::undo() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
37 | { 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
|
38 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
39 | |
497
c51941e590b6
a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
40 | const Changeset& set = changeset (pos()); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
41 | g_fullRefresh = false; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
42 | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
43 | // Iterate the list in reverse and undo all actions |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
44 | for (const AbstractHistoryEntry* change : c_rev<AbstractHistoryEntry*> (set)) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
45 | change->undo(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
46 | |
376 | 47 | setPos (pos() - 1); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
48 | |
376 | 49 | if (!g_fullRefresh) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
50 | g_win->refresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
51 | else |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
52 | g_win->fullRefresh(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
53 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
54 | updateActions(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
57 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
58 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
59 | void History::redo() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
60 | { 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
|
61 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
62 | |
497
c51941e590b6
a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
63 | const Changeset& set = changeset (pos() + 1); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
64 | g_fullRefresh = false; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
65 | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
66 | // Redo things - in the order as they were done in the first place |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
67 | for (const AbstractHistoryEntry* change : set) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
68 | change->redo(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
69 | |
376 | 70 | setPos (pos() + 1); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
71 | |
376 | 72 | if (!g_fullRefresh) |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
73 | g_win->refresh(); |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
74 | else |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
75 | g_win->fullRefresh(); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
76 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
77 | updateActions(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
80 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
81 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
82 | void History::clear() |
497
c51941e590b6
a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
83 | { for (Changeset set : m_changesets) |
c51941e590b6
a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents:
493
diff
changeset
|
84 | for (auto change : set) |
376 | 85 | delete change; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
86 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
87 | m_changesets.clear(); |
183
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
90 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
91 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
92 | void History::updateActions() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
93 | { ACTION (Undo)->setEnabled (pos() != -1); |
382
c1642530ea35
Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
379
diff
changeset
|
94 | 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
|
95 | } |
f1b8cb53d2a2
Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
97 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
98 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
99 | void History::open() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
100 | { if (opened()) |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
101 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
102 | |
376 | 103 | setOpened (true); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
104 | } |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
105 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
106 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
107 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
108 | void History::close() |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
109 | { if (!opened()) |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
110 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
111 | |
376 | 112 | setOpened (false); |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
113 | |
376 | 114 | 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
|
115 | return; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
116 | |
376 | 117 | while (pos() < size() - 1) |
118 | m_changesets.erase (size() - 1); | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
119 | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
120 | m_changesets << m_currentArchive; |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
121 | m_currentArchive.clear(); |
376 | 122 | setPos (pos() + 1); |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
123 | updateActions(); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
124 | } |
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
125 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
126 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
127 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
128 | void History::add (AbstractHistoryEntry* entry) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
129 | { if (!opened()) |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
130 | { delete entry; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
131 | return; |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
132 | } |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
133 | |
376 | 134 | entry->setParent (this); |
266
12e7302f14e9
Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
265
diff
changeset
|
135 | m_currentArchive << entry; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
136 | } |
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 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
139 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
140 | void AddHistory::undo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
141 | { LDFile* f = parent()->file(); |
376 | 142 | LDObject* obj = f->object (index()); |
143 | f->forgetObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
144 | delete obj; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
145 | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
146 | g_fullRefresh = true; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
147 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
148 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
149 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
150 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
151 | void AddHistory::redo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
152 | { LDFile* f = parent()->file(); |
376 | 153 | LDObject* obj = parseLine (code()); |
154 | f->insertObj (index(), obj); | |
155 | 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
|
156 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
157 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
158 | AddHistory::~AddHistory() {} |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
159 | |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
160 | // ============================================================================= |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
161 | // heh |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
162 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
163 | void DelHistory::undo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
164 | { LDFile* f = parent()->file(); |
376 | 165 | LDObject* obj = parseLine (code()); |
166 | f->insertObj (index(), obj); | |
167 | 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
|
168 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
169 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
170 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
171 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
172 | void DelHistory::redo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
173 | { LDFile* f = parent()->file(); |
376 | 174 | LDObject* obj = f->object (index()); |
175 | f->forgetObject (obj); | |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
176 | delete obj; |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
177 | |
276
a21e49914264
Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents:
275
diff
changeset
|
178 | g_fullRefresh = true; |
271
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
179 | } |
d5ec224c1879
Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents:
266
diff
changeset
|
180 | |
347
02e10ed4f8eb
astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
276
diff
changeset
|
181 | DelHistory::~DelHistory() {} |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
182 | |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
183 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
184 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
185 | void EditHistory::undo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
186 | { LDObject* obj = LDFile::current()->object (index()); |
376 | 187 | LDObject* newobj = parseLine (oldCode()); |
188 | obj->replace (newobj); | |
189 | g_win->R()->compileObject (newobj); | |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
190 | } |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
191 | |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
192 | // ============================================================================= |
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
193 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
194 | void EditHistory::redo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
195 | { LDObject* obj = LDFile::current()->object (index()); |
376 | 196 | LDObject* newobj = parseLine (newCode()); |
197 | obj->replace (newobj); | |
198 | g_win->R()->compileObject (newobj); | |
275
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
199 | } |
7b5afec27688
Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents:
274
diff
changeset
|
200 | |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
201 | EditHistory::~EditHistory() {} |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
202 | |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
203 | // ============================================================================= |
455
c5d14d112034
Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
421
diff
changeset
|
204 | // ----------------------------------------------------------------------------- |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
205 | void SwapHistory::undo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
206 | { LDObject::fromID (a)->swap (LDObject::fromID (b)); |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
207 | } |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
208 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
209 | void SwapHistory::redo() const |
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
210 | { undo(); // :v |
362
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
211 | } |
344fe1da32c8
Added history functionality for swapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
355
diff
changeset
|
212 | |
493
16766ac1bbd9
last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents:
455
diff
changeset
|
213 | SwapHistory::~SwapHistory() {} |