Skip to content

Commit 20614b6

Browse files
author
Eloy Retamino
committed
Fixed bug in saving node widget enabled state
1 parent 770a6f9 commit 20614b6

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

include/QtNodes/internal/AbstractNodeGeometry.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
7474

7575
virtual QRect enableWidgetHandleRect(NodeId const nodeId) const = 0;
7676

77-
void setEnableEmbeddedWidget(bool val)
78-
{ _embeddedWidgetEnabled = val; }
77+
void setEnableEmbeddedWidget(NodeId const nodeId, bool val)
78+
{ _embeddedWidgetEnabled[nodeId] = val; }
7979

8080
protected:
81+
8182
AbstractGraphModel &_graphModel;
8283

83-
bool _embeddedWidgetEnabled = true;
84+
std::map<NodeId, bool> _embeddedWidgetEnabled;
8485

8586
};
8687

src/DefaultHorizontalNodeGeometry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void DefaultHorizontalNodeGeometry::recomputeSize(NodeId const nodeId) const
3333
unsigned int height = maxVerticalPortsExtent(nodeId);
3434

3535
auto w = _graphModel.nodeData<QWidget *>(nodeId, NodeRole::Widget);
36-
if (_embeddedWidgetEnabled && w) {
36+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
3737
height = std::max(height, static_cast<unsigned int>(w->height()));
3838
}
3939

@@ -50,7 +50,7 @@ void DefaultHorizontalNodeGeometry::recomputeSize(NodeId const nodeId) const
5050

5151
unsigned int width = inPortWidth + outPortWidth + 4 * _portSpasing;
5252

53-
if (_embeddedWidgetEnabled && w) {
53+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
5454
width += w->width();
5555
}
5656

@@ -153,7 +153,7 @@ QPointF DefaultHorizontalNodeGeometry::widgetPosition(NodeId const nodeId) const
153153
unsigned int captionHeight = captionRect(nodeId).height();
154154

155155
auto w = _graphModel.nodeData<QWidget *>(nodeId, NodeRole::Widget);
156-
if (_embeddedWidgetEnabled && w) {
156+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
157157
// If the widget wants to use as much vertical space as possible,
158158
// place it immediately after the caption.
159159
if (w->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) {

src/DefaultVerticalNodeGeometry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void DefaultVerticalNodeGeometry::recomputeSize(NodeId const nodeId) const
3333
unsigned int height = _portSpasing; // maxHorizontalPortsExtent(nodeId);
3434

3535
auto w = _graphModel.nodeData<QWidget *>(nodeId, NodeRole::Widget);
36-
if (_embeddedWidgetEnabled && w) {
36+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
3737
height = std::max(height, static_cast<unsigned int>(w->height()));
3838
}
3939

@@ -65,7 +65,7 @@ void DefaultVerticalNodeGeometry::recomputeSize(NodeId const nodeId) const
6565

6666
unsigned int width = std::max(totalInPortsWidth, totalOutPortsWidth);
6767

68-
if (_embeddedWidgetEnabled && w) {
68+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
6969
width = std::max(width, static_cast<unsigned int>(w->width()));
7070
}
7171

@@ -180,7 +180,7 @@ QPointF DefaultVerticalNodeGeometry::widgetPosition(NodeId const nodeId) const
180180
unsigned int captionHeight = captionRect(nodeId).height();
181181

182182
auto w = _graphModel.nodeData<QWidget *>(nodeId, NodeRole::Widget);
183-
if (_embeddedWidgetEnabled && w) {
183+
if (_embeddedWidgetEnabled.count(nodeId) && _embeddedWidgetEnabled.at(nodeId) && w) {
184184
// If the widget wants to use as much vertical space as possible,
185185
// place it immediately after the caption.
186186
if (w->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) {

0 commit comments

Comments
 (0)