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 06/02/2010 Added this text. :-)
15 #include "rs_undoable.h"
17 #include "rs_undocycle.h"
20 * Default constructor.
22 RS_Undoable::RS_Undoable()
28 * Destructor. Makes sure that this undoable is removed from
29 * its undo cycle before it is deleted.
31 RS_Undoable::~RS_Undoable()
34 cycle->removeUndoable(this);
38 * Runtime type identification for undoables.
39 * Note that this is voluntarily. The default implementation
40 * returns RS2::UndoableUnknown.
42 /*virtual*/ RS2::UndoableType RS_Undoable::undoRtti()
44 return RS2::UndoableUnknown;
48 * Sets the undo cycle this entity is in. This is necessary to
49 * make sure the entity can remove itself from the cycle before
52 void RS_Undoable::setUndoCycle(RS_UndoCycle * cycle)
58 * The undoable thing gets activated if it was undone and
59 * deactivated otherwise.
61 void RS_Undoable::changeUndoState()
63 toggleFlag(RS2::FlagUndone);
64 undoStateChanged(isUndone());
68 * Undoes or redoes an undoable.
70 void RS_Undoable::setUndoState(bool undone)
73 setFlag(RS2::FlagUndone);
75 delFlag(RS2::FlagUndone);
77 undoStateChanged(isUndone());
81 * Is this entity in the Undo memory and not active?
83 bool RS_Undoable::isUndone() const
85 return getFlag(RS2::FlagUndone);
89 * Can be overwriten by the implementing class to be notified
90 * when the undo state changes (the undoable becomes visible / invisible).
92 /*virtual*/ void RS_Undoable::undoStateChanged(bool /*undone*/)