#include <rail.h>
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 |
Definition at line 26 of file rail.h.
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
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().
int Rail::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 | ( | ) |
Definition at line 43 of file rail.cpp.
References _decoder.
Referenced by Srcp083Client::requestNewRailState(), and Win::save().
int Rail::delay | ( | ) |
Definition at line 48 of file rail.cpp.
References _delay.
Referenced by Srcp083Client::requestNewRailState(), and Win::save().
QString Rail::type | ( | ) |
Definition at line 38 of file rail.cpp.
References _type.
Referenced by Win::save().
bool Rail::isOpen | ( | ) |
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
open | The state to apply | |
quiet | If quiet is true the rail do not emit the stateChanged() signal |
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
quiet | If quiet is true the rail do not emit the stateChanged() signal |
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.
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.
void Rail::initState | ( | ) | [private] |
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".
id | The rail type to set. |
Definition at line 25 of file rail.cpp.
References OrKMap::UnknownId.
Referenced by Rail(), and setState().
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
Definition at line 106 of file rail.h.
Referenced by initState(), Rail(), setState(), and type().
int Rail::_address [private] |
int Rail::_delay [private] |
QString Rail::_decoder [private] |
bool Rail::_open [private] |
Store the current state for the active elements
Definition at line 123 of file rail.h.
Referenced by initState(), isOpen(), setState(), and toggleState().