Scribus
Open source desktop publishing at your fingertips
SimpleState Class Reference

SimpleState provides a simple implementation of the UndoState. More...

#include <undostate.h>

Inheritance diagram for SimpleState:
Collaboration diagram for SimpleState:

Public Member Functions

 SimpleState (const QString &name, const QString &description=0, QPixmap *pixmap=0)
 Creates a new SimpleState instance. More...
 
bool contains (const QString &key)
 Returns true if parameter key exists in the map. More...
 
QString get (const QString &key, const QString &def="")
 Returns the QString value attached to the key. More...
 
int getInt (const QString &key, int def=0)
 Returns the int value attached to the key. More...
 
uint getUInt (const QString &key, uint def=0)
 Returns the uint value attached to the key. More...
 
double getDouble (const QString &key, double def=0.0)
 Returns the double value attached to the key. More...
 
bool getBool (const QString &key, bool def=false)
 Returns the boolean value attached to the key. More...
 
void set (const QString &key, const QString &value)
 Set a value for the key. More...
 
void set (const QString &key, int value)
 Set a value for the key. More...
 
void set (const QString &key, uint value)
 Set a value for the key. More...
 
void set (const QString &key, double value)
 Set a value for the key. More...
 
void set (const QString &key, bool value)
 Set a value for the key. More...
 
- Public Member Functions inherited from UndoState
 UndoState (const QString &name, const QString &description=0, QPixmap *pixmap=0)
 Creates a new UndoState instance. More...
 
virtual QString getName ()
 Returns name of the state (action). More...
 
virtual void setName (const QString &newName)
 Set the name for this UndoState. More...
 
virtual QString getDescription ()
 Returns description of the state. More...
 
virtual void setDescription (const QString &newDescription)
 Set the description for this UndoState. More...
 
virtual QPixmap * getPixmap ()
 Returns a pointer to the icon attached to the state. More...
 
virtual void setPixmap (QPixmap *newPixmap)
 Set the icon for this UndoState. More...
 
virtual void undo ()
 undo the state described by this UndoState, More...
 
virtual void redo ()
 redo the state described by this UndoState, More...
 
virtual bool isTransaction ()
 To know if the state is a transaction.
 
virtual void setUndoObject (UndoObject *object)
 Set the UndoObject this state belongs to.
 
virtual UndoObjectundoObject ()
 return the UndoObject this state belongs to
 

Additional Inherited Members

- Public Attributes inherited from UndoState
int transactionCode
 

Detailed Description

SimpleState provides a simple implementation of the UndoState.

SimpleState uses a QMap to store key-value pairs that can be queried and set using it's get() and set() methods.

Author
Riku Leino tsoot.nosp@m.s@gm.nosp@m.ail.c.nosp@m.om
Date
December 2004

Constructor & Destructor Documentation

SimpleState::SimpleState ( const QString &  name,
const QString &  description = 0,
QPixmap *  pixmap = 0 
)

Creates a new SimpleState instance.

Parameters
nameName of the state (action). Will be used when describing the state in UndoGui subclasses.
descriptionDescription of the state (action)
pixmapPointer to an icon describing the state (action) visually.

Member Function Documentation

bool SimpleState::contains ( const QString &  key)

Returns true if parameter key exists in the map.

Parameters
keyKey that is searched from the map
Returns
true if parameter key exists in the map if not false
QString SimpleState::get ( const QString &  key,
const QString &  def = "" 
)

Returns the QString value attached to the key.

If key is not found from the map it will be added there with the value given as a parameter def. In such case def will also be returned.

Parameters
keyKey that is searched from the map
defDefault value to be used if key is not found from the map
Returns
Value attached to the key in the map. If the key is not found from the map it will be added with the value described in the param def which is then returned.
bool SimpleState::getBool ( const QString &  key,
bool  def = false 
)

Returns the boolean value attached to the key.

Values are stored as QStrings in the map and when queried with this method value attached to the key is converted to a bool. If the conversion fails value of the parameter def will be returned. If key is not found from the map it will be added there with the value given as a parameter def. In such case def will also be returned.

Parameters
keyKey that is searched from the map
defDefault value to be used if key is not found from the map
Returns
Bool value attached to the key in the map. If the key is not found from the map it will be added with the value described in the parameter def which is then returned.
double SimpleState::getDouble ( const QString &  key,
double  def = 0.0 
)

Returns the double value attached to the key.

Values are stored as QStrings in the map and when queried with this method value attached to the key is converted to a double. If the conversion fails value of the parameter def will be returned. If key is not found from the map it will be added there with the value given as a parameter def. In such case def will also be returned.

Parameters
keyKey that is searched from the map
defDefault value to be used if key is not found from the map
Returns
Double value attached to the key in the map. If the key is not found from the map it will be added with the value described in the parameter def which is then returned.
int SimpleState::getInt ( const QString &  key,
int  def = 0 
)

Returns the int value attached to the key.

Values are stored as QStrings in the map and when queried with this method value attached to the key is converted to an int. If the conversion fails value of the parameter def will be returned. If key is not found from the map it will be added there with the value given as a parameter def. In such case def will also be returned.

Parameters
keyKey that is searched from the map
defDefault value to be used if key is not found from the map
Returns
int value attached to the key in the map. If the key is not found from the map it will be added with the value described in the param def which is then returned.
uint SimpleState::getUInt ( const QString &  key,
uint  def = 0 
)

Returns the uint value attached to the key.

Values are stored as QStrings in the map and when queried with this method value attached to the key is converted to an int. If the conversion fails value of the parameter def will be returned. If key is not found from the map it will be added there with the value given as a parameter def. In such case def will also be returned.

Parameters
keyKey that is searched from the map
defDefault value to be used if key is not found from the map
Returns
uint value attached to the key in the map. If the key is not found from the map it will be added with the value described in the param def which is then returned.
void SimpleState::set ( const QString &  key,
const QString &  value 
)

Set a value for the key.

Parameters
keyKey that can be later used to query the value.
valueValue attached to the key.
void SimpleState::set ( const QString &  key,
int  value 
)

Set a value for the key.

Parameters
keyKey that can be later used to query the value.
valueValue attached to the key.
void SimpleState::set ( const QString &  key,
uint  value 
)

Set a value for the key.

Parameters
keyKey that can be later used to query the value.
valueValue attached to the key.
void SimpleState::set ( const QString &  key,
double  value 
)

Set a value for the key.

Parameters
keyKey that can be later used to query the value.
valueValue attached to the key.
void SimpleState::set ( const QString &  key,
bool  value 
)

Set a value for the key.

Parameters
keyKey that can be later used to query the value.
valueValue attached to the key.

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