Win Class Reference

This is the main GUI element. More...

#include <win.h>

List of all members.

Public Slots

void setRailsFile (const QString &railsFile)
void addMap (Map *map)
void addMap ()
void addRail (Rail *rail)
void addEnginesArea (EnginesArea *enginesArea)
void addEnginesArea ()
void addEngine (Engine *engine)
void addEngine ()
void addRule (QString trigger, int source, QString action, int target)
 Insert a rule.
void removeMap (Map *map)
void removeRail (Rail *rail)
void removeEngine (Engine *engine)
void removeEnginesArea (EnginesArea *enginesArea)
void setRailState (int address, bool state, bool quiet=TRUE)
void setEngineState (int address, bool direction, int speed, bool light, bool f2, bool f3, bool f4)
void reportError (QString)

Public Member Functions

 Win (QSplashScreen *splash, QWidget *parent=0)
QString railsFile ()

Protected Member Functions

void closeEvent (QCloseEvent *event)
 Reimplemented to grab close event.

Private Slots

void readSettings ()
void writeSettings ()
void clearModel ()
 Close the current model and creates an empty model.
bool save (QString fileName)
bool save ()
bool saveAs ()
void open ()
 Show a file dialog and the open the .ork file.
void open (QString fileName)
bool maybeSave ()
void mapEdit ()
 If necessary create the map editor wigdet, else show or hide the widget.
void engineEdit ()
 If necessary create the engine editor wigdet, else show or hide the widget.
void editMode (bool edition)
void setDirty (bool dirty=TRUE)
void net (bool state)
 Handle new connection state, (de)activate the power action.
void setPower (bool state)
void fullscreen ()
 Go into fullscreen modus.
void hideMenubar ()
 Hide the menu bar.
void zoomIn ()
 Zoom in the current map.
void zoomOut ()
 Zoom oun the current map.
void zoomBestFit ()
 Fit the view to the size of the current map.
void zoomOriginal ()
 Reset the zoom to the original scale factor.
void tileView ()
 Tile the maps in the map area. This is only available in the docked window modus.
void cascadeView ()
 Cascade the maps in the map area. This is only available in the docked window modus.
void config ()
 Show the configuration dialog.
void help ()
 Show or open the help file.
void bug ()
 Go to the bug report web page.
void translate ()
 Go to the translation web page.
void about ()
 Show informations about OrK.
void setMultiWinMode (bool multiWinFlag)
void setUserPath (QString userPath)
 Called from the config object to set the current preferred user path.
void initClient (int protocol)
void showCloseMessage ()

Private Member Functions

void mkActions ()
 Create and connect all the actions for the buttons, toolsbars, and menus.
void mkMenus ()
 Create the memus.
void mkToolBars ()
 Create the toolbars.
void mkStatusBar ()
 Create the status bar.

Private Attributes

QList< Map * > * _maps
 Provide a maps storage place.
QMultiHash< int, Rail * > * _rails
 Provide a rails storage place.
QList< EnginesArea * > * _enginesAreas
 Provide an engine areas storage place.
QMultiHash< int, Engine * > * _engines
 Provide an engines storage place.
QSvgRenderer * _mapRenderer
 Provide a storage for the rules with action = on.
QString _railsFile
VirtualClient_client
 Store the current network client.
MapEditor_mapEditor
 Store the lazy map editior widget.
EngineEditor_engineEditor
 Store the lazy engine editor widget.
Config_config
 Store the config object, which contains also a dialog.
QMdiArea * _mapArea
 The area for the map windows, only for the single windows modus.
QString _userPath
 Store the preferred user user path.
bool _multiWinFlag
 OrK flags, true if the GUI is in multi-windows modus.
bool _editModeFlag
 OrK flags, true if the GUI is in edition modus.
QErrorMessage * _closeMessageDialog
QMenu * _removeMenu
QMenu * _mapsMenu
QMenu * _enginesAreaMenu
QAction * newAct
QAction * openAct
QAction * saveAct
QAction * saveAsAct
QAction * quitAct
QAction * addLocAct
QAction * addLocAreaAct
QAction * addMapAct
QAction * mapEditorAct
QAction * engineEditorAct
QAction * editModeAct
QAction * connectAct
QAction * powerAct
QAction * fullscreenAct
QAction * hideMenubarAct
QAction * zoomInAct
QAction * zoomOutAct
QAction * zoomBestFitAct
QAction * zoomOriginAct
QAction * cascadeViewAct
QAction * tileViewAct
QAction * configAct
QAction * helpAct
QAction * bugAct
QAction * translateAct
QAction * aboutAct
QAction * aboutQtAct


