00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00024 
00025 #ifndef DESIGNERGUI_H
00026 #define DESIGNERGUI_H
00027 
00028 #include <QObject>
00029 #include <QList>
00030 #include <QString>
00031 #include <QMap>
00032 class QXmlStreamReader;
00033 #include "../qvgui.h"
00034 #include "facade/itemproperties.h"
00035 #include "facade/itemfactory.h"
00036 #include "slate/slatewindow.h"
00037 #include "slate/informer.h"
00038 #include <QMetaType>
00039 class QVPropertyContainer;
00040 class QVPropertyContainerChange;
00041 
00042 
00053 class QVDesignerGUI: QObject, QVGUI
00054 { 
00055         Q_OBJECT
00056         
00057         public:
00058 
00060                 
00061                 QVDesignerGUI();
00062 
00063 #ifndef DOXYGEN_IGNORE_THIS
00064 
00065 
00067                 virtual void init();
00068         
00070                 void show();
00071 
00073 
00074                 
00075                 QMap<QString, QList<QString> > getItemTypes() const;
00076         
00077                 
00078                 QMap<QString, QList<QString> > getInputItemTypes() const;
00079         
00080                 
00081                 QMap<QString, QList<QString> > getMiddleItemTypes() const;
00082         
00083                 
00084                 QMap<QString, QList<QString> > getOutputItemTypes() const;
00085 
00086                 QString getCppText() const;
00087 
00088                 QString getXMLText();
00089 
00090                 bool loadXML(QString text);
00091 
00092 
00094 
00097                 
00098                 template<typename T> static uint registerUserType(const QString name)
00099                         { return qRegisterMetaType<T>(name.toAscii().data()); }
00100 
00101                 
00102                 uint addItem(const QString type, const QString name, uint lastId = 0);
00103         
00104                 
00105                 bool addLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp, const bool synchronous, const bool sequential);
00106 
00107                 
00108                 bool delItem(const uint id);
00109         
00110                 
00111                 bool delLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp);
00112 
00113                 
00114                 template <class Type> bool setProperty(const uint fromId, const QString fromProp, const Type &value);
00115 
00116                 bool setName(const uint id, const QString name);
00117 
00118                 void showProperties(const uint id);
00119 
00121 
00122                 
00123                 void run();
00124         
00125                 
00126                 void stop();
00127 
00128         public slots:
00129                 void quit();
00130                 void processChange(QVPropertyContainerChange change);
00131                 void dialogChange(QVPropertyContainerChange change);
00132 
00133         private:
00134                 bool createDialog(const uint itemId);
00135                 void deleteDialog(const uint itemId);
00136                 QString getLinkName(QVPropertyContainerChange change);
00137                 QString getLinkName(QString fromName, QString fromProp, QString toName, QString toProp);
00138                 QString getAbsPropName(QString fromName, QString fromProp);
00139                 void createGroups(QList<GroupInfo> &lastGroups, QMap<uint, uint> &oldId_To_NewId);
00140 
00141                 bool readXMLQVApplication(QXmlStreamReader &xmlReader);
00142                 bool readXMLNodes(QXmlStreamReader &xmlReader);
00143                 bool readXMLNode(QXmlStreamReader &xmlReader);
00144                 bool readXMLProperty(QXmlStreamReader &xmlReader, uint id);
00145                 bool readXMLLinks(QXmlStreamReader &xmlReader);
00146                 bool readXMLAsynchronousLink(QXmlStreamReader &xmlReader);
00147                 bool readXMLSynchronousLink(QXmlStreamReader &xmlReader);
00148                 bool readXMLSequentialLink(QXmlStreamReader &xmlReader);
00149                 bool readXMLGroups(QXmlStreamReader &xmlReader);
00150                 bool readXMLGroup(QXmlStreamReader &xmlReader, QList<GroupInfo> &groupInfos);
00151                 bool readXMLChildNode(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00152                 bool readXMLChildGroup(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00153                 bool readXMLVisibleNodeLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00154                 bool readXMLVisibleGroupLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00155                 bool readXMLUnknownElement(QXmlStreamReader &xmlReader);
00156 
00157                 ItemFactory factory;
00158                 SlateWindow slate;
00159                 Informer informer;
00160 
00161                 QMap<uint, QVPropertyContainer *> containers;
00162                 QMap<uint, QVPropertyContainer *> initialContainers;
00163                 QMap<uint, QDialog *> dialogs; 
00164                 QMap<uint, uint> dialogsToContainers; 
00165 
00166                         class CreatedLink
00167                                 {
00168                                 public:
00169                                         CreatedLink(const uint _fromId, const QString _fromProp, const uint _toId, const QString _toProp, const bool _sync, const bool _sequ):
00170                                                 fromId(_fromId), fromProp(_fromProp), toId(_toId), toProp(_toProp), synchronous(_sync), sequential(_sequ) { }
00171 
00172                                         uint fromId;
00173                                         QString fromProp;
00174                                         uint toId;
00175                                         QString toProp;
00176                                         bool synchronous;
00177                                         bool sequential;
00178                                 };
00179 
00180                         class CreatedItem
00181                                 {
00182                                 public:
00183                                         CreatedItem(): type(""), name(""), id(0) { }
00184                                         CreatedItem(const QString _type, const QString _name, uint _id): type(_type), name(_name), id(_id) { }
00185 
00186                                         QString type, name;
00187                                         uint id;
00188                                 };
00189 
00190                         class PropertyChange
00191                                 {
00192                                 public:
00193                                         PropertyChange(const uint contId, const QString prop, const QVariant val): id(contId), propName(prop), value(val) { }
00194 
00195                                         uint id;
00196                                         QString propName;
00197                                         QVariant value;
00198                                 };
00199 
00200                 QMap<QString, CreatedLink> createdLinks; 
00201                 QMap<uint, CreatedItem> createdItems;
00202                 QMap<QString, PropertyChange> propertyChanges; 
00203 
00204                 QMap<uint, uint> XMLId_To_ContainersId; 
00205 
00206 #endif
00207 };
00208 
00209 #endif
00210