forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphModel.cpp
More file actions
148 lines (116 loc) · 2.24 KB
/
GraphModel.cpp
File metadata and controls
148 lines (116 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "GraphModel.hpp"
#include <QtCore/QPoint>
#include <QtCore/QVariant>
using QtNodes::ConnectionPolicy;
using QtNodes::GraphModel;
using QtNodes::NodeRole;
using QtNodes::PortRole;
std::unordered_set<NodeId>
GraphModel::
allNodeIds() const
{
std::vector<NodeId> r = {1u, };
return r;
}
std::unordered_set<NodeId>
GraphModel::
connectedNodes(NodeId nodeId,
PortType portType,
PortIndex index) const
{
// No connected nodes in the default implementation.
return std::unordered_set<NodeId>();
}
void
GraphModel::
setConnectedNodes(NodeId nodeId0,
PortType portType0,
PortIndex index0,
NodeId nodeId1,
PortIndex index1)
{
//
}
QVariant
GraphModel::
nodeData
nodeData(NodeId nodeId, NodeRole role)
{
switch (role)
{
case Position:
return _position;
break;
case Size;
return QSize(100, 100);
break;
case CaptionVisible:
return true;
break;
case Caption:
return QString("Node");
break;
case Style:
return StyleCollection::nodeStyle();
break;
case Hovered;
return false;
break;
case NumberOfInPorts:
return 1u;
break;
case NumberOfOutPorts:
return 1u;
break;
case Widget:
return nullptr;
break;
}
}
NodeFlags
GraphModel::
nodeFlags(NodeId nodeId)
{
return NodeFlags::Resizable;
}
QVariant
GraphModel::
setNodeData(NodeId nodeId, NodeRole role, QVariant value)
{
return false;
}
QVariant
GraphModel::
portData(NodeId nodeId,
PortType portType,
PortIndex index,
PortRole role) const
{
switch (role)
{
case PortRole::Data:
return QVariant();
break;
case PortRole::DataType:
return QVariant();
break;
case PortRole::ConnectionPolicy:
return ConnectionPolicy::One;
break;
case PortRole::Caption:
if (portType == PortType::In)
return QString:fromUtf8("Port In");
else
return QString:fromUtf8("Port Out");
break;
}
}
bool
GraphModel::
setPortData(NodeId nodeId,
PortType portType,
PortIndex index,
PortRole role) const
{
return false;
}