Skip to content

Commit 490a210

Browse files
committed
solve conflicts
2 parents 388f65d + 163ed49 commit 490a210

24 files changed

Lines changed: 478 additions & 87 deletions

examples/calculator/MathOperationDataModel.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "MathOperationDataModel.hpp"
2-
32
#include "DecimalData.hpp"
43

54
unsigned int MathOperationDataModel::nPorts(PortType portType) const

examples/styles/models.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class MyDataModel : public NodeDelegateModel
3636

3737
QString name() const override { return QString("MyDataModel"); }
3838

39+
bool labelEditable() const override { return true; }
40+
3941
public:
4042
QJsonObject save() const override
4143
{

include/QtNodes/internal/AbstractNodeGeometry.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
3636
/// Port position in node's coordinate system.
3737
virtual QPointF portPosition(NodeId const nodeId,
3838
PortType const portType,
39-
PortIndex const index) const
40-
= 0;
39+
PortIndex const index) const = 0;
4140

4241
/// A convenience function using the `portPosition` and a given transformation.
4342
virtual QPointF portScenePosition(NodeId const nodeId,
@@ -48,8 +47,7 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
4847
/// Defines where to draw port label. The point corresponds to a font baseline.
4948
virtual QPointF portTextPosition(NodeId const nodeId,
5049
PortType const portType,
51-
PortIndex const portIndex) const
52-
= 0;
50+
PortIndex const portIndex) const = 0;
5351

5452
/**
5553
* Defines where to start drawing the caption. The point corresponds to a font
@@ -60,6 +58,15 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
6058
/// Caption rect is needed for estimating the total node size.
6159
virtual QRectF captionRect(NodeId const nodeId) const = 0;
6260

61+
/**
62+
* Defines where to start drawing the label. The point corresponds to a font
63+
* baseline.
64+
*/
65+
virtual QPointF labelPosition(NodeId const nodeId) const = 0;
66+
67+
/// Caption rect is needed for estimating the total node size.
68+
virtual QRectF labelRect(NodeId const nodeId) const = 0;
69+
6370
/// Position for an embedded widget. Return any value if you don't embed.
6471
virtual QPointF widgetPosition(NodeId const nodeId) const = 0;
6572

@@ -69,6 +76,8 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
6976

7077
virtual QRect resizeHandleRect(NodeId const nodeId) const = 0;
7178

79+
virtual int getPortSpacing() = 0;
80+
7281
protected:
7382
AbstractGraphModel &_graphModel;
7483
};

include/QtNodes/internal/BasicGraphicsScene.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
#include "Export.hpp"
88
#include "GroupGraphicsObject.hpp"
99
#include "NodeGroup.hpp"
10+
#include "QUuidStdHash.hpp"
1011
#include "UndoCommands.hpp"
11-
1212
#include <QtCore/QJsonObject>
13+
#include <QtCore/QUuid>
1314
#include <QtWidgets/QGraphicsScene>
1415
#include <QtWidgets/QMenu>
1516

@@ -34,7 +35,7 @@ class NodeGroup;
3435
class GroupGraphicsObject;
3536
struct ConnectionId;
3637

37-
/// An instance of QGraphicsScene, holds connections and nodes.
38+
/// An instance of QGraphicsScene , holds connections and nodes.
3839
class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
3940
{
4041
Q_OBJECT
@@ -205,6 +206,12 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
205206
*/
206207
virtual QMenu *createSceneMenu(QPointF const scenePos);
207208

209+
/**
210+
* @brief Freezes and unfreezes the model and connections of the selected nodes.
211+
* @param isFreeze reference for freezing or unfreezing the model and connections of the selected nodes.
212+
*/
213+
void freezeModelAndConnections(bool isFreeze);
214+
208215
/**
209216
* @brief Creates the default menu when a node is selected.
210217
*/

include/QtNodes/internal/ConnectionState.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class NODE_EDITOR_PUBLIC ConnectionState
2525
ConnectionState(ConnectionGraphicsObject &cgo)
2626
: _cgo(cgo)
2727
, _hovered(false)
28+
, _frozen(false)
2829
{}
2930

3031
ConnectionState(ConnectionState const &) = delete;
@@ -42,6 +43,9 @@ class NODE_EDITOR_PUBLIC ConnectionState
4243
bool hovered() const;
4344
void setHovered(bool hovered);
4445

46+
bool frozen() const { return _frozen; }
47+
void setFrozen(bool frozen) { _frozen = frozen; }
48+
4549
public:
4650
/// Caches NodeId for further interaction.
4751
void setLastHoveredNode(NodeId const nodeId);
@@ -56,5 +60,7 @@ class NODE_EDITOR_PUBLIC ConnectionState
5660
bool _hovered;
5761

5862
NodeId _lastHoveredNode{InvalidNodeId};
63+
64+
bool _frozen;
5965
};
6066
} // namespace QtNodes

