3 // Originally part of QCad Community Edition by Andrew Mustun
4 // Extensively rewritten and refactored by James L. Hammons
5 // (C) 2010 Underground Software
7 // JLH = James L. Hammons <jlhamm@acm.org>
10 // --- ---------- -----------------------------------------------------------
11 // JLH 05/05/2010 Moved implementation from header to this file. :-)
14 #include "rs_undocycle.h"
16 #include "rs_entity.h"
17 #include "rs_undoable.h"
20 * @param type Type of undo item.
22 RS_UndoCycle::RS_UndoCycle(/*RS2::UndoType type*/): undoableIterator(undoables)
25 // Good, we don't have to worry about this...
26 // undoables.setAutoDelete(false);
30 * Adds an Undoable to this Undo Cycle. Every Cycle can contain one or
33 void RS_UndoCycle::addUndoable(RS_Undoable * u)
39 * Removes an undoable from the list.
41 void RS_UndoCycle::removeUndoable(RS_Undoable * u)
43 // undoables.remove(u);
44 int i = undoables.indexOf(u);
49 * Iteration through undoable elements in this item.
51 RS_Undoable * RS_UndoCycle::getFirstUndoable()
53 // return undoables.first();
54 undoableIterator.toFront();
55 return undoableIterator.next();
59 * Iteration through undoable elements in this item.
61 RS_Undoable * RS_UndoCycle::getNextUndoable()
63 // return undoables.next();
64 return undoableIterator.next();
67 /*friend*/ std::ostream & operator<<(std::ostream & os, RS_UndoCycle & i)
69 os << " Undo item: " << "\n";
79 os << " Undoable ids: ";
81 for(RS_Undoable * u=i.getFirstUndoable(); u!=NULL; u=i.getNextUndoable())
83 if (u->undoRtti() == RS2::UndoableEntity)
85 RS_Entity * e = (RS_Entity *)u;
86 os << e->getId() << (u->isUndone() ? "*" : "") << " ";