nodeview: update positions correctly

This commit is contained in:
itsmattkc
2021-05-24 10:12:53 +10:00
parent 74a1507c6f
commit f9309da4b3
6 changed files with 149 additions and 83 deletions
+10 -1
View File
@@ -45,7 +45,8 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
expanded_(false),
hide_titlebar_(false),
highlighted_index_(-1),
flow_dir_(NodeViewCommon::kLeftToRight)
flow_dir_(NodeViewCommon::kLeftToRight),
dont_signal_(false)
{
// Set flags for this widget
setFlag(QGraphicsItem::ItemIsMovable);
@@ -336,6 +337,10 @@ QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change, cons
{
if (change == ItemPositionHasChanged && node_) {
ReadjustAllEdges();
if (!dont_signal_) {
emit NodePositionChanged(GetNodePosition());
}
}
return QGraphicsItem::itemChange(change, value);
@@ -479,6 +484,8 @@ QPointF NodeViewItem::GetInputPointInternal(int index, const QPointF& source_pos
void NodeViewItem::UpdateNodePosition()
{
dont_signal_ = true;
const QPointF &pos = cached_node_pos_;
switch (flow_dir_) {
@@ -499,6 +506,8 @@ void NodeViewItem::UpdateNodePosition()
-pos.x() * DefaultItemVerticalPadding());
break;
}
dont_signal_ = false;
}
}