00001
00008
00009 #ifndef WIN_H
00010 #define WIN_H
00011
00012 #include <QDebug>
00013
00014 #include <utility>
00015
00016 #include "ork.h"
00017 #include "config.h"
00018
00019 #include "map_editor.h"
00020 #include "engine_editor.h"
00021
00022 #include "map.h"
00023 #include "rail.h"
00024 #include "engines_area.h"
00025 #include "engine.h"
00026
00027 #include "virtual_client.h"
00028 #include "srcp073_client.h"
00029 #include "srcp083_client.h"
00030
00031 #include <QtXml>
00032 #include <QtGui>
00033
00042 class Win : public QMainWindow
00043 {
00044 Q_OBJECT
00045
00046 public :
00047
00050 Win( QSplashScreen* splash, QWidget *parent = 0 ) ;
00051
00055 QString railsFile() ;
00056
00057 public slots :
00058
00062 void setRailsFile( const QString &railsFile ) ;
00063
00067 void addMap( Map* map ) ;
00068
00071 void addMap() ;
00072
00075 void addRail( Rail* rail ) ;
00076
00080 void addEnginesArea( EnginesArea* enginesArea ) ;
00081
00084 void addEnginesArea() ;
00085
00088 void addEngine( Engine* engine ) ;
00089
00092 void addEngine() ;
00093
00095 void addRule( QString trigger, int source, QString action, int target ) ;
00096
00099 void removeMap( Map* map ) ;
00100
00103 void removeRail( Rail* rail ) ;
00104
00107 void removeEngine( Engine* engine ) ;
00108
00111 void removeEnginesArea( EnginesArea* enginesArea ) ;
00112
00119 void setRailState( int address, bool state, bool quiet = TRUE ) ;
00120
00129 void setEngineState( int address, bool direction, int speed, bool light, bool f2, bool f3, bool f4 ) ;
00130
00133 void reportError( QString ) ;
00134
00135 private slots :
00136
00139 void readSettings() ;
00140
00143 void writeSettings() ;
00144
00146 void clearModel() ;
00147
00151 bool save( QString fileName ) ;
00152
00156 bool save() ;
00157
00160 bool saveAs() ;
00161
00163 void open() ;
00164
00167 void open( QString fileName ) ;
00168
00173 bool maybeSave() ;
00174
00176 void mapEdit() ;
00177
00179 void engineEdit() ;
00180
00183 void editMode( bool edition ) ;
00184
00187 void setDirty( bool dirty = TRUE ) ;
00188
00190 void net( bool state ) ;
00191
00194 void setPower( bool state ) ;
00195
00197 void fullscreen() ;
00198
00200 void hideMenubar() ;
00201
00203 void zoomIn() ;
00204
00206 void zoomOut() ;
00207
00209 void zoomBestFit() ;
00210
00212 void zoomOriginal() ;
00213
00215 void tileView() ;
00216
00218 void cascadeView() ;
00219
00221 void config() ;
00222
00224 void help() ;
00225
00227 void bug() ;
00228
00230 void translate() ;
00231
00233 void about() ;
00234
00237 void setMultiWinMode( bool multiWinFlag ) ;
00238
00240 void setUserPath( QString userPath ) ;
00241
00244 void initClient( int protocol ) ;
00245
00248 void showCloseMessage() ;
00249
00250 protected:
00251
00253 void closeEvent(QCloseEvent *event);
00254
00255 private :
00256
00258 void mkActions() ;
00259
00261 void mkMenus() ;
00262
00264 void mkToolBars() ;
00265
00267 void mkStatusBar() ;
00268
00269
00270
00272 QList <Map*> *_maps ;
00273
00275 QMultiHash <int, Rail*> *_rails ;
00276
00278 QList <EnginesArea*> *_enginesAreas ;
00279
00281 QMultiHash <int, Engine*> *_engines ;
00282
00284
00285
00287 QSvgRenderer *_mapRenderer ;
00288
00291 QString _railsFile ;
00292
00293
00294
00296 VirtualClient *_client ;
00297
00299 MapEditor *_mapEditor ;
00300
00302 EngineEditor *_engineEditor ;
00303
00305 Config *_config;
00306
00308 QMdiArea *_mapArea ;
00309
00311 QString _userPath ;
00312
00314 bool _multiWinFlag ;
00315
00317 bool _editModeFlag ;
00318
00321 QErrorMessage *_closeMessageDialog;
00322
00323
00324
00325 QMenu *_removeMenu, *_mapsMenu, *_enginesAreaMenu ;
00326
00327 QAction *newAct, *openAct, *saveAct, *saveAsAct, *quitAct ;
00328 QAction *addLocAct, *addLocAreaAct, *addMapAct, *mapEditorAct, *engineEditorAct, *editModeAct ;
00329 QAction *connectAct, *powerAct;
00330 QAction *fullscreenAct, *hideMenubarAct, *zoomInAct, *zoomOutAct, *zoomBestFitAct, *zoomOriginAct ;
00331 QAction *cascadeViewAct, *tileViewAct;
00332 QAction *configAct ;
00333 QAction *helpAct, *bugAct, *translateAct, *aboutAct, *aboutQtAct ;
00334 } ;
00335
00336 #endif // WIN_H