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.
24 #include <pbd/xml++.h>
29 UndoTransaction::UndoTransaction ()
33 UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
37 actions.insert(actions.end(),rhs.actions.begin(),rhs.actions.end());
41 UndoTransaction::operator= (const UndoTransaction& rhs)
43 if (this == &rhs) return *this;
46 actions.insert(actions.end(),rhs.actions.begin(),rhs.actions.end());
51 UndoTransaction::add_command (Command *const action)
53 actions.push_back (action);
57 UndoTransaction::clear ()
63 UndoTransaction::operator() ()
65 for (list<Command*>::iterator i = actions.begin(); i != actions.end(); ++i) {
71 UndoTransaction::undo ()
73 cerr << "Undo " << _name << endl;
74 for (list<Command*>::reverse_iterator i = actions.rbegin(); i != actions.rend(); ++i) {
80 UndoTransaction::redo ()
82 cerr << "Redo " << _name << endl;
86 XMLNode &UndoTransaction::get_state()
88 XMLNode *node = new XMLNode ("UndoTransaction");
94 UndoHistory::add (UndoTransaction ut)
96 UndoList.push_back (ut);
100 UndoHistory::undo (unsigned int n)
103 if (UndoList.size() == 0) {
106 UndoTransaction ut = UndoList.back ();
107 UndoList.pop_back ();
109 RedoList.push_back (ut);
114 UndoHistory::redo (unsigned int n)
117 if (RedoList.size() == 0) {
120 UndoTransaction ut = RedoList.back ();
121 RedoList.pop_back ();
123 UndoList.push_back (ut);
128 UndoHistory::clear_redo ()
134 UndoHistory::clear_undo ()
140 UndoHistory::clear ()