X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/e5af659f87bcb199d6a5f10f09b311138351d0f3..819b9aaf8a357efbf4d095ef9268cbcbb46c52e9:/BoxItem.cpp?ds=inline diff --git a/BoxItem.cpp b/BoxItem.cpp index a107198..6e6f15a 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -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. */