Detailed Description

This is the main GUI element.

This class is the core class of the OrK client. The Win class creates the OrK GUI, and provide storage for representing a railroad model. It creates a network client (as a VirtualClient).

Definition at line 42 of file win.h.


Constructor & Destructor Documentation

Win::Win ( QSplashScreen *  splash,
QWidget *  parent = 0 
)


Member Function Documentation

QString Win::railsFile (  ) 

Returns:
The path to the SVG file containing the rail items which will be shown on a Map
See also:
setRailsFile()

Definition at line 183 of file win.cpp.

References _railsFile.

void Win::setRailsFile ( const QString &  railsFile  )  [slot]

Parameters:
railsFile Set the path to the SVG file containing the rail items which will be shown on a Map
See also:
railsFile()

Definition at line 177 of file win.cpp.

References _mapRenderer, and _railsFile.

Referenced by Win().

void Win::addMap ( Map map  )  [slot]

Add a new map to the GUI, and connects the necessary stuff.

Parameters:
map The map object to insert

Definition at line 243 of file win.cpp.

References _mapArea, _maps, _mapsMenu, _multiWinFlag, Map::name(), and showCloseMessage().

Win::addMap (  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Create a new map on the GUI and insert it into the model

Definition at line 443 of file win.cpp.

References setDirty(), and Map::setName().

Referenced by mkActions(), open(), and setMultiWinMode().

void Win::addRail ( Rail rail  )  [slot]

Insert a rail in the model

Parameters:
rail Rail to insert

Definition at line 458 of file win.cpp.

References _client, _rails, and Rail::address().

Referenced by open().

void Win::addEnginesArea ( EnginesArea enginesArea  )  [slot]

Add a new engines area to the GUI, and connects the necessary stuff.

Parameters:
enginesArea The engines area to insert

Definition at line 305 of file win.cpp.

References _enginesAreaMenu, _enginesAreas, _multiWinFlag, EnginesArea::name(), setDirty(), and showCloseMessage().

Win::addEnginesArea (  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Create a new engines area on the GUI and insert it into the model

Definition at line 428 of file win.cpp.

References setDirty(), and EnginesArea::setName().

Referenced by mkActions(), open(), and setMultiWinMode().

void Win::addEngine ( Engine engine  )  [slot]

Insert an engine in the model

Parameters:
engine Engine to insert

Definition at line 416 of file win.cpp.

References _client, _engines, and Engine::address().

Win::addEngine (  )  [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Create a new engine on the GUI and insert it into the model

Definition at line 368 of file win.cpp.

References _engineEditor, engineEdit(), engineEditorAct, and EngineEditor::setEngine().

Referenced by mkActions(), and open().

void Win::addRule ( QString  trigger,
int  source,
QString  action,
int  target 
) [slot]

Insert a rule.

Definition at line 361 of file win.cpp.

Referenced by open().

void Win::removeMap ( Map map  )  [slot]

Remove a map from the model

Parameters:
map Map to remove

Definition at line 299 of file win.cpp.

References _maps.

void Win::removeRail ( Rail rail  )  [slot]

Remove a rail from the model

Parameters:
item Rail to remove

Definition at line 467 of file win.cpp.

References _rails, and Rail::address().

void Win::removeEngine ( Engine engine  )  [slot]

Remove an engine from the model

Parameters:
engine The engine to remove

Definition at line 422 of file win.cpp.

References _engines, and Engine::address().

void Win::removeEnginesArea ( EnginesArea enginesArea  )  [slot]

Remove an enginesArea form the model

Parameters:
enginesArea The enginesArea to remove

Definition at line 355 of file win.cpp.

References _enginesAreas.

void Win::setRailState ( int  address,
bool  state,
bool  quiet = TRUE 
) [slot]

Change the state of all rails with the given address on all available maps in the model. It is normally called according to informations received from the server.

Parameters:
address The address of the rails
state State (true = open) of the item
See also:
virtual_client.h

Definition at line 111 of file win.cpp.

References _rails.

Referenced by Win().

void Win::setEngineState ( int  address,
bool  direction,
int  speed,
bool  light,
bool  f2,
bool  f3,
bool  f4 
) [slot]

Change the state of an engine. It is normally called from an info client.

Parameters:
address The engine address
direction Direction of the engine ( true = reversed )
speed Engine speed in percent
light True if the lights are on
f2 True if the second function is on
f3 True if the third function is on
f4 True if the fourth function is on

Definition at line 139 of file win.cpp.

Referenced by Win().

void Win::reportError ( QString  error  )  [slot]

Report the error to the user. It is mainly use to report error from the network client.

Definition at line 146 of file win.cpp.

void Win::readSettings (  )  [private, slot]

Read the Qt settings file to restore the window(s) and toolsbars geometry

See also:
writeSettings()

Definition at line 156 of file win.cpp.

References _config, and Config::readConfig().

Referenced by Win().

void Win::writeSettings (  )  [private, slot]

Store the window(s) and toolsbars geometry

See also:
readSettings()

Definition at line 165 of file win.cpp.

References _config, and Config::writeConfig().

Referenced by closeEvent().

void Win::clearModel (  )  [private, slot]

Close the current model and creates an empty model.

Definition at line 193 of file win.cpp.

References _engines, _enginesAreaMenu, _enginesAreas, _mapArea, _maps, _mapsMenu, _multiWinFlag, _rails, maybeSave(), and setDirty().

Referenced by mkActions(), and open().

bool Win::save ( QString  fileName  )  [private, slot]

Save the current model to an OrK XML file

Parameters:
fileName Where we want to save the model
Returns:
False if an error occurred or if the user discards the save

Definition at line 1439 of file win.cpp.

References _enginesAreas, _maps, Engine::address(), Rail::address(), EnginesArea::count(), Engine::decoder(), Rail::decoder(), Rail::delay(), Engine::imagePath(), EnginesArea::itemAt(), OrKMap::ItemXSize, OrKMap::ItemYSize, Engine::name(), EnginesArea::name(), Map::name(), Rail::type(), OrKEngine::Version, OrKMap::Version, and OrK::Version.

Win::save (  )  [private, slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Save the current model to an OrK XML file

Returns:
False if an error occured or if the user discards the save

Definition at line 1133 of file win.cpp.

References saveAs(), and setDirty().

Referenced by maybeSave(), mkActions(), and saveAs().

bool Win::saveAs (  )  [private, slot]

Save the current model in a new file

Returns:
False if an error occurred or if the user discards the save

Definition at line 1145 of file win.cpp.

References _userPath, and save().

Referenced by mkActions(), and save().

void Win::open (  )  [private, slot]

Show a file dialog and the open the .ork file.

Definition at line 1157 of file win.cpp.

References _userPath.

Referenced by mkActions(), and Win().

void Win::open ( QString  fileName  )  [private, slot]

bool Win::maybeSave (  )  [private, slot]

If necessary, it will ask the user if he want to save the changes in the .ork file.

Returns:
True if the file do not need to be saved, or was saved, or if the user discard its changes, else return false (cancel next step)

Definition at line 1165 of file win.cpp.

References save().

Referenced by clearModel(), closeEvent(), and open().

void Win::mapEdit (  )  [private, slot]

If necessary create the map editor wigdet, else show or hide the widget.

Definition at line 493 of file win.cpp.

References _mapEditor, _multiWinFlag, and mapEditorAct.

Referenced by mkActions(), and setMultiWinMode().

void Win::engineEdit (  )  [private, slot]

If necessary create the engine editor wigdet, else show or hide the widget.

Definition at line 529 of file win.cpp.

References _engineEditor, _multiWinFlag, engineEditorAct, and setDirty().

Referenced by addEngine(), mkActions(), and setMultiWinMode().

void Win::editMode ( bool  edition  )  [private, slot]

Switch the edition modus

Parameters:
edition The edition state

Definition at line 573 of file win.cpp.

References _editModeFlag, _engineEditor, _mapEditor, _removeMenu, addLocAct, addLocAreaAct, addMapAct, engineEditorAct, and mapEditorAct.

Referenced by closeEvent(), and mkActions().

void Win::setDirty ( bool  dirty = TRUE  )  [private, slot]

Set the dirty flag to dirty

Parameters:
dirty True if the model was modified and not saved

Definition at line 1127 of file win.cpp.

References saveAct.

Referenced by addEnginesArea(), addMap(), clearModel(), engineEdit(), open(), and save().

void Win::net ( bool  state  )  [private, slot]

Handle new connection state, (de)activate the power action.

Definition at line 636 of file win.cpp.

References powerAct.

Referenced by mkActions().

void Win::setPower ( bool  state  )  [private, slot]

Set the power action in the state reported by the info client

See also:
virtual_client.h

Definition at line 641 of file win.cpp.

References powerAct.

Referenced by mkActions(), and Win().

void Win::fullscreen (  )  [private, slot]

Go into fullscreen modus.

Definition at line 647 of file win.cpp.

Referenced by mkActions().

void Win::hideMenubar (  )  [private, slot]

Hide the menu bar.

Definition at line 652 of file win.cpp.

Referenced by mkActions().

void Win::zoomIn (  )  [private, slot]

Zoom in the current map.

Definition at line 660 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::zoomOut (  )  [private, slot]

Zoom oun the current map.

Definition at line 673 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::zoomBestFit (  )  [private, slot]

Fit the view to the size of the current map.

Definition at line 687 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::zoomOriginal (  )  [private, slot]

Reset the zoom to the original scale factor.

Definition at line 701 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::tileView (  )  [private, slot]

Tile the maps in the map area. This is only available in the docked window modus.

Definition at line 715 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::cascadeView (  )  [private, slot]

Cascade the maps in the map area. This is only available in the docked window modus.

Definition at line 730 of file win.cpp.

References _mapArea, and _multiWinFlag.

Referenced by mkActions().

void Win::config (  )  [private, slot]

Show the configuration dialog.

Definition at line 744 of file win.cpp.

References _config.

Referenced by mkActions().

void Win::help (  )  [private, slot]

Show or open the help file.

Definition at line 749 of file win.cpp.

Referenced by mkActions().

void Win::bug (  )  [private, slot]

Go to the bug report web page.

Definition at line 754 of file win.cpp.

Referenced by mkActions().

void Win::translate (  )  [private, slot]

Go to the translation web page.

Definition at line 759 of file win.cpp.

Referenced by mkActions().

void Win::about (  )  [private, slot]

Show informations about OrK.

Definition at line 764 of file win.cpp.

References OrK::Version.

Referenced by mkActions().

void Win::setMultiWinMode ( bool  multiWinFlag  )  [private, slot]

Set the GUI to bo either in a docked modus (single window) or in a multi-windows modus (one window for each map, and engines area)

Definition at line 1049 of file win.cpp.

References _editModeFlag, _engineEditor, _mapArea, _mapEditor, _multiWinFlag, addEnginesArea(), addMap(), engineEdit(), and mapEdit().

Referenced by Win().

void Win::setUserPath ( QString  userPath  )  [private, slot]

Called from the config object to set the current preferred user path.

Definition at line 1112 of file win.cpp.

References _userPath.

Referenced by Win().

void Win::initClient ( int  protocol  )  [private, slot]

Load the requested network client with a specific protocol

See also:
virtual_client.h, srcp073_client.h, srcp083_client.h

Definition at line 99 of file win.cpp.

References _client.

Referenced by Win().

void Win::showCloseMessage (  )  [private, slot]

Show an information when the user close the maps windows. The windows are not deleted, but only stored in the corresponding menu.

Definition at line 1117 of file win.cpp.

References _closeMessageDialog.

Referenced by addEnginesArea(), and addMap().

void Win::closeEvent ( QCloseEvent *  event  )  [protected]

Reimplemented to grab close event.

Definition at line 473 of file win.cpp.

References _editModeFlag, editMode(), maybeSave(), and writeSettings().

void Win::mkActions (  )  [private]

void Win::mkMenus (  )  [private]

void Win::mkToolBars (  )  [private]

void Win::mkStatusBar (  )  [private]

Create the status bar.

Definition at line 1035 of file win.cpp.

Referenced by Win().


Member Data Documentation

QList<Map*>* Win::_maps [private]

Provide a maps storage place.

Definition at line 272 of file win.h.

Referenced by addMap(), clearModel(), removeMap(), save(), and Win().

QMultiHash<int, Rail*>* Win::_rails [private]

Provide a rails storage place.

Definition at line 275 of file win.h.

Referenced by addRail(), clearModel(), removeRail(), setRailState(), and Win().

QList<EnginesArea*>* Win::_enginesAreas [private]

Provide an engine areas storage place.

Definition at line 278 of file win.h.

Referenced by addEnginesArea(), clearModel(), removeEnginesArea(), save(), and Win().

QMultiHash<int, Engine*>* Win::_engines [private]

Provide an engines storage place.

Definition at line 281 of file win.h.

Referenced by addEngine(), clearModel(), removeEngine(), and Win().

QSvgRenderer* Win::_mapRenderer [private]

Provide a storage for the rules with action = on.

Store the QSvgRenderer for all the rail

Definition at line 287 of file win.h.

Referenced by open(), and setRailsFile().

QString Win::_railsFile [private]

Path to the SVG file containing the rail item which will be shown on a Map

Definition at line 291 of file win.h.

Referenced by railsFile(), and setRailsFile().

Store the current network client.

Definition at line 296 of file win.h.

Referenced by addEngine(), addRail(), initClient(), mkActions(), and Win().

Store the lazy map editior widget.

Definition at line 299 of file win.h.

Referenced by editMode(), mapEdit(), setMultiWinMode(), and Win().

Store the lazy engine editor widget.

Definition at line 302 of file win.h.

Referenced by addEngine(), editMode(), engineEdit(), setMultiWinMode(), and Win().

Config* Win::_config [private]

Store the config object, which contains also a dialog.

Definition at line 305 of file win.h.

Referenced by config(), readSettings(), Win(), and writeSettings().

QMdiArea* Win::_mapArea [private]

The area for the map windows, only for the single windows modus.

Definition at line 308 of file win.h.

Referenced by addMap(), cascadeView(), clearModel(), setMultiWinMode(), tileView(), Win(), zoomBestFit(), zoomIn(), zoomOriginal(), and zoomOut().

QString Win::_userPath [private]

Store the preferred user user path.

Definition at line 311 of file win.h.

Referenced by open(), saveAs(), setUserPath(), and Win().

bool Win::_multiWinFlag [private]

OrK flags, true if the GUI is in multi-windows modus.

Definition at line 314 of file win.h.

Referenced by addEnginesArea(), addMap(), cascadeView(), clearModel(), engineEdit(), mapEdit(), setMultiWinMode(), tileView(), Win(), zoomBestFit(), zoomIn(), zoomOriginal(), and zoomOut().

bool Win::_editModeFlag [private]

OrK flags, true if the GUI is in edition modus.

Definition at line 317 of file win.h.

Referenced by closeEvent(), editMode(), setMultiWinMode(), and Win().

QErrorMessage* Win::_closeMessageDialog [private]

Store the information shown by showCloseMessage()

See also:
showCloseMessage()

Definition at line 321 of file win.h.

Referenced by showCloseMessage(), and Win().

QMenu* Win::_removeMenu [private]

Definition at line 325 of file win.h.

Referenced by editMode(), and mkMenus().

QMenu * Win::_mapsMenu [private]

Definition at line 325 of file win.h.

Referenced by addMap(), clearModel(), and mkMenus().

QMenu * Win::_enginesAreaMenu [private]

Definition at line 325 of file win.h.

Referenced by addEnginesArea(), clearModel(), and mkMenus().

QAction* Win::newAct [private]

Definition at line 327 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::openAct [private]

Definition at line 327 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::saveAct [private]

Definition at line 327 of file win.h.

Referenced by mkActions(), mkMenus(), mkToolBars(), and setDirty().

QAction * Win::saveAsAct [private]

Definition at line 327 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::quitAct [private]

Definition at line 327 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction* Win::addLocAct [private]

Definition at line 328 of file win.h.

Referenced by editMode(), mkActions(), mkMenus(), and mkToolBars().

QAction * Win::addLocAreaAct [private]

Definition at line 328 of file win.h.

Referenced by editMode(), mkActions(), mkMenus(), and mkToolBars().

QAction * Win::addMapAct [private]

Definition at line 328 of file win.h.

Referenced by editMode(), mkActions(), mkMenus(), and mkToolBars().

QAction * Win::mapEditorAct [private]

Definition at line 328 of file win.h.

Referenced by editMode(), mapEdit(), mkActions(), mkMenus(), and mkToolBars().

QAction * Win::engineEditorAct [private]

Definition at line 328 of file win.h.

Referenced by addEngine(), editMode(), engineEdit(), mkActions(), mkMenus(), and mkToolBars().

QAction * Win::editModeAct [private]

Definition at line 328 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction* Win::connectAct [private]

Definition at line 329 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::powerAct [private]

Definition at line 329 of file win.h.

Referenced by mkActions(), mkMenus(), mkToolBars(), net(), and setPower().

QAction* Win::fullscreenAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::hideMenubarAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::zoomInAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::zoomOutAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::zoomBestFitAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::zoomOriginAct [private]

Definition at line 330 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction* Win::cascadeViewAct [private]

Definition at line 331 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction * Win::tileViewAct [private]

Definition at line 331 of file win.h.

Referenced by mkActions(), mkMenus(), and mkToolBars().

QAction* Win::configAct [private]

Definition at line 332 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction* Win::helpAct [private]

Definition at line 333 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction * Win::bugAct [private]

Definition at line 333 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction * Win::translateAct [private]

Definition at line 333 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction * Win::aboutAct [private]

Definition at line 333 of file win.h.

Referenced by mkActions(), and mkMenus().

QAction * Win::aboutQtAct [private]

Definition at line 333 of file win.h.

Referenced by mkActions(), and mkMenus().


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

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