Scribus
Open source desktop publishing at your fingertips
UndoObject Class Referenceabstract

Superclass for all objects that are wanted to have undoable actions. More...

#include <undoobject.h>

Inheritance diagram for UndoObject:

Public Member Functions

 UndoObject ()
 Creates a new anonymous UndoObject instance.
 
 UndoObject (const UndoObject &other)
 Creates a copy of an UndoObject instance.
 
 UndoObject (const QString &objectName, QPixmap *objectIcon=0)
 Creates a new UndoObject instance with the name objectName More...
 
virtual ~UndoObject ()
 Destroys the object.
 
virtual QString getUName ()
 Returns the name of the UndoObject. More...
 
virtual void setUName (QString newUName)
 Set the name of the UndoObject. More...
 
virtual QPixmap * getUPixmap ()
 Returns the pixmap connected to this object. More...
 
virtual void setUPixmap (QPixmap *newUPixmap)
 Set the pixmap for this object. More...
 
ulong getUId () const
 Returns an unique identifier number for the UndoObject. More...
 
const ScGuardedPtr< UndoObject > & undoObjectPtr ()
 Returns a guarded pointer.
 
virtual void restore (UndoState *state, bool isUndo)=0
 Method used when an undo/redo is requested. More...
 

Detailed Description

Superclass for all objects that are wanted to have undoable actions.

The most important feature of UndoObject is the restore() method which must be implemented in the subclass. When an action that is wanted to be undoable happens UndoObject subclass must use UndoManager::action() method to store the action using UndoState object. Then when a user undos this action UndoManager will send the UndoState object back to this UndoObject by using the restore() method.

What is needed for an undo/redo:

  1. UndoObject creates an UndoState object describing the action
  2. Sends it to the UndoManager
  3. When an undo/redo is requested UndoManager will send this very same UndoState object back to the UndoObject which then uses it to restore the state.
Author
Riku Leino riku@.nosp@m.scri.nosp@m.bus.i.nosp@m.nfo
Date
December 2004

Constructor & Destructor Documentation

UndoObject::UndoObject ( const QString &  objectName,
QPixmap *  objectIcon = 0 
)

Creates a new UndoObject instance with the name objectName

Parameters
objectNameName of the UndoObject

Member Function Documentation

ulong UndoObject::getUId ( ) const

Returns an unique identifier number for the UndoObject.

Returns
unique identifier number for the UndoObjet
QString UndoObject::getUName ( )
virtual

Returns the name of the UndoObject.

Returns
the name of the UndoObject
QPixmap * UndoObject::getUPixmap ( )
virtual

Returns the pixmap connected to this object.

Returns
pixmap connected to this object
virtual void UndoObject::restore ( UndoState state,
bool  isUndo 
)
pure virtual

Method used when an undo/redo is requested.

UndoObject must know how to handle the UndoState object given as a parameter. It is the same object that was send from the UndoObject to the UndoManager when the action happened.

Parameters
stateState describing the action that is wanted to be undone/redone
isUndoIf true undo is wanted else if false redo.

Implemented in PageItem, ScribusDoc, ScribusMainWindow, DummyUndoObject, ScPage, and PageItem_LatexFrame.

void UndoObject::setUName ( QString  newUName)
virtual

Set the name of the UndoObject.

Parameters
newUNameNew name for the UndoObject
void UndoObject::setUPixmap ( QPixmap *  newUPixmap)
virtual

Set the pixmap for this object.

Parameters
newUPixmappixmap for this object

The documentation for this class was generated from the following files: