forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeDelegateModel.cpp
More file actions
123 lines (104 loc) · 3.08 KB
/
Copy pathNodeDelegateModel.cpp
File metadata and controls
123 lines (104 loc) · 3.08 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
#include "NodeDelegateModel.hpp"
#include "StyleCollection.hpp"
namespace QtNodes {
NodeDelegateModel::NodeDelegateModel()
: _nodeStyle(StyleCollection::nodeStyle())
{
// Derived classes can initialize specific style here
}
QJsonObject NodeDelegateModel::save() const
{
QJsonObject modelJson;
modelJson["model-name"] = name();
return modelJson;
}
void NodeDelegateModel::load(QJsonObject const &)
{
//
}
void NodeDelegateModel::setValidationState(const NodeValidationState &validationState)
{
_nodeValidationState = validationState;
}
ConnectionPolicy NodeDelegateModel::portConnectionPolicy(PortType portType, PortIndex) const
{
auto result = ConnectionPolicy::One;
switch (portType) {
case PortType::In:
result = ConnectionPolicy::One;
break;
case PortType::Out:
result = ConnectionPolicy::Many;
break;
case PortType::None:
break;
}
return result;
}
NodeStyle const &NodeDelegateModel::nodeStyle() const
{
return _nodeStyle;
}
void NodeDelegateModel::setNodeStyle(NodeStyle const &style)
{
_nodeStyle = style;
}
QPixmap NodeDelegateModel::processingStatusIcon() const
{
int resolution = _nodeStyle.processingIconStyle._resolution;
switch (_processingStatus) {
case NodeProcessingStatus::NoStatus:
return {};
case NodeProcessingStatus::Updated:
return _nodeStyle.statusUpdated.pixmap(resolution);
case NodeProcessingStatus::Processing:
return _nodeStyle.statusProcessing.pixmap(resolution);
case NodeProcessingStatus::Pending:
return _nodeStyle.statusPending.pixmap(resolution);
case NodeProcessingStatus::Empty:
return _nodeStyle.statusEmpty.pixmap(resolution);
case NodeProcessingStatus::Failed:
return _nodeStyle.statusInvalid.pixmap(resolution);
case NodeProcessingStatus::Partial:
return _nodeStyle.statusPartial.pixmap(resolution);
}
return {};
}
void NodeDelegateModel::setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap)
{
switch (status) {
case NodeProcessingStatus::NoStatus:
break;
case NodeProcessingStatus::Updated:
_nodeStyle.statusUpdated = QIcon(pixmap);
break;
case NodeProcessingStatus::Processing:
_nodeStyle.statusProcessing = QIcon(pixmap);
break;
case NodeProcessingStatus::Pending:
_nodeStyle.statusPending = QIcon(pixmap);
break;
case NodeProcessingStatus::Empty:
_nodeStyle.statusEmpty = QIcon(pixmap);
break;
case NodeProcessingStatus::Failed:
_nodeStyle.statusInvalid = QIcon(pixmap);
break;
case NodeProcessingStatus::Partial:
_nodeStyle.statusPartial = QIcon(pixmap);
break;
}
}
void NodeDelegateModel::setStatusIconStyle(const ProcessingIconStyle &style)
{
_nodeStyle.processingIconStyle = style;
}
void NodeDelegateModel::setNodeProcessingStatus(NodeProcessingStatus status)
{
_processingStatus = status;
}
void NodeDelegateModel::setBackgroundColor(QColor const &color)
{
_nodeStyle.setBackgroundColor(color);
}
} // namespace QtNodes