2 Copyright (C) 2001 Brett Viren & Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 UndoTransaction::UndoTransaction ()
32 UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
36 undo_actions.insert(undo_actions.end(),rhs.undo_actions.begin(),rhs.undo_actions.end());
37 redo_actions.insert(redo_actions.end(),rhs.redo_actions.begin(),rhs.redo_actions.end());
41 UndoTransaction::operator= (const UndoTransaction& rhs)
43 if (this == &rhs) return *this;
46 undo_actions.insert(undo_actions.end(),rhs.undo_actions.begin(),rhs.undo_actions.end());
47 redo_actions.insert(redo_actions.end(),rhs.redo_actions.begin(),rhs.redo_actions.end());
52 UndoTransaction::add_undo (const UndoAction& action)
54 undo_actions.push_back (action);
58 UndoTransaction::add_redo (const UndoAction& action)
60 redo_actions.push_back (action);
61 redo_actions.back()(); // operator()
65 UndoTransaction::add_redo_no_execute (const UndoAction& action)
67 redo_actions.push_back (action);
71 UndoTransaction::clear ()
73 undo_actions.clear ();
74 redo_actions.clear ();
78 UndoTransaction::undo ()
80 cerr << "Undo " << _name << endl;
81 for (list<UndoAction>::reverse_iterator i = undo_actions.rbegin(); i != undo_actions.rend(); ++i) {
87 UndoTransaction::redo ()
89 cerr << "Redo " << _name << endl;
90 for (list<UndoAction>::iterator i = redo_actions.begin(); i != redo_actions.end(); ++i) {
96 UndoHistory::add (UndoTransaction ut)
98 UndoList.push_back (ut);
102 UndoHistory::undo (unsigned int n)
105 if (UndoList.size() == 0) {
108 UndoTransaction ut = UndoList.back ();
109 UndoList.pop_back ();
111 RedoList.push_back (ut);
116 UndoHistory::redo (unsigned int n)
119 if (RedoList.size() == 0) {
122 UndoTransaction trans = RedoList.back ();
123 RedoList.pop_back ();
125 UndoList.push_back (trans);
130 UndoHistory::clear_redo ()
136 UndoHistory::clear_undo ()
142 UndoHistory::clear ()