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 actions.insert(actions.end(),rhs.actions.begin(),rhs.actions.end());
40 UndoTransaction::operator= (const UndoTransaction& rhs)
42 if (this == &rhs) return *this;
45 actions.insert(actions.end(),rhs.actions.begin(),rhs.actions.end());
50 UndoTransaction::add_command (const UndoAction& action)
52 actions.push_back (action);
56 UndoTransaction::clear ()
62 UndoTransaction::operator() ()
64 for (list<UndoAction>::iterator i = actions.begin(); i != actions.end(); ++i) {
70 UndoTransaction::undo ()
72 cerr << "Undo " << _name << endl;
73 for (list<UndoAction>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
79 UndoTransaction::redo ()
81 cerr << "Redo " << _name << endl;
86 UndoHistory::add (UndoTransaction ut)
88 UndoList.push_back (ut);
92 UndoHistory::undo (unsigned int n)
95 if (UndoList.size() == 0) {
98 UndoTransaction ut = UndoList.back ();
101 RedoList.push_back (ut);
106 UndoHistory::redo (unsigned int n)
109 if (RedoList.size() == 0) {
112 UndoTransaction ut = RedoList.back ();
113 RedoList.pop_back ();
115 UndoList.push_back (trans);
120 UndoHistory::clear_redo ()
126 UndoHistory::clear_undo ()
132 UndoHistory::clear ()