Skip to content

Commit aec1c22

Browse files
committed
Add signals for dynamic ports to the data flow classes
1 parent e076fb6 commit aec1c22

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

include/QtNodes/internal/NodeDelegateModel.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@ public Q_SLOTS:
149149
void
150150
embeddedWidgetSizeUpdated();
151151

152+
/// Call this function before deleting the data associated with ports.
153+
/**
154+
* The function notifies the Graph Model and makes it remove and recompute the
155+
* affected connection addresses.
156+
*/
157+
void
158+
portsAboutToBeDeleted(PortType const portType,
159+
PortIndex const first,
160+
PortIndex const last);
161+
162+
/// Call this function when data and port moditications are finished.
163+
void
164+
portsDeleted();
165+
166+
/// Call this function before inserting the data associated with ports.
167+
/**
168+
* The function notifies the Graph Model and makes it recompute the affected
169+
* connection addresses.
170+
*/
171+
void
172+
portsAboutToBeInserted(PortType const portType,
173+
PortIndex const first,
174+
PortIndex const last);
175+
176+
/// Call this function when data and port moditications are finished.
177+
void
178+
portsInserted();
179+
152180
private:
153181
NodeStyle _nodeStyle;
154182
};

src/DataFlowGraphModel.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,33 @@ addNode(QString const nodeType)
9292
[newId, this](PortIndex const portIndex)
9393
{ onOutPortDataUpdated(newId, portIndex); });
9494

95+
connect(model.get(),
96+
&NodeDelegateModel::portsAboutToBeDeleted,
97+
this,
98+
[newId, this](PortType const portType,
99+
PortIndex const first,
100+
PortIndex const last)
101+
{ portsAboutToBeDeleted(newId, portType, first, last);});
102+
103+
connect(model.get(),
104+
&NodeDelegateModel::portsDeleted,
105+
this,
106+
&DataFlowGraphModel::portsDeleted);
107+
108+
connect(model.get(),
109+
&NodeDelegateModel::portsAboutToBeInserted,
110+
this,
111+
[newId, this](PortType const portType,
112+
PortIndex const first,
113+
PortIndex const last)
114+
{ portsAboutToBeInserted(newId, portType, first, last);});
115+
116+
connect(model.get(),
117+
&NodeDelegateModel::portsInserted,
118+
this,
119+
&DataFlowGraphModel::portsInserted);
120+
121+
95122
_models[newId] = std::move(model);
96123

97124
Q_EMIT nodeCreated(newId);

0 commit comments

Comments
 (0)