3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/05/2010 Moved implementation from header to this file. :-)
15 #include "rs_undocycle.h"
17 #include "rs_entity.h"
18 #include "rs_undoable.h"
21 * @param type Type of undo item.
23 RS_UndoCycle::RS_UndoCycle(/*RS2::UndoType type*/): undoableIterator(undoables)
26 // Good, we don't have to worry about this...
27 // undoables.setAutoDelete(false);
31 * Adds an Undoable to this Undo Cycle. Every Cycle can contain one or
34 void RS_UndoCycle::addUndoable(RS_Undoable * u)
40 * Removes an undoable from the list.
42 void RS_UndoCycle::removeUndoable(RS_Undoable * u)
44 // undoables.remove(u);
45 int i = undoables.indexOf(u);
50 * Iteration through undoable elements in this item.
52 RS_Undoable * RS_UndoCycle::getFirstUndoable()
54 // return undoables.first();
55 undoableIterator.toFront();
56 return undoableIterator.next();
60 * Iteration through undoable elements in this item.
62 RS_Undoable * RS_UndoCycle::getNextUndoable()
64 // return undoables.next();
65 return undoableIterator.next();
68 /*friend*/ std::ostream & operator<<(std::ostream & os, RS_UndoCycle & i)
70 os << " Undo item: " << "\n";
80 os << " Undoable ids: ";
82 for(RS_Undoable * u=i.getFirstUndoable(); u!=NULL; u=i.getNextUndoable())
84 if (u->undoRtti() == RS2::UndoableEntity)
86 RS_Entity * e = (RS_Entity *)u;
87 os << e->getId() << (u->isUndone() ? "*" : "") << " ";