src/history.cpp

Sat, 06 Jul 2013 03:54:59 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 06 Jul 2013 03:54:59 +0300
changeset 347
02e10ed4f8eb
parent 276
a21e49914264
child 348
20134b519f90
permissions
-rw-r--r--

astyle history.cpp

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
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
26 EXTERN_ACTION( undo )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
27 EXTERN_ACTION( redo )
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
29 bool g_fullRefresh = false;
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
30
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
31 History::History()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
32 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
33 setPos( -1 );
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
36 void History::undo()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
37 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
38 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
39 return;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
41 const list& set = changeset( pos() );
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
42 g_fullRefresh = false;
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
43
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
44 // Iterate the list in reverse and undo all actions
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
45 for( const AbstractHistoryEntry * change : c_rev<AbstractHistoryEntry*> ( set ))
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
46 change->undo();
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
47
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
48 setPos( pos() - 1 );
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 if( !g_fullRefresh )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
51 g_win->refresh();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
52 else
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
53 g_win->fullRefresh();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
54
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
55 updateActions();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
58 void History::redo()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
59 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
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;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
63 const list& 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;
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
65
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
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
67 for( const AbstractHistoryEntry* change : set )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
68 change->redo();
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
69
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
70 setPos( pos() + 1 );
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
71
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
72 if( !g_fullRefresh )
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();
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
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
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
80 void History::clear()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
81 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
82 for( vector<AbstractHistoryEntry*> set : m_changesets )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
83 for( AbstractHistoryEntry* change : set )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
84 delete change;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
86 m_changesets.clear();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
89 void History::updateActions() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
90 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
91 ACTION( undo )->setEnabled( pos() != -1 );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
92 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
93 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
95 void History::open()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
96 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
97 if( opened() )
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
98 return;
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
99
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
100 setOpened( true );
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
101 }
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
102
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
103 void History::close()
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
104 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
105 if( !opened() )
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
106 return;
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
107
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
108 setOpened( false );
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
109
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
110 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
111 return;
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
112
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
113 while( pos() < size() - 1 )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
114 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
115
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
116 m_changesets << m_currentArchive;
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
117 m_currentArchive.clear();
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
118 setPos( pos() + 1 );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
119 updateActions();
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
120 }
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
121
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
122 void History::add( AbstractHistoryEntry* entry )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
123 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
124 if( !opened() )
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
125 {
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
126 delete entry;
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
127 return;
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
128 }
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
129
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
130 entry->setParent( this );
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 265
diff changeset
131 m_currentArchive << entry;
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
132 }
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
133
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
134 // =============================================================================
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
135 void AddHistory::undo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
136 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
137 LDOpenFile* f = parent()->file();
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
138 LDObject* obj = f->object( index() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
139 f->forgetObject( obj );
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
140 delete obj;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
141
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
142 g_fullRefresh = true;
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
143 }
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
144
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
145 void AddHistory::redo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
146 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
147 LDOpenFile* f = parent()->file();
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
148 LDObject* obj = parseLine( code() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
149 f->insertObj( index(), obj );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
150 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
151 }
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
152
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
153 AddHistory::~AddHistory() {}
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
154
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
155 // =============================================================================
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
156 // heh
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
157 void DelHistory::undo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
158 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
159 LDOpenFile* f = parent()->file();
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
160 LDObject* obj = parseLine( code() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
161 f->insertObj( index(), obj );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
162 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
163 }
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
164
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
165 void DelHistory::redo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
166 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
167 LDOpenFile* f = parent()->file();
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
168 LDObject* obj = f->object( index() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
169 f->forgetObject( obj );
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
170 delete obj;
276
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
171
a21e49914264 Made history work with most things
Santeri Piippo <crimsondusk64@gmail.com>
parents: 275
diff changeset
172 g_fullRefresh = true;
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
173 }
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 266
diff changeset
174
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
175 DelHistory::~DelHistory() {}
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
176
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
177 // =============================================================================
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
178 void EditHistory::undo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
179 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
180 LDObject* obj = g_curfile->object( index() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
181 LDObject* newobj = parseLine( oldCode() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
182 obj->replace( newobj );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
183 g_win->R()->compileObject( newobj );
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
184 }
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
185
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
186 void EditHistory::redo() const
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
187 {
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
188 LDObject* obj = g_curfile->object( index() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
189 LDObject* newobj = parseLine( newCode() );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
190 obj->replace( newobj );
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
191 g_win->R()->compileObject( newobj );
275
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
192 }
7b5afec27688 Color changing is now logged into history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
193
347
02e10ed4f8eb astyle history.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 276
diff changeset
194 EditHistory::~EditHistory() {}

mercurial