Files

74 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/QLabel>
#include <nodes/NodeDataModel>
#include <iostream>
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.
class NumberDisplayDataModel : public NodeDataModel
{
Q_OBJECT
public:
NumberDisplayDataModel();
2016-09-23 09:45:07 +02:00
virtual
~NumberDisplayDataModel() {}
2016-08-21 19:20:29 +02:00
2016-09-23 09:45:07 +02:00
public:
QString
caption() const override
{ return QStringLiteral("Result"); }
2016-09-23 09:45:07 +02:00
bool
captionVisible() const override
{ return false; }
2016-11-22 22:01:28 +01:00
QString
name() const override
{ return QStringLiteral("Result"); }
2016-08-22 22:20:34 +02:00
2016-09-23 09:45:07 +02:00
public:
2016-08-21 19:20:29 +02:00
2016-09-23 09:45:07 +02:00
unsigned int
nPorts(PortType portType) const override;
2016-08-21 19:20:29 +02:00
2016-09-23 09:45:07 +02:00
NodeDataType
dataType(PortType portType,
PortIndex portIndex) const override;
2016-08-21 19:20:29 +02:00
2016-09-23 09:45:07 +02:00
std::shared_ptr<NodeData>
outData(PortIndex port) override;
void
setInData(std::shared_ptr<NodeData> data, int) override;
QWidget *
embeddedWidget() override { return _label; }
2016-08-21 19:20:29 +02:00
2017-01-31 21:30:56 +01:00
NodeValidationState
validationState() const override;
2017-01-31 21:30:56 +01:00
QString
validationMessage() const override;
2016-08-21 19:20:29 +02:00
private:
NodeValidationState modelValidationState = NodeValidationState::Warning;
QString modelValidationError = QStringLiteral("Missing or incorrect inputs");
2016-08-21 19:20:29 +02:00
QLabel * _label;
};