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

Private GIT Repository
added an example of source block
[blast.git] / BoxItem.cpp
index a107198654913fdc6badc66bc19ed9b13f784d47..6e6f15aace5731771cc753171d3b0af4ba77877a 100644 (file)
@@ -207,11 +207,18 @@ bool BoxItem::updateGeometry(ChangeType type) {
   return false;
 }
 
-void BoxItem::interfaceRenamed() {
+void BoxItem::nameChanged() {
+  
+  QFontMetrics fmId(params->defaultBlockFont);
+  nameWidth = fmId.width(refBlock->getName());
+  nameHeight = fmId.height();
+  
   if (updateGeometry(InterfaceMove)) {
     //cout << "must recompute group item geometry" << endl;
     (getScene()->getGroupItem())->updateShape();
-  }  
+  }
+  // force the update in case of size has not changed
+  update();
 }
 
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
@@ -387,7 +394,7 @@ void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent  *event) {
     else if (params->editState == Parameters::EditCloseConnection) {
       InterfaceItem* iface1 = getScene()->getSelectedInterface(1);
       InterfaceItem* iface2 = getScene()->getSelectedInterface(2);
-      bool ok = dispatcher->connect(iface1,iface2);
+      bool ok = dispatcher->createConnectionItem(iface1,iface2);
       if (ok) {
         iface1->selected = false;
         // no update needed since the whole scene will be repainted
@@ -482,6 +489,8 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) {
 
 void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
 
+  event->accept();
+  
   QMenu menu;
   QAction* titleAction = NULL;
   QAction* removeAction = NULL;
@@ -587,17 +596,24 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
      dispatcher->removeFunctionalInterface(ifaceItem);
     }
     else {
-      dispatcher->removeBlock(this);
+      dispatcher->removeBoxItem(this);
     }
   }
   else if (selectedAction == duplicateAction) {
-    dispatcher->duplicateBlock(this);
+    dispatcher->duplicateBoxItem(this);
   }
   else if(selectedAction == renameAction){
-    if(ifaceItem != NULL)
+    if(ifaceItem != NULL) {
       dispatcher->renameInterface(ifaceItem);
-    else
-      dispatcher->renameBlockOrGroup(this);
+    }
+    else {
+      if (refBlock->isFunctionalBlock()) {          
+        dispatcher->renameFunctionalBlock(this);
+      }
+      else if (refBlock->isGroupBlock()) {        
+        dispatcher->renameGroupBlock(childGroupItem);
+      }
+    }   
   }
   else if(selectedAction == showProperties){
     dispatcher->showProperties(ifaceItem);
@@ -609,7 +625,7 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     dispatcher->disconnectInterFromGroup(ifaceItem);
   }
   else if (selectedAction == cloneInterface){
-    dispatcher->duplicateInterface(ifaceItem);
+    dispatcher->duplicateInterfaceItem(ifaceItem);
   }
   else if (selectedAction == openWindow){
     dispatcher->showRaiseWindow(this);
@@ -622,8 +638,9 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   }
   else if(selectedAction == showParameters){
     new ParametersWindow(refBlock, params, NULL);
-  }
+  }    
 }
+
 void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
 
   bool ok = false;
@@ -676,7 +693,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   }
   
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
-  FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
+  FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference);
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
     reading bif_iface tags. Thus interface are all removed.
   */