Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

Undo Class Reference

Inheritance diagram for Undo:
CallBacker

List of all members.

Public Member Functions

 Undo ()
virtual ~Undo ()
void removeAll ()
int maxLength () const
void setMaxLength (int)
int addEvent (UndoEvent *event, const char *description=0)
int currentEventID () const
int firstEventID () const
int lastEventID () const
void removeAllAfterCurrentEvent ()
void removeAllBeforeCurrentEvent ()
bool isUserInteractionEnd (int eventid) const
void setUserInteractionEnd (int eventid, bool=true)
int getNextUserInteractionEnd (int start) const
BufferString getDesc (int eventid) const
void setDesc (int eventid, const char *d)
BufferString unDoDesc () const
BufferString reDoDesc () const
bool canUnDo () const
bool unDo (int nrtimes=1, bool userinteraction=true)
bool canReDo () const
bool reDo (int nrtimes=1, bool userinteraction=true)

Public Attributes

Notifier< Undochangenotifier

Protected Member Functions

int indexOf (int eventid) const
void removeOldEvents ()
void removeStartToAndIncluding (int)

Protected Attributes

int currenteventid_
int firsteventid_
int maxsize_
ObjectSet< UndoEventevents_
int userendscount_

Detailed Description

Class to handle undo/redo information. Events that can be undone/redone are added to the Undo. One user operation may involve thouthands of changes added to the history, but the user does not want to press undo a thousand times. This is managed by setting a UserInteractionEnd flag on the last event in a chain that the user started. When doing undo, one undo step is consists of all events from the current event until the next event with the UserInteraction flag set.

This means that after all user-driven events, the UserInteractionEnd should be set:

void MyClass::userPushedAButtonCB( CallBacker* )
{
    doSomethingsThatAddThingsOnTheHistory();
    history.setUserInteractionEnd( currentEventID() );
}

Constructor & Destructor Documentation

Undo::Undo (  ) 
virtual Undo::~Undo (  )  [virtual]

Member Function Documentation

int Undo::addEvent ( UndoEvent event,
const char *  description = 0 
)
Parameters:
event The new event (becomes mine).
Returns:
the event id.
bool Undo::canReDo (  )  const
bool Undo::canUnDo (  )  const
Note:
takes redodesc with userinteraction
int Undo::currentEventID (  )  const
int Undo::firstEventID (  )  const
BufferString Undo::getDesc ( int  eventid  )  const
int Undo::getNextUserInteractionEnd ( int  start  )  const
int Undo::indexOf ( int  eventid  )  const [protected]
bool Undo::isUserInteractionEnd ( int  eventid  )  const
int Undo::lastEventID (  )  const
int Undo::maxLength (  )  const

Returns maximum number of userevents.

Note:
The actual number of events may be considerably higher since many events may be part of one single user event.
bool Undo::reDo ( int  nrtimes = 1,
bool  userinteraction = true 
)
BufferString Undo::reDoDesc (  )  const
void Undo::removeAll (  ) 
void Undo::removeAllAfterCurrentEvent (  ) 
void Undo::removeAllBeforeCurrentEvent (  ) 
void Undo::removeOldEvents (  )  [protected]
void Undo::removeStartToAndIncluding ( int   )  [protected]
void Undo::setDesc ( int  eventid,
const char *  d 
)
void Undo::setMaxLength ( int   ) 
void Undo::setUserInteractionEnd ( int  eventid,
bool  = true 
)
bool Undo::unDo ( int  nrtimes = 1,
bool  userinteraction = true 
)
BufferString Undo::unDoDesc (  )  const

Member Data Documentation

int Undo::currenteventid_ [protected]
int Undo::firsteventid_ [protected]
int Undo::maxsize_ [protected]
int Undo::userendscount_ [protected]