NCL Composer  0.1.5
 All Classes Functions Variables Pages
qnstcomposerplugin.h
1 /*
2  * Copyright 2011 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 #ifndef QNSTCOMPOSERPLUGIN_H
19 #define QNSTCOMPOSERPLUGIN_H
20 
21 #include <QMap>
22 
23 #include <core/extensions/IPlugin.h>
24 using namespace composer::extension;
25 
26 #include "ui/view/qnstview.h"
27 
28 //
29 // ATTENTION: This code needs a refactoring.
30 //
31 
33 {
34  Q_OBJECT
35 
36 public:
37  QnstComposerPlugin(QObject* parent = 0);
38 
40 
41  virtual void init();
42 
43  virtual QWidget* getWidget();
44 
45  virtual bool saveSubsession();
46 
47 public slots:
48  virtual void updateFromModel();
49 
50  virtual void onEntityAdded(QString pluginID, Entity *entity);
51 
52  virtual void errorMessage(QString error);
53 
54  virtual void onEntityChanged(QString pluginID, Entity *entity);
55 
56  virtual void onEntityRemoved(QString pluginID, QString entityID);
57 
58  virtual void changeSelectedEntity(QString pluginID, void* entityUID);
59 
60  void clearValidationError(QString pluginID, void *param);
61 
62  void validationError(QString pluginID, void *param);
63 
64 
65  /* From Core */
66  void requestEntitySelection(const QString uid);
67 
68  void requestEntityAddition(Entity* entity);
69 
70  void requestEntityRemotion(Entity* entity);
71 
72  void requestEntityChange(Entity* entity);
73 
74  void requestEntitySelection(Entity* entity);
75 
76  /* From View */
77  void notifyEntityAddedInView (const QString uid, const QString parent,
78  QMap<QString, QString> properties);
79 
80  void notifyEntityDeletedInView(const QString uid);
81 
82  void notifyEntityChangedInView(const QString uid,
83  QMap<QString, QString> properties);
84 
85 private:
86  QString getUidById(QString id);
87 
88  QString getUidById(QString id, Entity* entity);
89 
90  QString getUidByName(QString name, Entity* entity);
91 
92  void createWidgets();
93 
94  void createConnections();
95 
96  /* FROM NCL COMPOSER CORE */
97  void requestImportBaseAddition(Entity* entity);
98 
99  void requestImportBaseChange(Entity* entity);
100 
101  void requestCausalConnectorAddition(Entity* entity);
102 
103  void requestCausalConnectorChange(Entity* entity);
104 
105  void requestSimpleConditionAddition(Entity* entity);
106 
107  void requestSimpleConditionChange(Entity* entity);
108 
109  void requestSimpleActionAddition(Entity* entity);
110 
111  void requestSimpleActionChange(Entity* entity);
112 
113  void requestConnectorParamAddition(Entity* entity);
114 
115  void requestConnectorParamChange(Entity* entity);
116  /* END FROM NCL COMPOSER CORE */
117 
118 
119 
120  /* FROM QNSTVIEW */
121  void requestBodyDependence();
122 
123  void requestConnectorAddition(const QString uid, const QString parent,
124  const QMap<QString, QString> &properties);
125 
126  void requestComplexConnectorAddition(const QString uid,
127  const QString parent,
128  const QMap<QString, QString> &properties);
129 
130  void requestBindAddition(const QString uid, const QString parent,
131  const QMap<QString, QString> &properties);
132 
133  void requestConnectorDependence();
134 
135  void requestConnectorBaseDependence();
136  /* END FROM QNSTVIEW */
137 
138 
139 private:
140  int n;
141 
142  QnstView* view;
143 
144  QString request;
145  QMap <QString, QString> entities; // core -> structural
146  QMap <QString, QString> nclIDtoStructural; // nclId -> structural ID
147  QList <QString> dirtyEntities;
148  QList <QString> previousCoreID;
149 
150  QString lastSelected;
151 
152  /* Functions to handle the "sinchronization with core" */
153  bool isSyncingFromTextual;
154  void cacheNCLIds();
155  QString insertNCLIDIfEmpty(Entity *entity);
156  QString getNCLIdFromEntity(Entity *entity);
157  bool isEntityHandled(Entity *entity);
158  void syncNCLIdsWithStructuralIds();
159 
160 public slots:
161  void textualStartSync(QString, void*); /* from textual plugin */
162  void textualFinishSync(QString, void*); /* from textual plugin */
163  /* End "synchronization with core". */
164 };
165 
166 #endif // QNSTCOMPOSERPLUGIN_H