include/QtNodes/internal/DataFlowGraphModel.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <QJsonObject>
1212

1313
#include <memory>
14+
#include <unordered_map>
15+
#include <QString>
1416

1517
namespace QtNodes {
1618

@@ -137,6 +139,9 @@ private Q_SLOTS:
137139
std::unordered_set<ConnectionId> _connectivity;
138140

139141
mutable std::unordered_map<NodeId, NodeGeometryData> _nodeGeometryData;
142+
143+
std::unordered_map<NodeId, QString> _labels;
144+
std::unordered_map<NodeId, bool> _labelsVisible;
140145
};
141146

142147
} // namespace QtNodes

include/QtNodes/internal/DataFlowGraphicsScene.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22

33
#include "BasicGraphicsScene.hpp"
4+
#include "ConnectionGraphicsObject.hpp"
45
#include "DataFlowGraphModel.hpp"
56
#include "Export.hpp"
7+
#include "NodeConnectionInteraction.hpp"
68

79
namespace QtNodes {
810

@@ -22,6 +24,7 @@ class NODE_EDITOR_PUBLIC DataFlowGraphicsScene : public BasicGraphicsScene
2224
public:
2325
std::vector<NodeId> selectedNodes() const;
2426
QMenu *createSceneMenu(QPointF const scenePos) override;
27+
void updateConnectionGraphics(const std::unordered_set<ConnectionId> &connections, bool state);
2528

2629
public Q_SLOTS:
2730
bool save() const;

include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ class NODE_EDITOR_PUBLIC DefaultHorizontalNodeGeometry : public AbstractNodeGeom
2828
QPointF portTextPosition(NodeId const nodeId,
2929
PortType const portType,
3030
PortIndex const PortIndex) const override;
31+
3132
QPointF captionPosition(NodeId const nodeId) const override;
3233

3334
QRectF captionRect(NodeId const nodeId) const override;
3435

36+
QPointF labelPosition(const NodeId nodeId) const override;
37+
38+
QRectF labelRect(NodeId const nodeId) const override;
39+
3540
QPointF widgetPosition(NodeId const nodeId) const override;
3641

3742
QRect resizeHandleRect(NodeId const nodeId) const override;
3843

44+
int getPortSpacing() override { return _portSpacing; }
45+
3946
private:
4047
QRectF portTextRect(NodeId const nodeId,
4148
PortType const portType,
@@ -52,7 +59,7 @@ class NODE_EDITOR_PUBLIC DefaultHorizontalNodeGeometry : public AbstractNodeGeom
5259
// constness of the Node.
5360

5461
mutable unsigned int _portSize;
55-
unsigned int _portSpasing;
62+
unsigned int _portSpacing;
5663
mutable QFontMetrics _fontMetrics;
5764
mutable QFontMetrics _boldFontMetrics;
5865
};

include/QtNodes/internal/DefaultNodePainter.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#pragma once
22

3-
#include <QIcon>
4-
#include <QtGui/QPainter>
5-
63
#include "AbstractNodePainter.hpp"
74
#include "Definitions.hpp"
5+
#include <QIcon>
6+
#include <QtGui/QPainter>
87

98
namespace QtNodes {
109

@@ -28,6 +27,8 @@ class NODE_EDITOR_PUBLIC DefaultNodePainter : public AbstractNodePainter
2827

2928
void drawNodeCaption(QPainter *painter, NodeGraphicsObject &ngo) const;
3029

30+
void drawNodeLabel(QPainter *painter, NodeGraphicsObject &ngo) const;
31+
3132
void drawEntryLabels(QPainter *painter, NodeGraphicsObject &ngo) const;
3233

3334
void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const;

include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ class NODE_EDITOR_PUBLIC DefaultVerticalNodeGeometry : public AbstractNodeGeomet
3333

3434
QRectF captionRect(NodeId const nodeId) const override;
3535

36+
QPointF labelPosition(const NodeId nodeId) const override;
37+
38+
QRectF labelRect(NodeId const nodeId) const override;
39+
3640
QPointF widgetPosition(NodeId const nodeId) const override;
3741

3842
QRect resizeHandleRect(NodeId const nodeId) const override;
3943

44+
int getPortSpacing() override { return _portSpacing; }
45+
4046
private:
4147
QRectF portTextRect(NodeId const nodeId,
4248
PortType const portType,
@@ -54,7 +60,7 @@ class NODE_EDITOR_PUBLIC DefaultVerticalNodeGeometry : public AbstractNodeGeomet
5460
// constness of the Node.
5561

5662
mutable unsigned int _portSize;
57-
unsigned int _portSpasing;
63+
unsigned int _portSpacing;
5864
mutable QFontMetrics _fontMetrics;
5965
mutable QFontMetrics _boldFontMetrics;
6066
};

0 commit comments

Comments
 (0)