X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/d30c9cf675ad7141d1c8e31d2e72315267d45cf2..e5af659f87bcb199d6a5f10f09b311138351d0f3:/ConnectionItem.cpp?ds=inline diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index b6d99a5..78a3651 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -84,6 +84,13 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, setFlag(ItemSendsGeometryChanges); setCursor(Qt::PointingHandCursor); setZValue(0); + + if (fromInterfaceItem->refInter->getPurpose() == AbstractInterface::Data) { + visible = true; + } + else { + visible = false; + } setPath(); } @@ -133,6 +140,8 @@ void ConnectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + if (!visible) return; + painter->setPen(Qt::blue); if(selected){ painter->setPen(Qt::red); @@ -727,13 +736,37 @@ void ConnectionItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { } void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { - QMenu menu; - QAction* removeAction = menu.addAction("Remove"); - QAction * selectedAction= menu.exec(event->screenPos()); + /* have to check if the connection can be removed. + If the from or to InterfaceItem is owned by a group item, and this item + is both connected to and from, thus it is impossible to remove this connection + */ + bool canRemove = true; + InterfaceItem* groupIfaceItem = NULL; + if (fromInterfaceItem->getOwner()->isGroupItem()) { + groupIfaceItem = fromInterfaceItem; + } + else if (toInterfaceItem->getOwner()->isGroupItem()) { + groupIfaceItem = toInterfaceItem; + } - if(selectedAction == removeAction){ - dispatcher->removeConnection(this); - dispatcher->removeUselessGroupInterfaces(); + if (groupIfaceItem != NULL) { + ConnectedInterface* ref = groupIfaceItem->refInter; + if ((ref->isConnectedFrom()) && (ref->isConnectedTo())) { + canRemove = false; + } + } + + if (canRemove) { + QMenu menu; + QAction* titleAction = menu.addAction("Connection operations"); + titleAction->setEnabled(false); + menu.addSeparator(); + QAction* removeAction = menu.addAction("Remove"); + QAction * selectedAction= menu.exec(event->screenPos()); + + if(selectedAction == removeAction){ + dispatcher->removeConnection(this); + } } }