Rail Class Reference

Rail widget based on QGraphicsSvgItem. More...

#include <rail.h>

List of all members.

Signals

void stateChanged (bool)
void clicked ()

Public Member Functions

 Rail (QSvgRenderer *renderer, QString type="", int address=0, int delay=0, QString decoder="", QString info="", QGraphicsItem *parent=0)
int address ()
QString decoder ()
int delay ()
QString type ()
bool isOpen ()
void setState (bool open, bool quiet=FALSE)
void toggleState (bool quiet=FALSE)
QRectF boundingRect () const
 Return the size of the rail.

Protected Member Functions

void mousePressEvent (QGraphicsSceneMouseEvent *event)

Private Member Functions

void initState ()
void setElementIdSafe (const QString &id)

Private Attributes

QString _type
int _address
int _delay
QString _decoder
bool _open


Detailed Description

Rail widget based on QGraphicsSvgItem.

Definition at line 26 of file rail.h.


Constructor & Destructor Documentation

Rail::Rail ( QSvgRenderer *  renderer,
QString  type = "",
int  address = 0,
int  delay = 0,
QString  decoder = "",
QString  info = "",
QGraphicsItem *  parent = 0 
)

Create a rail widget for OrK

Parameters:
renderer Pointer to the QSvgRenderer wich render the whole map
type Represent the type of the rail (i.e shunting, line, ...) it corresponds to the group ID in the SVG file with the rails
address The address of the rail. If address != 0 the rail is active (i.e clickable)
delay The activation delay in ms
decoder The decoder protocol as described by the SRCP
info An info string show as a tooltip on the rail

Definition at line 12 of file rail.cpp.

References _address, _decoder, _delay, _type, initState(), and setElementIdSafe().


Member Function Documentation

int Rail::address (  ) 

Returns:
The rail address, 0 means no address

Definition at line 33 of file rail.cpp.

References _address.

Referenced by Win::addRail(), Win::removeRail(), Srcp083Client::requestNewRailState(), and Win::save().

QString Rail::decoder (  ) 

Returns:
The decoder type
See also:
http://srcpd.sourceforge.net/srcp

Definition at line 43 of file rail.cpp.

References _decoder.

Referenced by Srcp083Client::requestNewRailState(), and Win::save().

int Rail::delay (  ) 

Returns:
The activation delay in ms

Definition at line 48 of file rail.cpp.

References _delay.

Referenced by Srcp083Client::requestNewRailState(), and Win::save().

QString Rail::type (  ) 

Returns:
The type name of the rail, as store in the group id of the SVG file with the rails

Definition at line 38 of file rail.cpp.

References _type.

Referenced by Win::save().

bool Rail::isOpen (  ) 

Returns:
True if the element is open
See also:
setState(), toggleState()

Definition at line 97 of file rail.cpp.

References _open.

Referenced by Srcp083Client::requestNewRailState().

void Rail::setState ( bool  open,
bool  quiet = FALSE 
)

Set a new rail state

Parameters:
open The state to apply
quiet If quiet is true the rail do not emit the stateChanged() signal
See also:
toggleState(), isOpen()

Definition at line 61 of file rail.cpp.

References _open, _type, setElementIdSafe(), stateChanged(), OrKMap::StateClosed, and OrKMap::StateOpen.

Referenced by toggleState().

void Rail::toggleState ( bool  quiet = FALSE  ) 

Toggle the rail state

Parameters:
quiet If quiet is true the rail do not emit the stateChanged() signal
See also:
setState(), isOpen()

Definition at line 78 of file rail.cpp.

References _open, and setState().

QRectF Rail::boundingRect (  )  const

Return the size of the rail.

Definition at line 83 of file rail.cpp.

References OrKMap::ItemXSize, and OrKMap::ItemYSize.

void Rail::stateChanged ( bool   )  [signal]

The stateChanged() is emitted if the rail state change, after a after a request from the model according to the info client.

See also:
setState(), toggleState(), isOpen()

Referenced by setState().

void Rail::clicked (  )  [signal]

The clicked() is emit if the user clicked on the rail this signal will be handled by the model.

Referenced by mousePressEvent().

void Rail::mousePressEvent ( QGraphicsSceneMouseEvent *  event  )  [protected]

Reimplemented to get the user action. The mouse action is responsible for calling the toggleState() if the address of the rail is not 0.

See also:
toggleState()

Definition at line 88 of file rail.cpp.

References _address, and clicked().

void Rail::initState (  )  [private]

Set the state according to the current type. This is normally only called by the constructor.

Definition at line 53 of file rail.cpp.

References _open, _type, and OrKMap::StateOpen.

Referenced by Rail().

void Rail::setElementIdSafe ( const QString &  id  )  [private]

This function look if the requested id group exist in the svg file if it is not the case, the id is set to "unknown".

Parameters:
id The rail type to set.

Definition at line 25 of file rail.cpp.

References OrKMap::UnknownId.

Referenced by Rail(), and setState().


Member Data Documentation

QString Rail::_type [private]

Store the rail type (i.e shunting, line, ...) it corresponds to the group ID in the SVG file with the rails

See also:
type()

Definition at line 106 of file rail.h.

Referenced by initState(), Rail(), setState(), and type().

int Rail::_address [private]

Store the rail address, if address = 0 the element is inactive (i.e not responding on click)

See also:
address()

Definition at line 111 of file rail.h.

Referenced by address(), mousePressEvent(), and Rail().

int Rail::_delay [private]

Store the activation delay

See also:
delay()

Definition at line 115 of file rail.h.

Referenced by delay(), and Rail().

QString Rail::_decoder [private]

Store the decoder name according to the SRCP protocol

See also:
decoder(), http://srcpd.sourceforge.net/srcp

Definition at line 119 of file rail.h.

Referenced by decoder(), and Rail().

bool Rail::_open [private]

Store the current state for the active elements

See also:
isOpen()

Definition at line 123 of file rail.h.

Referenced by initState(), isOpen(), setState(), and toggleState().


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

Generated on Sun Jun 22 23:46:29 2008 for OrK by  doxygen 1.5.6