1 #include "Dispatcher.h"
2 #include "Parameters.h"
3 #include "MainWindow.h"
6 #include "ReferenceBlock.h"
7 #include "GroupBlock.h"
8 #include "FunctionalBlock.h"
10 #include "ConnectedInterface.h"
11 #include "ReferenceInterface.h"
12 #include "GroupInterface.h"
13 #include "FunctionalInterface.h"
15 #include "GroupWidget.h"
16 #include "GroupScene.h"
17 #include "GroupItem.h"
19 #include "InterfaceItem.h"
20 #include "ConnectionItem.h"
22 #include "BlockLibraryWidget.h"
23 #include "BlockLibraryTree.h"
25 #include "InterfacePropertiesWindow.h"
28 Dispatcher::Dispatcher(Parameters* _params, MainWindow* _window) {
31 params->setDispatcher(this);
36 GroupWidget *Dispatcher::loadProject(const QString& filename) {
40 root = params->openProjectFile(filename);
42 catch(Exception err) {
46 // creating the top widget/scene
47 topGroup = new GroupWidget(NULL,this,params);
48 currentGroup = topGroup;
49 // getting the newly created scene
50 GroupScene *scene = topGroup->getScene();
51 params->setTopScene(scene);
52 params->setCurrentScene(scene);
55 params->loadProject(root);
58 cerr << qPrintable(e.getDefaultMessage()) << endl;
59 cerr << "Aborting ..." << endl;
60 // TO DO : deleteting topGroup and all
67 void Dispatcher::closeCurrentProject() {
69 foreach(GroupWidget* win, groupList) {
72 params->destroyGraph();
75 bool Dispatcher::connect(InterfaceItem *iface1, InterfaceItem *iface2) {
77 ConnectedInterface* ref1 = iface1->refInter;
78 ConnectedInterface* ref2 = iface2->refInter;
79 // connect both interface
84 if (ref1->canConnectTo(ref2)) {
85 ok1 = ref1->connectTo(ref2);
86 ok1 = ok1 & ref2->connectFrom(ref1);
88 if (ref2->canConnectTo(ref1)) {
89 ok2 = ref2->connectTo(ref1);
90 ok2 = ok2 & ref1->connectFrom(ref2);
92 if ((ok1 == true) || (ok2 == true)) {
94 iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2);
97 params->unsaveModif = true;
103 void Dispatcher::checkSelection(){
104 InterfaceItem *iface1 = NULL;
105 InterfaceItem *iface2 = NULL;
107 GroupScene *scene = params->getCurrentScene();
108 QList<AbstractBoxItem*> list = scene->getGroupAndBlocks();
109 foreach(AbstractBoxItem *block, list){
110 InterfaceItem *tmp = block->getCurrentInterface();
112 if (iface1 == NULL) {
120 if(iface1 != NULL && iface2 != NULL){
121 connect(iface1,iface2);
125 void Dispatcher::unselectAllItems(int direction){
127 GroupScene *scene = params->getCurrentScene();
129 foreach(BoxItem* block, scene->getBlockItems()) {
130 block->setSelected(false);
131 block->setCurrentInterface(NULL);
133 scene->unselecteInterfaces();
137 void Dispatcher::setCurrentGroupWidget(GroupWidget *win){
139 win->changeConnectionMode(-1);
141 params->setCurrentScene(win->getScene());
144 void Dispatcher::changeConnectionMode(int mode){
147 foreach(GroupWidget* win, groupList){
149 QToolButton* buttonNewConnection = win->getButtonNewConnection();
151 QPalette pal = buttonNewConnection->palette();
154 if(params->sceneMode != Parameters::EditOnConnection){
155 params->sceneMode = Parameters::EditOnConnection;
156 pal.setColor(QPalette::Button, QColor(Qt::lightGray));
158 params->sceneMode = Parameters::EditNoOperation;
159 pal.setColor(QPalette::Button, QColor("#edeceb"));
162 else if(mode == Parameters::EditOnConnection){
163 params->sceneMode = Parameters::EditOnConnection;
164 pal.setColor(QPalette::Button, QColor(Qt::lightGray));
167 params->sceneMode = Parameters::EditNoOperation;
168 pal.setColor(QPalette::Button, QColor("#edeceb"));
170 unselectAllInterfaces();
172 buttonNewConnection->setAutoFillBackground(true);
173 buttonNewConnection->setPalette(pal);
174 buttonNewConnection->update();
179 void Dispatcher::rename(AbstractBoxItem *item){
182 QString text = QInputDialog::getText(NULL, "Rename an element",
183 "New name:", QLineEdit::Normal,
184 item->getRefBlock()->getName(), &ok);
187 if(!text.isEmpty() && text.length() < 30){
188 item->getRefBlock()->setName(text);
189 if(item->isGroupItem()){
190 if (currentGroup->isTopGroup()) {
191 mainWindow->setWindowTitle("blast - "+text);
194 currentGroup->setWindowTitle("blast - "+text);
199 QMessageBox::warning(NULL,"Error in given name",
200 "the element name must be shorter than 30 characters and can't be empty!",
207 void Dispatcher::rename(InterfaceItem *item){
209 QString text = QInputDialog::getText(NULL, "Rename an interface",
210 "New name:", QLineEdit::Normal,
211 item->refInter->getName(), &ok);
213 /* CAUTION: when renaming an interface item, there are two cases :
214 - it refers to a functional block interface (fbi): the fbi keeps its name
215 and the new name is given to item
216 - it refers to a group block interface (gbi) : both gbi and item store the new name
219 if(ok && !text.isEmpty() && text.length() < 30) {
220 if (item->refInter->getOwner()->isGroupBlock()) {
221 item->refInter->setName(text);
226 QMessageBox::warning(NULL,"Error in given name",
227 "the interface name must be shorter than 30 characters and can't be empty!",
233 void Dispatcher::duplicateBlock(BoxItem *item){
235 GroupScene *scene = params->getCurrentScene();
236 AbstractBlock* block = item->getRefBlock();
237 AbstractBlock *newBlock;
239 // only duplicate functional blocks
240 if(block->isFunctionalBlock()) {
242 // adding to the model
243 FunctionalBlock* funBlock = (FunctionalBlock*)block;
244 newBlock = params->duplicateFunctionalBlock(funBlock);
245 // adding to the view
246 scene->createBlockItem(newBlock);
248 params->unsaveModif = true;
252 void Dispatcher::duplicateInterface(InterfaceItem *item){
253 AbstractInterface *refI = item->refInter;
254 if (! refI->isFunctionalInterface()) return;
256 AbstractBlock *refB = refI->getOwner();
257 if(! refB->isFunctionalBlock()) return;
259 FunctionalInterface* iface = (FunctionalInterface*)refI;
260 AbstractInterface *otherRef = iface->clone();
261 if (otherRef == NULL) {
262 QMessageBox::warning(NULL,"Error while cloning an interface","the interface cannot be cloned because its maximum multiplicity is reached", QMessageBox::Ok);
266 refB->addInterface(otherRef);
268 InterfaceItem *otherIface = new InterfaceItem(item->getPosition(),item->getOrientation(),(ConnectedInterface*)otherRef,item->getOwner(),params);
269 item->getOwner()->addInterface(otherIface,true);
273 void Dispatcher::addBlock(int idCategory, int idBlock) {
275 GroupScene *scene = params->getCurrentScene();
276 FunctionalBlock* newOne = params->addFunctionalBlock(idCategory, idBlock);
277 scene->createBlockItem(newOne);
281 GroupWidget *Dispatcher::createTopScene(){
283 // creating the model part of the group
284 Graph* graph = params->createGraph();
285 GroupBlock *refBlock = graph->getTopGroup();
287 // creating a fake and not connected interface
288 //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top);
290 // creating the group widget
291 topGroup = new GroupWidget(NULL,this,params);
292 currentGroup = topGroup;
293 // getting the newly created scene
294 GroupScene *scene = topGroup->getScene();
295 params->setTopScene(scene);
296 params->setCurrentScene(scene);
297 // creating the view part of the group
298 GroupItem *group = new GroupItem(NULL,refBlock,this,params);
300 // adding the fake interface to the top group item
301 //InterfaceItem* item = new InterfaceItem(0.0 , Parameters::West, (ConnectedInterface*)iface, group, params);
302 //group->addInterface(item,true);
304 scene->setGroupItem(group);
309 GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) {
311 GroupBlock* parentBlock = NULL;
312 if (upperItemOfGroupItem != NULL) {
313 parentBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock());
315 // creating the model part of the group
316 GroupBlock *groupBlock = new GroupBlock(parentBlock);
317 groupBlock->setName("no name");
318 // creating the view part of the group
319 GroupItem *groupItem = new GroupItem(upperItemOfGroupItem,groupBlock,this,params);
320 // creating the group widget
321 GroupWidget* group = new GroupWidget(parentWidget, this, params);
322 // getting the newly created scene
323 GroupScene *scene = group->getScene();
324 // affecting group item to the scene
325 scene->setGroupItem(groupItem);
330 void Dispatcher::showRaiseWindow(AbstractBoxItem *item) {
331 GroupWidget* win = item->getScene()->getGroupWindow();
332 if (win->isTopGroup()) {
341 params->setCurrentScene(currentGroup->getScene());
344 void Dispatcher::showRstClkInter(AbstractBoxItem *item) {
346 item->setRstClkVisible(!item->isRstClkVisible());
347 item->resetInterfacesPosition();
349 item->getScene()->updateConnectionItemsShape();
352 void Dispatcher::addNewFullGroup() {
356 QList<BlockItem*> listBlocks = params->getCurrentScene()->getSelectedBlocks(); //selected blocks in the current scene
357 QList<AbstractBlock*> listAbstractBlocks; //abstract blocks in the group
358 QList<ConnectionItem *> connections = params->getCurrentScene()->getConnectionItems();
360 /* What must be done:
361 1 - creating a new GroupBlock
362 2 - moving the selected blocks from the current GroupBlock to the new GroupBlock
363 3 - creating a BlockItem that references the new GroupBlock
364 4 - creating a new GroupWidget
365 5 - creating a new GroupItem added to the scene of the GroupWidget
369 /* step 1 : creating new GroupBlock that will have as a parent the GroupBlock
370 associated to the GroupItem of the current scene
372 GroupBlock* parentBlock = params->getCurrentScene()->getGroupItem()->getRefBlock();
373 GroupBlock* newGroupBlock = new GroupBlock(parentBlock);
374 /* step 2: moving selected blocks */
375 foreach(BlockItem* blockItem, listBlocks) {
376 parentBlock->removeBlock(blockItem->getRefBlock());
377 newGroupBlock->addBlock(blockItem->getRefBlock());
380 GroupItem *parent = currentGroup->getScene()->getGroupItem();
381 GroupBlock *groupBlock = new GroupBlock(((GroupBlock*)parent->getRefBlock()),params->currentWindow);
382 BlockItem *blockItem = new BlockItem(params->getCurrentScene()->getGroupItem(),groupBlock,this,params);
383 GroupItem *groupItem = new GroupItem(blockItem,groupBlock,this,params);
385 //create the new window
386 GroupWidget* win = new GroupWidget(this,params);
387 win->getScene()->setGroupItem(groupItem);
388 win->getScene()->addItem(groupItem);
389 ((GroupBlock*)groupItem->getRefBlock())->setWindow(win);
390 params->addWindow(win);
394 params->getCurrentScene()->addBlockItem(blockItem);
395 params->getCurrentScene()->addItem(blockItem);
396 ((GroupItem*)params->getCurrentScene()->getGroupItem())->addBlockItem(blockItem);
398 //replace selected blocks in the group
399 foreach(AbstractBoxItem *block, listBlocks){
400 ((GroupItem*)block->getParentItem())->removeBlockItem(block);
401 ((GroupBlock*)block->getParentItem()->getRefBlock())->removeBlock(block->getRefBlock());
402 params->getCurrentScene()->removeItem(block);
403 params->getCurrentScene()->removeBlockItem(block);
405 groupBlock->addBlock(block->getRefBlock());
406 listAbstractBlocks.append(block->getRefBlock());
408 block->setUpperItem(groupItem);
409 groupItem->addBlockItem(block);
410 win->getScene()->addItem(block);
411 win->getScene()->addBlockItem(block);
414 //replace connection between selected blocks in the group
415 foreach(ConnectionItem *conn, connections){
416 if(listBlocks.contains(conn->getFromInterfaceItem()->getOwner())){
417 if(listBlocks.contains(conn->getToInterfaceItem()->getOwner())){
418 parent->removeConnection(conn);
419 params->getCurrentScene()->removeItem(conn);
421 groupItem->addConnection(conn);
422 win->getScene()->addItem(conn);
427 //create new interfaces and connections for the new group
428 foreach(AbstractBoxItem *block, listBlocks){
429 foreach(InterfaceItem *inter, block->getInterfaces()){
430 cout << "inter : " << inter->getName().toStdString() << endl;
431 if(inter->refInter->getConnectedFrom() != NULL && inter->refInter->getDirection() == AbstractInterface::Input){
432 cout << "connected from non null" << endl;
433 if(!listAbstractBlocks.contains(inter->refInter->getConnectedFrom()->getOwner())){
435 AbstractInterface *iface = inter->refInter->clone(0);
436 iface->setName(iface->getName()+"_group");
437 groupBlock->addInterface(iface);
439 InterfaceItem *ifaceItem = new InterfaceItem(0,Parameters::East,iface,blockItem,params);
440 blockItem->addInterface(ifaceItem);
441 blockItem->resetInterfacesPosition();
443 InterfaceItem *ifaceGroupItem = new InterfaceItem(0,Parameters::West,iface,groupItem,params);
444 groupItem->addInterface(ifaceGroupItem);
445 groupItem->resetInterfacesPosition();
446 foreach(ConnectionItem* conn, currentGroup->getScene()->getInterfaceConnections(inter)){
447 if(conn->getToInterfaceItem() == inter){
448 conn->setToInterfaceItem(ifaceItem);
449 ifaceItem->refInter->setConnectedFrom(NULL);
450 conn->getFromInterfaceItem()->refInter->clearConnectedTo();
451 connect(ifaceItem,conn->getFromInterfaceItem());
454 params->setCurrentWindow(win);
456 inter->refInter->setConnectedFrom(NULL);
457 ifaceGroupItem->refInter->clearConnectedTo();
458 connect(inter,ifaceGroupItem);
459 params->setCurrentWindow(mainWindow);
463 if(!inter->refInter->getConnectedTo().isEmpty() && inter->refInter->getDirection() == AbstractInterface::Output){
464 cout << "connected to non null" << endl;
465 foreach(AbstractInterface *iface, inter->refInter->getConnectedTo()){
466 if(!listAbstractBlocks.contains(iface->getOwner())){
468 AbstractInterface *iface = inter->refInter->clone(0);
469 iface->setName(iface->getName()+"_group");
470 groupBlock->addInterface(iface);
472 InterfaceItem *ifaceItem = new InterfaceItem(0,Parameters::East,iface,blockItem,params);
473 blockItem->addInterface(ifaceItem);
474 blockItem->resetInterfacesPosition();
476 foreach(ConnectionItem* conn, currentGroup->getScene()->getInterfaceConnections(inter)){
477 if(conn->getFromInterfaceItem() == inter){
478 conn->setFromInterfaceItem(ifaceItem);
479 iface->addConnectedTo(conn->getToInterfaceItem()->refInter);
480 conn->getToInterfaceItem()->refInter->setConnectedFrom(iface);
484 InterfaceItem *ifaceGroupItem = new InterfaceItem(0,Parameters::East,iface,groupItem,params);
485 groupItem->addInterface(ifaceGroupItem);
486 groupItem->resetInterfacesPosition();
487 inter->refInter->clearConnectedTo();
488 ifaceGroupItem->refInter->setConnectedFrom(NULL);
489 connect(ifaceGroupItem,inter);
498 parent->updateShape();
499 currentGroup->getScene()->updateConnectionItemsShape();
501 groupItem->updateShape();
502 win->getScene()->updateConnectionItemsShape();
503 groupItem->update(groupItem->boundingRect());
508 void Dispatcher::removeBlock(AbstractBoxItem *item) {
512 GroupScene *scene = params->getCurrentScene();
513 AbstractBlock* block = item->getRefBlock();
514 if (block->isReferenceBlock()) return;
516 GroupBlock* group = (GroupBlock*)item->getParentItem()->getRefBlock();
518 removeConnections(item);
521 group->removeBlock(block);
523 //remove the associated window
524 if(block->isGroupBlock()){
525 foreach(QWidget *window, params->windows){
526 if(!window->inherits("MainWindow")){
527 if(((GroupWidget*)window)->getScene()->getGroupItem()->getRefBlock() == block){
528 params->removeWindow(window);
537 //supprimer l'item de la scène
538 cout << "dispatcher : remove item of scene " << params->currentWindow << endl;
539 ((GroupItem *)scene->getGroupItem())->removeBlockItem(item);
540 scene->removeItem(item);
541 scene->removeBlockItem(item);
544 ((GroupItem *)scene->getGroupItem())->updateShape();
546 params->updateToolbar();
547 params->unsaveModif = true;
552 void Dispatcher::removeAllBlockConnections(AbstractBoxItem *block) {
554 GroupScene* scene = block->getScene();
555 // supprimer les connections associées au bloc
556 foreach (ConnectionItem *conn, scene->getConnectionItems()) {
557 if(conn->getToInterfaceItem()->owner == block || conn->getFromInterfaceItem()->owner == block){
558 removeConnection(conn);
561 scene->getGroupItem()->updateInterfacesAndConnections();
564 void Dispatcher::removeConnection(ConnectionItem *conn) {
566 GroupScene *scene = params->getCurrentScene();
567 GroupItem* currentGroup = scene->getGroupItem();
569 conn->getFromInterfaceItem()->unconnectTo(conn->getToInterfaceItem());
571 scene->removeConnectionItem(conn);
574 currentGroup->updateInterfacesAndConnections();
575 params->unsaveModif = true;
578 void Dispatcher::removeUselessGroupInterfaces() {
580 GroupScene *scene = params->getCurrentScene();
581 GroupItem* currentGroup = scene->getGroupItem();
583 foreach(InterfaceItem *inter, currentGroup->getInterfaces()) {
584 if(inter->refInter->getConnectedTo().length() == 0) {
585 // NB : remove from view also remove from model
586 currentGroup->removeInterface(inter);
589 scene->updateConnectionItemsShape();
592 void Dispatcher::showBlocksLibrary(){
593 cout << "showing block library" << endl;
594 mainWindow->getLibrary()->show();
595 mainWindow->getLibrary()->raise();
598 void Dispatcher::showProperties(InterfaceItem *inter)
600 new InterfacePropertiesWindow(inter);
603 /* connectInterToGroup() :
604 The only way for a block (functional of group) within a GroupItem to be connected
605 to the latter is to right-click on one of its interfaces and to choose "connect to group".
606 That action will create a new InterfaceItem on the GroupItem and a connectionItem between the
609 void Dispatcher::connectInterToGroup(InterfaceItem *item){
611 // getting the GroupBlock and GroupItem that are parent of the block that owns item
612 ConnectedInterface *refInter = item->refInter;
613 GroupBlock* parentBlock = AB_TO_GRP(refInter->getOwner()->getParent());
614 GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
616 // creating/adding the group interface in the graph model
617 GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getLevel());
618 groupInter->setType(refInter->getType());
619 groupInter->setWidth(refInter->getWidth());
620 groupInter->setPurpose(refInter->getPurpose());
621 parentItem->getRefBlock()->addInterface(groupInter);
623 // connect both interface
625 if (refInter->getDirection() == AbstractInterface::Output) {
626 ok = refInter->connectTo(groupInter);
627 ok = ok & groupInter->connectFrom(refInter);
629 else if (refInter->getDirection() == AbstractInterface::Input) {
630 ok = groupInter->connectTo(refInter);
631 ok = ok & refInter->connectFrom(groupInter);
633 else if (refInter->getDirection() == AbstractInterface::InOut) {
634 ok = refInter->connectTo(groupInter);
635 ok = ok & groupInter->connectFrom(refInter);
636 ok = ok & groupInter->connectTo(refInter);
637 ok = ok & refInter->connectFrom(groupInter);
640 cerr << "abnormal case while connecting a block iface to its parent group" << endl;
642 // creating/adding the group interface in the current scene model, and connection item
643 InterfaceItem *groupIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parentItem,params);
644 parentItem->addInterface(groupIfaceItem,true);
646 parentItem->getScene()->createConnectionItem(item, groupIfaceItem);
648 // if groupItem is not topGroup, must also add a new interface to the parent BlockItem
649 BoxItem* parent2Item = parentItem->getParentItem();
650 if(parent2Item != NULL){
651 InterfaceItem *blockIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parent2Item,params);
652 parent2Item->addInterface(blockIfaceItem,true);
656 parentItem->getScene()->updateConnectionItemsShape();
658 params->unsaveModif = true;
663 void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) {
664 static QString fctName = "Dispatcher::disconnectInterFromGroup()";
666 cout << "call to " << qPrintable(fctName) << endl;
669 // getting the GroupBlock and GroupItem that are parent of the block that owns item
670 ConnectedInterface *refInter = item->refInter;
671 ConnectedInterface *groupInter = NULL;
672 GroupBlock* parentGroup = AB_TO_GRP(refInter->getOwner()->getParent());
673 GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
675 // removing the connection from graph
677 cout << "removing connections from graph ..." ;
680 if (refInter->getDirection() == AbstractInterface::Output) {
681 groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
682 refInter->clearConnectedTo();
683 groupInter->clearConnectedFrom();
685 else if (refInter->getDirection() == AbstractInterface::Input) {
686 groupInter = refInter->getConnectedFrom();
687 refInter->clearConnectedFrom();
688 groupInter->clearConnectedTo();
690 else if (refInter->getDirection() == AbstractInterface::InOut) {
691 groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
692 refInter->clearConnectedTo();
693 refInter->clearConnectedFrom();
694 groupInter->clearConnectedTo();
695 groupInter->clearConnectedFrom();
698 cout << "done." << endl ;
701 if (groupInter == NULL) {
702 cerr << "abnormal case 1 while removing an interface item of a block, linked to a parent group" << endl;
706 cout << "getting group interface item, and connection item ..." ;
710 InterfaceItem* groupIfaceItem = parentItem->searchInterfaceByRef(groupInter);
711 if (groupIfaceItem == NULL) {
712 cerr << "abnormal case 2 while removing an interface item of a block, linked to a parent group" << endl;
714 ConnectionItem* conn = parentItem->getScene()->searchConnectionItem(item,groupIfaceItem);
716 cerr << "abnormal case 3 while removing an interface item of a block, linked to a parent group" << endl;
719 cout << "done." << endl ;
722 // removing the interface group item from the group item, and the connection item
724 cout << "removing group interface item, and connection item ..." ;
727 item->removeConnectionItem(conn);
728 groupIfaceItem->removeConnectionItem(conn);
729 parentItem->removeInterface(groupIfaceItem); // CAUTION : this deletes the interface item.
730 parentItem->getScene()->removeConnectionItem(conn);
732 cout << "done." << endl ;
735 // removing the interface box item in the parent scene
737 cout << "removing the inteeface item of box item in parent scene if needed ..." ;
740 BoxItem* parent2Item = parentItem->getParentItem();
741 if (parent2Item != NULL) {
742 InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter);
743 parent2Item->removeInterface(group2IfaceItem);
746 cout << "done." << endl ;
749 // removing the interface group from the group
751 cout << "removing group interface ..." ;
753 parentGroup->removeInterface(groupInter);
755 cout << "done." << endl ;
760 void Dispatcher::removeGroupInterface(InterfaceItem *item) {
761 static QString fctName = "Dispatcher::removeGroupInterface()";
763 cout << "call to " << qPrintable(fctName) << endl;
766 /* NB: there is a single connection between item and another one that is owned
767 by a BoxItem. Thus, we just have to find it and to call disconnectInterFromGroup();
769 ConnectionItem* conn = item->connections.at(0);
770 if (conn->getFromInterfaceItem() == item) {
771 disconnectInterFromGroup(conn->getToInterfaceItem());
774 disconnectInterFromGroup(conn->getFromInterfaceItem());
778 GroupScene* Dispatcher::searchSceneById(int id) {
779 foreach(GroupWidget *group, groupList){
780 if(group->getScene()->getId() == id)
781 return group->getScene();
783 cout << "search scene by id :" << id << " :: not found..." << endl;
787 GroupItem *Dispatcher::searchGroupItemById(int id) {
788 foreach(GroupWidget *group, groupList) {
789 GroupScene* scene = group->getScene();
790 if (scene->getGroupItem()->getId() == id) return scene->getGroupItem();
792 cout << "search GroupItem by id :" << id << " :: not found..." << endl;
796 BoxItem *Dispatcher::searchBlockItemById(int id) {
797 foreach(GroupWidget *group, groupList) {
799 GroupScene* scene = group->getScene();
800 foreach(BoxItem *item, scene->getBlockItems()){
801 if(item->getId() == id){
806 cout << "search BlockItem by id :" << id << " :: not found..." << endl;
810 InterfaceItem* Dispatcher::searchInterfaceItemById(int id) {
812 foreach(GroupWidget *group, groupList) {
814 GroupScene* scene = group->getScene();
816 foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){
817 if(item->getId() == id){
821 foreach(BoxItem *block, scene->getBlockItems()){
822 foreach(InterfaceItem *item, block->getInterfaces()){
823 if(item->getId() == id){
829 cout << "search interface by id :" << id << " :: not found..." << endl;