| 1693 | } |
| 1694 | |
| 1695 | void TOPPASScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) |
| 1696 | { |
| 1697 | QPointF scene_pos = event->scenePos(); |
| 1698 | QGraphicsItem* clicked_item = itemAt(scene_pos, QTransform()); |
| 1699 | QMenu menu; |
| 1700 | |
| 1701 | if (clicked_item == nullptr) |
| 1702 | { |
| 1703 | QAction* new_action = menu.addAction("Paste"); |
| 1704 | emit requestClipboardContent(); |
| 1705 | if (clipboard_ == nullptr) |
| 1706 | { |
| 1707 | new_action->setEnabled(false); |
| 1708 | } |
| 1709 | } |
| 1710 | else |
| 1711 | { |
| 1712 | if (!clicked_item->isSelected()) |
| 1713 | { |
| 1714 | unselectAll(); |
| 1715 | } |
| 1716 | |
| 1717 | clicked_item->setSelected(true); |
| 1718 | |
| 1719 | // check which kinds of items are selected and display a context menu containing only actions compatible with all of them |
| 1720 | bool found_tool = false; |
| 1721 | bool found_input = false; |
| 1722 | bool found_output = false; |
| 1723 | bool found_merger = false; |
| 1724 | bool found_splitter = false; |
| 1725 | bool found_edge = false; |
| 1726 | bool disable_resume = false; |
| 1727 | //bool disable_toppview = true; |
| 1728 | |
| 1729 | foreach(TOPPASEdge* edge, edges_) |
| 1730 | { |
| 1731 | if (edge->isSelected()) |
| 1732 | { |
| 1733 | found_edge = true; |
| 1734 | break; |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | foreach(TOPPASVertex* tv, vertices_) |
| 1739 | { |
| 1740 | if (!tv->isSelected()) |
| 1741 | { |
| 1742 | continue; |
| 1743 | } |
| 1744 | |
| 1745 | if (qobject_cast<TOPPASToolVertex*>(tv)) |
| 1746 | { |
| 1747 | found_tool = true; |
| 1748 | // all predecessor nodes finished successfully? if not, disable resuming |
| 1749 | for (ConstEdgeIterator it = tv->inEdgesBegin(); it != tv->inEdgesEnd(); ++it) |
| 1750 | { |
| 1751 | TOPPASToolVertex* pred_ttv = qobject_cast<TOPPASToolVertex*>((*it)->getSourceVertex()); |
| 1752 | if (pred_ttv && (pred_ttv->getStatus() != TOPPASToolVertex::TOOL_SUCCESS)) |
nothing calls this directly
no test coverage detected