Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SCDATAMODEL_H
00022 #define SCDATAMODEL_H
00023
00024 #include "scdatamodel_global.h"
00025 #include "sctransition.h"
00026 #include "scstate.h"
00027 #include <QList>
00028 #include "scxmlreader.h"
00029 #include <QXmlStreamWriter>
00030 class QGraphicsScene;
00031
00066 class SCDATAMODELSHARED_EXPORT SCDataModel : public QObject
00067 {
00068 Q_OBJECT
00069
00070
00071 public:
00072 static SCDataModel * singleton();
00073
00074
00075 void open(QString scxmlFile);
00076
00077 bool save(QString scxmlFile, QString & message);
00078 void initializeEmptyStateMachine();
00079
00080 void getStates(QList<SCState *>& list);
00081 void getAllStates(QList<SCState *>& list);
00082 SCState* getStateByName(QString name);
00083 SCTransition * getTransitionByName(QString name);
00084 QObject * getItemByName(QString name);
00085 SCState* getTopState( );
00086 void setScene(QGraphicsScene *scene);
00087 QGraphicsScene * getScene();
00088
00089 static SCState *getAsState(QObject*);
00090 static SCTransition *getAsTransition(QObject*);
00091 static TextBlock *getAsTextBlock(QObject*);
00092
00096 SCState* insertNewState(SCState *parent);
00097
00103 SCTransition* insertNewTransition(SCState *source, QString event );
00104
00105 void logError(QString message);
00106 void logInfo(QString message);
00107
00108
00109 signals:
00110 void openCompleted(bool sucess, QStringList message);
00111 void newStateSignal(SCState * newState);
00112 void newTransitionSignal(SCTransition * newTransition);
00113
00114 private slots:
00115 void handleReaderDone(bool sucess, QStringList message);
00116 void handleMakeANewState(StateAttributes*);
00117 void handleMakeANewTransition(TransitionAttributes*);
00118 void handleLeaveTransitionElement();
00119 void handleMakeANewTransitionPath(QString path);
00120 void handleTransitUp();
00121 void handleTransitDown();
00122 void handleMakeANewIDTextBlock(TextBlockAttributes *attributes);
00123
00124 private:
00125 SCXMLReader _reader;
00126 QXmlStreamWriter *_writer;
00127 int _level;
00128 int _topLevel;
00129 SCState *_currentState;
00130 SCTransition *_currentTransition;
00131 SCState *_topState;
00132 QGraphicsScene * _scene;
00133
00134
00135
00136 SCDataModel(QObject * parent=NULL);
00137
00138 };
00139
00140 #endif // SCDATAMODEL_H