Files
nodeeditor/examples/example2/TextSourceDataModel.hpp
T

76 lines
1.3 KiB
C++
Raw 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>
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:
2016-09-23 09:45:07 +02:00
QString
caption() const override
{ return QString("Text Source"); }
2016-05-31 23:22:03 +02:00
2016-11-22 22:01:28 +01:00
bool
2016-11-23 22:46:25 +01:00
captionVisible() const override { return false; }
2016-05-31 23:22:03 +02:00
2016-11-22 22:01:28 +01:00
QString
name() const override
2016-09-23 09:45:07 +02:00
{ return QString("TextSourceDataModel"); }
2016-11-22 22:01:28 +01:00
std::unique_ptr<NodeDataModel>
clone() const override
{ return std::make_unique<TextSourceDataModel>(); }
2016-09-23 09:45:07 +02:00
public:
void
save(Properties &p) const override
{
p.put("model_name", TextSourceDataModel::name());
}
public:
unsigned int
nPorts(PortType portType) const override;
NodeDataType
dataType(PortType portType, PortIndex portIndex) const override;
std::shared_ptr<NodeData>
outData(PortIndex port) override;
void
setInData(std::shared_ptr<NodeData>, int) override
{ }
2016-05-31 23:22:03 +02:00
2016-09-23 09:45:07 +02:00
QWidget *
embeddedWidget() override { return _lineEdit; }
2016-05-31 23:22:03 +02:00
private slots:
2016-05-31 23:22:03 +02:00
2016-09-23 09:45:07 +02:00
void
onTextEdited(QString const &string);
2016-05-31 23:22:03 +02:00
private:
QLineEdit * _lineEdit;
};