• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

C:/Users/David/Documents/QtProjects/visualsc/scdatamodel/scdatamodel.h

Go to the documentation of this file.
00001 /*
00002     visualsc - Visual State Chart Editing for SCXML State Engines
00003     Copyright (C) 2011  David W. Drell (david@davidwdrell.net) and
00004     Contributing Authors:
00005 
00006 
00007     This program is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     // direct interface
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 //private methods
00136     SCDataModel(QObject * parent=NULL);
00137 
00138 };
00139 
00140 #endif // SCDATAMODEL_H

Generated on Mon Sep 26 2011 06:59:25 for visualsc by  doxygen 1.7.1