src/history.cpp

Mon, 08 Jul 2013 02:46:55 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 08 Jul 2013 02:46:55 +0300
changeset 366
262d9bffe00e
parent 362
344fe1da32c8
child 376
4a89dd47535f
permissions
-rw-r--r--

fixed: history is supposed to be closed by default

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

mercurial