Files

73 lines
1.2 KiB
C++
Raw Permalink Normal View History

2016-05-31 23:22:03 +02:00
#pragma once
#include <QtCore/QObject>
#include <QtWidgets/QLineEdit>
#include "TextData.hpp"
#include <nodes/NodeDataModel>
#include <iostream>
2017-01-30 10:31:43 +01:00
using QtNodes::PortType;
using QtNodes::PortIndex;
using QtNodes::NodeData;
using QtNodes::NodeDataModel;
2016-05-31 23:22:03 +02:00
/// The model dictates the number of inputs and outputs for the Node.
/// In this example it has no logic.
class TextSourceDataModel : public NodeDataModel
{
Q_OBJECT
public:
TextSourceDataModel();
2016-09-23 09:45:07 +02:00
virtual
~TextSourceDataModel() {}
2016-05-31 23:22:03 +02:00
public:
2017-01-31 21:30:56 +01:00
QString
caption() const override
2016-09-23 09:45:07 +02:00
{ return QString("Text Source"); }
2016-05-31 23:22:03 +02:00
2017-01-31 21:30:56 +01:00
bool
captionVisible() const override { return false; }
2016-05-31 23:22:03 +02:00
2018-05-11 11:00:30 +02:00
static QString
Name()
2016-09-23 09:45:07 +02:00
{ return QString("TextSourceDataModel"); }
2018-05-11 11:00:30 +02:00
QString
name() const override
{ return TextSourceDataModel::Name(); }
2016-11-22 22:01:28 +01:00
2016-09-23 09:45:07 +02:00
public:
2017-01-31 21:30:56 +01:00
unsigned int
nPorts(PortType portType) const override;
2016-09-23 09:45:07 +02:00
2017-01-31 21:30:56 +01:00
NodeDataType
dataType(PortType portType, PortIndex portIndex) const override;
2016-09-23 09:45:07 +02:00
2017-01-31 21:30:56 +01:00
std::shared_ptr<NodeData>
outData(PortIndex port) override;
2016-09-23 09:45:07 +02:00
2017-01-31 21:30:56 +01:00
void
setInData(std::shared_ptr<NodeData>, int) override
{ }
2016-05-31 23:22:03 +02:00
2017-01-31 21:30:56 +01:00
QWidget *
embeddedWidget() override { return _lineEdit; }
2016-05-31 23:22:03 +02:00
private slots:
2016-05-31 23:22:03 +02:00
2017-01-31 21:30:56 +01:00
void
onTextEdited(QString const &string);
2016-05-31 23:22:03 +02:00
private:
QLineEdit * _lineEdit;
};