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
00158 class QVDesignerGUI: QObject, QVGUI
00159 {
00160 Q_OBJECT
00161
00162 public:
00163
00165
00166 QVDesignerGUI();
00167
00168 #ifndef DOXYGEN_IGNORE_THIS
00170
00172 virtual void init();
00173
00175 void show();
00176
00178
00179
00180 QMap<QString, QList<QString> > getItemTypes() const;
00181
00182
00183 QMap<QString, QList<QString> > getInputItemTypes() const;
00184
00185
00186 QMap<QString, QList<QString> > getMiddleItemTypes() const;
00187
00188
00189 QMap<QString, QList<QString> > getOutputItemTypes() const;
00190
00191 QString getCppText() const;
00192
00193 QString getXMLText();
00194
00195 bool loadXML(QString text);
00196
00197
00199
00202
00203 template<typename T> static uint registerUserType(const QString name)
00204 { return qRegisterMetaType<T>(name.toAscii().data()); }
00205
00206
00207 uint addItem(const QString type, const QString name, uint lastId = 0);
00208
00209
00210 bool addLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp, const bool synchronous, const bool sequential);
00211
00212
00213 bool delItem(const uint id);
00214
00215
00216 bool delLink(const uint fromId, const QString fromProp, const uint toId, const QString toProp);
00217
00218
00219 template <class Type> bool setProperty(const uint fromId, const QString fromProp, const Type &value);
00220
00221 bool setName(const uint id, const QString name);
00222
00223 void showProperties(const uint id);
00224
00226
00227
00228 void run();
00229
00230
00231 void stop();
00232
00233 public slots:
00234 void quit();
00235 void processChange(QVPropertyContainerChange change);
00236 void dialogChange(QVPropertyContainerChange change);
00237
00238 private:
00239 bool createDialog(const uint itemId);
00240 void deleteDialog(const uint itemId);
00241 QString getLinkName(QVPropertyContainerChange change);
00242 QString getLinkName(QString fromName, QString fromProp, QString toName, QString toProp);
00243 QString getAbsPropName(QString fromName, QString fromProp);
00244 void createGroups(QList<GroupInfo> &lastGroups, QMap<uint, uint> &oldId_To_NewId);
00245
00246 bool readXMLQVApplication(QXmlStreamReader &xmlReader);
00247 bool readXMLNodes(QXmlStreamReader &xmlReader);
00248 bool readXMLNode(QXmlStreamReader &xmlReader);
00249 bool readXMLProperty(QXmlStreamReader &xmlReader, uint id);
00250 bool readXMLLinks(QXmlStreamReader &xmlReader);
00251 bool readXMLAsynchronousLink(QXmlStreamReader &xmlReader);
00252 bool readXMLSynchronousLink(QXmlStreamReader &xmlReader);
00253 bool readXMLSequentialLink(QXmlStreamReader &xmlReader);
00254 bool readXMLGroups(QXmlStreamReader &xmlReader);
00255 bool readXMLGroup(QXmlStreamReader &xmlReader, QList<GroupInfo> &groupInfos);
00256 bool readXMLChildNode(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00257 bool readXMLChildGroup(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00258 bool readXMLVisibleNodeLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00259 bool readXMLVisibleGroupLink(QXmlStreamReader &xmlReader, GroupInfo &groupInfo);
00260 bool readXMLUnknownElement(QXmlStreamReader &xmlReader);
00261
00262 ItemFactory factory;
00263 SlateWindow slate;
00264 Informer informer;
00265
00266 QMap<uint, QVPropertyContainer *> containers;
00267 QMap<uint, QVPropertyContainer *> initialContainers;
00268 QMap<uint, QDialog *> dialogs;
00269 QMap<uint, uint> dialogsToContainers;
00270
00271 class CreatedLink
00272 {
00273 public:
00274 CreatedLink(const uint _fromId, const QString _fromProp, const uint _toId, const QString _toProp, const bool _sync, const bool _sequ):
00275 fromId(_fromId), fromProp(_fromProp), toId(_toId), toProp(_toProp), synchronous(_sync), sequential(_sequ) { }
00276
00277 uint fromId;
00278 QString fromProp;
00279 uint toId;
00280 QString toProp;
00281 bool synchronous;
00282 bool sequential;
00283 };
00284
00285 class CreatedItem
00286 {
00287 public:
00288 CreatedItem(): type(""), name(""), id(0) { }
00289 CreatedItem(const QString _type, const QString _name, uint _id): type(_type), name(_name), id(_id) { }
00290
00291 QString type, name;
00292 uint id;
00293 };
00294
00295 class PropertyChange
00296 {
00297 public:
00298 PropertyChange(const uint contId, const QString prop, const QVariant val): id(contId), propName(prop), value(val) { }
00299
00300 uint id;
00301 QString propName;
00302 QVariant value;
00303 };
00304
00305 QMap<QString, CreatedLink> createdLinks;
00306 QMap<uint, CreatedItem> createdItems;
00307 QMap<QString, PropertyChange> propertyChanges;
00308
00309 QMap<uint, uint> XMLId_To_ContainersId;
00310
00311 #endif
00312 };
00313
00314 #endif
00315