/* 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
+ because there would be a group interface alone and not connected and this situation is not allowed.
+
+ Nevertheless, there are 2 exceptions :
+ - a from group interface is connected to more than one input interface
+ - the connection is between a source block outside the top group and the top group
*/
bool canRemove = true;
- InterfaceItem* groupIfaceItem = NULL;
+
if (fromInterfaceItem->getOwner()->isGroupItem()) {
- groupIfaceItem = fromInterfaceItem;
- }
- else if (toInterfaceItem->getOwner()->isGroupItem()) {
- groupIfaceItem = toInterfaceItem;
+ ConnectedInterface* ref = fromInterfaceItem->refInter;
+ if ((ref->isConnectedFrom()) && (ref->getConnectedTo().length() == 1)) {
+ canRemove = false;
+ }
}
-
- if (groupIfaceItem != NULL) {
- ConnectedInterface* ref = groupIfaceItem->refInter;
+ else if ((toInterfaceItem->getOwner()->isGroupItem()) && (! toInterfaceItem->getOwner()->getRefBlock()->isTopGroupBlock())) {
+ ConnectedInterface* ref = toInterfaceItem->refInter;
if ((ref->isConnectedFrom()) && (ref->isConnectedTo())) {
canRemove = false;
}
QAction * selectedAction= menu.exec(event->screenPos());
if(selectedAction == removeAction){
- dispatcher->removeConnection(this);
+ dispatcher->removeConnection(Dispatcher::Design, this);
}
}
}