return NULL;
}
+ /*
// creating the top widget/scene
topGroup = new GroupWidget(NULL,this,params);
currentGroup = topGroup;
params->setTopScene(scene);
params->setCurrentScene(scene);
-
+*/
try {
- params->loadProject(root);
+ topGroup = params->loadProject(root);
}
catch(Exception e){
cerr << qPrintable(e.getDefaultMessage()) << endl;
foreach(GroupWidget* win, groupList) {
win->deleteLater();
}
+ groupList.clear();
params->destroyGraph();
+ topGroup = NULL;
+ currentGroup = NULL;
+ sceneCounter = 0;
}
bool Dispatcher::connect(InterfaceItem *iface1, InterfaceItem *iface2) {
if (item->refInter->getOwner()->isGroupBlock()) {
item->refInter->setName(text);
}
- item->setName(text);
-
}
else {
QMessageBox::warning(NULL,"Error in given name",
return topGroup;
}
-void Dispatcher::addNewEmptyGroup(GroupScene* scene) {
+GroupWidget* Dispatcher::addNewEmptyGroup(GroupScene* scene, bool show) {
static QString fctName = "Dispatcher::addNewEmptyGroup();";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
params->unsaveModif = true;
GroupWidget* child = createChildScene(scene->getGroupWidget(),newItem);
- child->show();
+ if (show) child->show();
+ return child;
}
cout << "call to " << qPrintable(fctName) << endl;
#endif
- // getting back the goup block already created
- GroupBlock* groupBlock = NULL;
- if (upperItemOfGroupItem != NULL) {
- groupBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock());
- }
- // creating the view part of the group
- GroupItem *groupItem = new GroupItem(upperItemOfGroupItem,groupBlock,this,params);
- // creating the group widget
- GroupWidget* group = new GroupWidget(parentWidget, this, params);
- // getting the newly created scene
- GroupScene *scene = group->getScene();
- scene->setId(sceneCounter++);
- // affecting group item to the scene
- scene->setGroupItem(groupItem);
- groupList.append(group);
-
- mainWindow->getLibrary()->updateComboScene();
+ GroupWidget* group = NULL;
+ /* NB: this method may be called during design process or when loading
+ a project. In this case, upperItemOfGroupItem is NULL, thus a lot of things
+ cannot be initialized yet. This is why there are 2 cases below
+ */
+ if (upperItemOfGroupItem != NULL) {
+ // getting back the goup block already created
+ GroupBlock* groupBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock());
+ // creating the view part of the group
+ GroupItem *groupItem = new GroupItem(upperItemOfGroupItem,groupBlock,this,params);
+ // creating the group widget
+ group = new GroupWidget(parentWidget, this, params);
+ // getting the newly created scene
+ GroupScene *scene = group->getScene();
+ scene->setId(sceneCounter++);
+ // affecting group item to the scene
+ scene->setGroupItem(groupItem);
+ groupList.append(group);
+
+ mainWindow->getLibrary()->updateComboScene();
+ }
+ else {
+ GroupItem *groupItem = new GroupItem(this,params);
+ // creating the group widget
+ group = new GroupWidget(parentWidget, this, params);
+ // getting the newly created scene
+ GroupScene *scene = group->getScene();
+ // affecting group item to the scene
+ scene->setGroupItem(groupItem);
+ groupList.append(group);
+ }
return group;
}