Files

83 lines
1.4 KiB
C++
Raw Permalink Normal View History

2016-08-21 19:20:29 +02:00
#pragma once
#include <QtCore/QObject>
#include <QtWidgets/QLineEdit>
#include <nodes/NodeDataModel>
#include <iostream>
class DecimalData;
2016-08-21 19:20:29 +02:00
2017-01-30 10:31:43 +01:00
using QtNodes::PortType;
using QtNodes::PortIndex;
using QtNodes::NodeData;
using QtNodes::NodeDataType;
using QtNodes::NodeDataModel;
using QtNodes::NodeValidationState;
2016-08-21 19:20:29 +02:00
/// The model dictates the number of inputs and outputs for the Node.
/// In this example it has no logic.
2016-09-23 09:45:07 +02:00
class NumberSourceDataModel
: public NodeDataModel
2016-08-21 19:20:29 +02:00
{
Q_OBJECT
public:
NumberSourceDataModel();
2016-09-23 09:45:07 +02:00
virtual
~NumberSourceDataModel() {}
2016-08-21 19:20:29 +02:00
public:
2016-09-23 09:45:07 +02:00
QString
caption() const override
{ return QStringLiteral("Number Source"); }
2016-08-21 19:20:29 +02:00
bool
captionVisible() const override
{ return false; }
2016-11-22 22:01:28 +01:00
QString
name() const override
{ return QStringLiteral("NumberSource"); }
2016-11-22 22:01:28 +01:00
2016-09-23 09:45:07 +02:00
public:
2016-08-21 19:20:29 +02:00
2017-01-31 21:30:56 +01:00
QJsonObject
save() const override;
2016-09-23 09:45:07 +02:00
void
2017-01-31 21:30:56 +01:00
restore(QJsonObject const &p) override;
2016-09-23 09:45:07 +02:00
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-08-21 19:20:29 +02:00
{ }
2016-09-23 09:45:07 +02:00
QWidget *
embeddedWidget() override { return _lineEdit; }
2016-08-21 19:20:29 +02:00
private slots:
2016-09-23 09:45:07 +02:00
void
onTextEdited(QString const &string);
2016-08-21 19:20:29 +02:00
private:
std::shared_ptr<DecimalData> _number;
2016-08-21 19:20:29 +02:00
QLineEdit * _lineEdit;
};