@@ -65,7 +65,6 @@ NodeGraphicsObject(FlowScene &scene,
6565 };
6666 connect (this , &QGraphicsObject::xChanged, this , onMoveSlot);
6767 connect (this , &QGraphicsObject::yChanged, this , onMoveSlot);
68-
6968}
7069
7170
@@ -91,6 +90,7 @@ node() const
9190 return _node;
9291}
9392
93+
9494void
9595NodeGraphicsObject::
9696embedQWidget ()
@@ -139,22 +139,26 @@ moveConnections() const
139139{
140140 NodeState const & nodeState = _node.nodeState ();
141141
142- for (PortType portType: {PortType::In, PortType::Out})
142+ for (PortType portType: {PortType::In, PortType::Out})
143143 {
144144 auto const & connectionEntries =
145- nodeState.getEntries (portType);
145+ nodeState.getEntries (portType);
146146
147147 for (auto const & connections : connectionEntries)
148148 {
149149 for (auto & con : connections)
150150 con.second ->getConnectionGraphicsObject ().move ();
151151 }
152- };
152+ }
153153}
154154
155- void NodeGraphicsObject::lock (bool locked)
155+
156+ void
157+ NodeGraphicsObject::
158+ lock (bool locked)
156159{
157160 _locked = locked;
161+
158162 setFlag (QGraphicsItem::ItemIsMovable, !locked);
159163 setFlag (QGraphicsItem::ItemIsFocusable, !locked);
160164 setFlag (QGraphicsItem::ItemIsSelectable, !locked);
190194NodeGraphicsObject::
191195mousePressEvent (QGraphicsSceneMouseEvent * event)
192196{
193- if (_locked) return ;
197+ if (_locked)
198+ return ;
194199
195200 // deselect all other items after this one is selected
196201 if (!isSelected () &&
@@ -199,20 +204,21 @@ mousePressEvent(QGraphicsSceneMouseEvent * event)
199204 _scene.clearSelection ();
200205 }
201206
202- for (PortType portToCheck: {PortType::In, PortType::Out})
207+ for (PortType portToCheck: {PortType::In, PortType::Out})
203208 {
204- NodeGeometry & nodeGeometry = _node.nodeGeometry ();
209+ NodeGeometry const & nodeGeometry = _node.nodeGeometry ();
205210
206211 // TODO do not pass sceneTransform
207- int portIndex = nodeGeometry.checkHitScenePoint (portToCheck,
212+ int const portIndex = nodeGeometry.checkHitScenePoint (portToCheck,
208213 event->scenePos (),
209214 sceneTransform ());
215+
210216 if (portIndex != INVALID)
211217 {
212218 NodeState const & nodeState = _node.nodeState ();
213219
214220 std::unordered_map<QUuid, Connection*> connections =
215- nodeState.connections (portToCheck, portIndex);
221+ nodeState.connections (portToCheck, portIndex);
216222
217223 // start dragging existing connection
218224 if (!connections.empty () && portToCheck == PortType::In)
@@ -227,24 +233,24 @@ mousePressEvent(QGraphicsSceneMouseEvent * event)
227233 {
228234 if (portToCheck == PortType::Out)
229235 {
230- const auto outPolicy = _node.nodeDataModel ()->portOutConnectionPolicy (portIndex);
236+ auto const outPolicy = _node.nodeDataModel ()->portOutConnectionPolicy (portIndex);
231237 if (!connections.empty () &&
232238 outPolicy == NodeDataModel::ConnectionPolicy::One)
233239 {
234240 _scene.deleteConnection ( *connections.begin ()->second );
235241 }
242+ }
236243
237- // todo add to FlowScene
238- auto connection = _scene.createConnection (portToCheck,
239- _node,
240- portIndex);
244+ // todo add to FlowScene
245+ auto connection = _scene.createConnection (portToCheck,
246+ _node,
247+ portIndex);
241248
242- _node.nodeState ().setConnection (portToCheck,
243- portIndex,
244- *connection);
249+ _node.nodeState ().setConnection (portToCheck,
250+ portIndex,
251+ *connection);
245252
246- connection->getConnectionGraphicsObject ().grabMouse ();
247- }
253+ connection->getConnectionGraphicsObject ().grabMouse ();
248254 }
249255 }
250256 }
@@ -342,6 +348,7 @@ hoverEnterEvent(QGraphicsSceneHoverEvent * event)
342348 item->setZValue (0.0 );
343349 }
344350 }
351+
345352 // bring this node forward
346353 setZValue (1.0 );
347354
@@ -370,7 +377,6 @@ hoverMoveEvent(QGraphicsSceneHoverEvent * event)
370377 auto pos = event->pos ();
371378 auto & geom = _node.nodeGeometry ();
372379
373-
374380 if (_node.nodeDataModel ()->resizable () &&
375381 geom.resizeRect ().contains (QPoint (pos.x (), pos.y ())))
376382 {
@@ -394,6 +400,7 @@ mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
394400 _scene.nodeDoubleClicked (node ());
395401}
396402
403+
397404void
398405NodeGraphicsObject::
399406contextMenuEvent (QGraphicsSceneContextMenuEvent* event)
0 commit comments