diff --git a/src/GraphView.qml b/src/GraphView.qml index 2ef5c931..d138e3da 100644 --- a/src/GraphView.qml +++ b/src/GraphView.qml @@ -197,9 +197,6 @@ Qan.AbstractGraphView { onPortClicked: function(port) { if (graph && port) { - // FIXME #1718 - //if (port.node) // Force port host node on top - // graph.sendToFront(port.node.item) if (graph.connector && graph.connectorEnabled) graph.connector.sourcePort = port @@ -231,11 +228,9 @@ Qan.AbstractGraphView { return if (node.locked || - node.isProtected) // Do not show any connector for locked node/groups + node.isProtected) // Do not show any connector for locked node/groups return; - // FIXME #1718 - //graph.sendToFront(node.item) // Protected/Locked nodes are not re-ordered to front. if (graph.connector && graph.connectorEnabled && (node.item.connectable === Qan.NodeItem.Connectable || @@ -284,10 +279,6 @@ Qan.AbstractGraphView { // Disable node resizing nodeResizer.target = nodeRightResizer.target = nodeBottomResizer.target = null - // FIXME #1718 - //if (!group.locked && !group.isProtected) // Do not move locked/protected groups to front. - // graph.sendToFront(group.item) - if (group.item.container && group.item.resizable) { // Set minimumTargetSize _before_ setting target @@ -319,16 +310,8 @@ Qan.AbstractGraphView { } // group.item.resizable } // onGroupClicked() - onGroupRightClicked: (group) => { - // FIXME #1718 - //if (group && group.item) - // graph.sendToFront(group.item) - } - onGroupDoubleClicked: (group) => { - // FIXME #1718 - //if (group && group.itm) - // graph.sendToFront(group.item) - } + onGroupRightClicked: (group) => { } + onGroupDoubleClicked: (group) => { } ShaderEffectSource { // Screenshot shader is used for gradbbing graph containerItem screenshot. Default id: graphImageShader // Item.grabToImage() does not allow negative (x, y) position, ShaderEffectSource is visible: false // used to render graph at desired resolution with a custom negative sourceRect, then diff --git a/src/qanGraph.cpp b/src/qanGraph.cpp index bc3ff23e..97ce6dda 100644 --- a/src/qanGraph.cpp +++ b/src/qanGraph.cpp @@ -47,6 +47,7 @@ #include "./qanNodeItem.h" #include "./qanPortItem.h" #include "./qanEdgeItem.h" +#include "./qanTableGroupItem.h" #include "./qanGroup.h" #include "./qanGroupItem.h" #include "./qanConnector.h" @@ -144,18 +145,36 @@ QQuickItem* Graph::graphChildAt(qreal x, qreal y) const { if (getContainerItem() == nullptr) return nullptr; - const QList children = getContainerItem()->childItems(); - for (int i = children.count()-1; i >= 0; --i) { - QQuickItem* child = children.at(i); - const QPointF point = mapToItem(child, QPointF(x, y)); // Map coordinates to the child element's coordinate space - if (child->isVisible() && - child->contains( point ) && // Note 20160508: childAt do not call contains() + const auto childrens = getContainerItem()->childItems(); + for (int i = childrens.count() - 1; i >= 0; --i) { + QQuickItem* child = childrens.at(i); + const QPointF point = mapToItem(child, QPointF{x, y}); // Map coordinates to the child element's coordinate space + if (child != nullptr && + child->isVisible() && + child->contains(point) && // Note 20160508: childAt do not call contains() point.x() > -0.0001 && child->width() > point.x() && point.y() > -0.0001 && - child->height() > point.y() ) { + child->height() > point.y()) { + if (child->inherits("qan::TableGroupItem")) { + const auto tableGroupItem = static_cast(child); + if (tableGroupItem != nullptr) { + for (const auto cell: tableGroupItem->getCells()) { + const auto point = mapToItem(cell, QPointF(x, y)); // Map coordinates to group child element's coordinate space + if (cell->isVisible() && + cell->contains(point) && + point.x() > -0.0001 && + cell->width() > point.x() && + point.y() > -0.0001 && + cell->height() > point.y()) { + QQmlEngine::setObjectOwnership(cell->getItem(), QQmlEngine::CppOwnership); + return cell->getItem(); + } + } + } + } if (child->inherits("qan::GroupItem")) { // For group, look in group childs - const auto groupItem = qobject_cast( child ); + const auto groupItem = qobject_cast(child); if (groupItem != nullptr && groupItem->getContainer() != nullptr) { const QList groupChildren = groupItem->getContainer()->childItems(); @@ -163,11 +182,11 @@ QQuickItem* Graph::graphChildAt(qreal x, qreal y) const QQuickItem* groupChild = groupChildren.at(gc); const auto point = mapToItem(groupChild, QPointF(x, y)); // Map coordinates to group child element's coordinate space if (groupChild->isVisible() && - groupChild->contains( point ) && + groupChild->contains(point) && point.x() > -0.0001 && groupChild->width() > point.x() && point.y() > -0.0001 && - groupChild->height() > point.y() ) { + groupChild->height() > point.y()) { QQmlEngine::setObjectOwnership(groupChild, QQmlEngine::CppOwnership); return groupChild; }