]> AND Private Git Repository - blast.git/blobdiff - GroupScene.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
corrected some warnings
[blast.git] / GroupScene.cpp
index b24c39cf48bdcbbbfeab3a956635e1f6395878c6..48de27e6ff76b81a85c5c035337ad98aa3169564 100644 (file)
@@ -61,6 +61,11 @@ QList<BoxItem *> GroupScene::getSelectedBlocks() {
 int GroupScene::setItemsId(int countInit) {
   int counter = countInit;
   groupItem->setId(counter++);
+  if (isTopScene()) {
+    foreach(SourceItem *item, sourceItems){
+      item->setId(counter++);
+    } 
+  }
   foreach(BoxItem *item, boxItems){
     item->setId(counter++);
   }
@@ -72,6 +77,13 @@ int GroupScene::setInterfacesId(int countInit) {
   foreach(InterfaceItem* inter, groupItem->getInterfaces()){
     inter->setId(counter++);
   }
+  if (isTopScene()) {
+    foreach(SourceItem *item, sourceItems){
+      foreach(InterfaceItem* inter, item->getInterfaces()){
+        inter->setId(counter++);
+      }
+    } 
+  }
   foreach(BoxItem *item, boxItems){
     foreach(InterfaceItem* inter, item->getInterfaces()){
       inter->setId(counter++);
@@ -129,6 +141,9 @@ SourceItem *GroupScene::createSourceItem(AbstractBlock *block) {
 }
 
 void GroupScene::addSourceItem(SourceItem* item) {  
+  // adding item to the scene
+  addItem(item);
+  item->setZValue(1);  
   // add item from the QList
   sourceItems.append(item);  
 }
@@ -140,15 +155,11 @@ void GroupScene::removeSourceItem(SourceItem* item) {
   sourceItems.removeAll(item);  
 }
 
-void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2, bool withinGroup) {
+void GroupScene::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
   ConnectionItem* conn = NULL;
-  if (withinGroup) {
-    conn = new ConnectionItem(iface1,iface2, dispatcher, params, groupItem);
-  }
-  else {
-    conn = new ConnectionItem(iface1,iface2, dispatcher, params, NULL);
-    addItem(conn);
-  }
+  
+  conn = new ConnectionItem(iface1,iface2, dispatcher, params);
+  addItem(conn);  
   addConnectionItem(conn);
 }
 
@@ -170,6 +181,13 @@ void GroupScene::addConnectionItem(ConnectionItem* item) {
 }
 
 void GroupScene::removeConnectionItem(ConnectionItem* item) {
+  
+  // remove connection from/to InterfaceItem
+  InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
+  InterfaceItem* toIfaceItem = item->getToInterfaceItem();
+  fromIfaceItem->removeConnectionItem(item);
+  toIfaceItem->removeConnectionItem(item);
+  
   // remove item from the viewport
   removeItem(item);
   // remove item from the QList