Skip to content

Commit 2dc6825

Browse files
committed
Add unselected moved node to selection with pressed CTRL
1 parent c99b6a2 commit 2dc6825

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

src/NodeGraphicsObject.cpp

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -229,53 +229,53 @@ mousePressEvent(QGraphicsSceneMouseEvent* event)
229229
PortIndex const portIndex =
230230
geometry.checkPortHit(_nodeId, portToCheck, nodeCoord);
231231

232-
if (portIndex != InvalidPortIndex)
233-
{
234-
auto const& connected =
235-
_graphModel.connections(_nodeId, portToCheck, portIndex);
232+
if (portIndex == InvalidPortIndex)
233+
continue;
236234

237-
// Start dragging existing connection.
238-
if (!connected.empty() && portToCheck == PortType::In)
239-
{
240-
auto const& cnId = *connected.begin();
235+
auto const& connected =
236+
_graphModel.connections(_nodeId, portToCheck, portIndex);
237+
238+
// Start dragging existing connection.
239+
if (!connected.empty() && portToCheck == PortType::In)
240+
{
241+
auto const& cnId = *connected.begin();
241242

242-
// Need ConnectionGraphicsObject
243+
// Need ConnectionGraphicsObject
243244

244-
NodeConnectionInteraction
245-
interaction(*this,
246-
*nodeScene()->connectionGraphicsObject(cnId),
247-
*nodeScene());
245+
NodeConnectionInteraction
246+
interaction(*this,
247+
*nodeScene()->connectionGraphicsObject(cnId),
248+
*nodeScene());
248249

249-
if (_graphModel.detachPossible(cnId))
250-
interaction.disconnect(portToCheck);
251-
}
252-
else // initialize new Connection
250+
if (_graphModel.detachPossible(cnId))
251+
interaction.disconnect(portToCheck);
252+
}
253+
else // initialize new Connection
254+
{
255+
if (portToCheck == PortType::Out)
253256
{
254-
if (portToCheck == PortType::Out)
257+
auto const outPolicy =
258+
_graphModel.portData(_nodeId,
259+
portToCheck,
260+
portIndex,
261+
PortRole::ConnectionPolicyRole).value<ConnectionPolicy>();
262+
263+
if (!connected.empty() &&
264+
outPolicy == ConnectionPolicy::One)
255265
{
256-
auto const outPolicy =
257-
_graphModel.portData(_nodeId,
258-
portToCheck,
259-
portIndex,
260-
PortRole::ConnectionPolicyRole).value<ConnectionPolicy>();
261-
262-
if (!connected.empty() &&
263-
outPolicy == ConnectionPolicy::One)
266+
for (auto& cnId : connected)
264267
{
265-
for (auto& cnId : connected)
266-
{
267-
_graphModel.deleteConnection(cnId);
268-
}
268+
_graphModel.deleteConnection(cnId);
269269
}
270-
} // if port == out
270+
}
271+
} // if port == out
271272

272-
ConnectionId const incompleteConnectionId =
273-
makeIncompleteConnectionId(_nodeId,
274-
portToCheck,
275-
portIndex);
273+
ConnectionId const incompleteConnectionId =
274+
makeIncompleteConnectionId(_nodeId,
275+
portToCheck,
276+
portIndex);
276277

277-
nodeScene()->makeDraftConnection(incompleteConnectionId);
278-
}
278+
nodeScene()->makeDraftConnection(incompleteConnectionId);
279279
}
280280
}
281281

@@ -299,10 +299,14 @@ void
299299
NodeGraphicsObject::
300300
mouseMoveEvent(QGraphicsSceneMouseEvent* event)
301301
{
302-
// deselect all other items after this one is selected
302+
// Deselect all other items after this one is selected.
303+
// Unless we press a CTRL button to add the item to the selected group before
304+
// starting moving.
303305
if (!isSelected())
304306
{
305-
scene()->clearSelection();
307+
if (!event->modifiers().testFlag(Qt::ControlModifier))
308+
scene()->clearSelection();
309+
306310
setSelected(true);
307311
}
308312

0 commit comments

Comments
 (0)