Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

SimpleState Class Reference

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

#include <undostate.h>

Inheritance diagram for SimpleState:

Inheritance graph
[legend]
Collaboration diagram for SimpleState:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 SimpleState (const QString &name, const QString &description=0, QPixmap *pixmap=0)
 Creates a new SimpleState instance.
virtual ~SimpleState ()
bool contains (const QString &key)
 Returns true if parameter key exists in the map.
QString get (const QString &key, const QString &def="")
 Returns the QString value attached to the key.
int getInt (const QString &key, int def=0)
 Returns the int value attached to the key.
uint getUInt (const QString &key, uint def=0)
 Returns the uint value attached to the key.
double getDouble (const QString &key, double def=0.0)
 Returns the double value attached to the key.
bool getBool (const QString &key, bool def=false)
 Returns the boolean value attached to the key.
void set (const QString &key, const QString &value)
 Set a value for the key.
void set (const QString &key, int value)
 Set a value for the key.
void set (const QString &key, uint value)
 Set a value for the key.
void set (const QString &key, double value)
 Set a value for the key.
void set (const QString &key, bool value)
 Set a value for the key.

Private Attributes

QMap< QString, QString > values_
 QMap to store key-value pairs.


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 tsoots@gmail.com
Date:
December 2004

Definition at line 138 of file undostate.h.


Constructor & Destructor Documentation

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

Creates a new SimpleState instance.

Parameters:
name Name of the state (action). Will be used when describing the state in UndoGui subclasses.
description Description of the state (action)
pixmap Pointer to an icon describing the state (action) visually.

Definition at line 98 of file undostate.cpp.

SimpleState::~SimpleState (  )  [virtual]

Definition at line 184 of file undostate.cpp.


Member Function Documentation

bool SimpleState::contains ( const QString &  key  ) 

Returns true if parameter key exists in the map.

Parameters:
key Key that is searched from the map
Returns:
true if parameter key exists in the map if not false

Definition at line 104 of file undostate.cpp.

References values_.

Referenced by ScribusDoc::restore(), PageItem_LatexFrame::restore(), and Page::restore().

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:
key Key that is searched from the map
def Default 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.

Definition at line 109 of file undostate.cpp.

References values_.

Referenced by ScribusDoc::restore(), PageItem_LatexFrame::restore(), and ScribusDoc::restoreMasterPageApplying().

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:
key Key that is searched from the map
def Default 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.

Definition at line 118 of file undostate.cpp.

Referenced by ScribusDoc::restore(), Page::restore(), ScribusDoc::restoreMasterPageApplying(), ScribusDoc::restorePageCopy(), and PageItem::restoreType().

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:
key Key that is searched from the map
def Default 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.

Definition at line 128 of file undostate.cpp.

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:
key Key that is searched from the map
def Default 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.

Definition at line 138 of file undostate.cpp.

Referenced by Page::restore().

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:
key Key that is searched from the map
def Default 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.

Definition at line 148 of file undostate.cpp.

Referenced by ScribusDoc::restore().

void SimpleState::set ( const QString &  key,
const QString &  value 
)

void SimpleState::set ( const QString &  key,
int  value 
)

Set a value for the key.

Parameters:
key Key that can be later used to query the value.
value Value attached to the key.

Definition at line 163 of file undostate.cpp.

References values_.

void SimpleState::set ( const QString &  key,
uint  value 
)

Set a value for the key.

Parameters:
key Key that can be later used to query the value.
value Value attached to the key.

Definition at line 168 of file undostate.cpp.

References values_.

void SimpleState::set ( const QString &  key,
double  value 
)

Set a value for the key.

Parameters:
key Key that can be later used to query the value.
value Value attached to the key.

Definition at line 173 of file undostate.cpp.

References values_.

void SimpleState::set ( const QString &  key,
bool  value 
)

Set a value for the key.

Parameters:
key Key that can be later used to query the value.
value Value attached to the key.

Definition at line 178 of file undostate.cpp.

References values_.


Member Data Documentation

QMap<QString, QString> SimpleState::values_ [private]

QMap to store key-value pairs.

Definition at line 276 of file undostate.h.

Referenced by contains(), get(), and set().


The documentation for this class was generated from the following files:
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.