loom
1#include "TextDisplayDataModel.hpp"
2
3TextDisplayDataModel::TextDisplayDataModel()
4: _label(new QLabel("Resulting Text"))
5{
6_label->setMargin(3);
7}
8
9unsigned int TextDisplayDataModel::nPorts(PortType portType) const
10{
11unsigned int result = 1;
12
13switch (portType) {
14case PortType::In:
15result = 1;
16break;
17
18case PortType::Out:
19result = 0;
20
21default:
22break;
23}
24
25return result;
26}
27
28NodeDataType TextDisplayDataModel::dataType(PortType, PortIndex) const
29{
30return TextData().type();
31}
32
33std::shared_ptr<NodeData> TextDisplayDataModel::outData(PortIndex)
34{
35std::shared_ptr<NodeData> ptr;
36return ptr;
37}
38
39void TextDisplayDataModel::setInData(std::shared_ptr<NodeData> data, PortIndex const)
40{
41auto textData = std::dynamic_pointer_cast<TextData>(data);
42
43if (textData) {
44_inputText = textData->text();
45} else {
46_inputText = "";
47}
48
49_label->setText(_inputText);
50_label->adjustSize();
51}
52