Skip to content

Commit

Permalink
Merge pull request cneben#231 from cneben/f/graph-child-table
Browse files Browse the repository at this point in the history
F/graph child table
  • Loading branch information
cneben authored Jul 15, 2024
2 parents 26cc899 + e4659dc commit 8995887
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
23 changes: 3 additions & 20 deletions src/GraphView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 29 additions & 10 deletions src/qanGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -144,30 +145,48 @@ QQuickItem* Graph::graphChildAt(qreal x, qreal y) const
{
if (getContainerItem() == nullptr)
return nullptr;
const QList<QQuickItem*> 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<qan::TableGroupItem*>(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<qan::GroupItem*>( child );
const auto groupItem = qobject_cast<qan::GroupItem*>(child);
if (groupItem != nullptr &&
groupItem->getContainer() != nullptr) {
const QList<QQuickItem *> groupChildren = groupItem->getContainer()->childItems();
for (int gc = groupChildren.count() - 1; gc >= 0; --gc) {
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;
}
Expand Down

0 comments on commit 8995887

Please sign in to comment.