File: TextSourceDataModel.cpp

package info (click to toggle)
qnodeeditor 2.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,144 kB
  • sloc: cpp: 8,823; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 841 bytes parent folder | download
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
#include "TextSourceDataModel.hpp"
TextSourceDataModel::TextSourceDataModel() : _lineEdit(new QLineEdit("Default Text"))
{
    connect(_lineEdit, &QLineEdit::textEdited, this, &TextSourceDataModel::onTextEdited);
}
unsigned int TextSourceDataModel::nPorts(PortType portType) const
{
    unsigned int result = 1;
    switch (portType)
    {
        case PortType::In: result = 0; break;
        case PortType::Out: result = 1;
        default: break;
    }
    return result;
}
void TextSourceDataModel::onTextEdited(QString const &string)
{
    Q_UNUSED(string);
    Q_EMIT dataUpdated(0);
}
std::shared_ptr<NodeDataType> TextSourceDataModel::dataType(PortType, PortIndex) const
{
    return TextData().type();
}
std::shared_ptr<NodeData> TextSourceDataModel::outData(PortIndex)
{
    return std::make_shared<TextData>(_lineEdit->text());
}