fix: some upgrades to the QNodeEditor

This commit is contained in:
Qv2ray-dev 2020-03-17 19:58:23 +08:00
parent e7b7592dd5
commit d92979bafc
8 changed files with 26 additions and 15 deletions

@ -1 +1 @@
Subproject commit c93f1c1826d46d5d60f118688cd830b39af8b9c6 Subproject commit 63af7f3d0db5b52b10c270912b49fd8cf7f250c1

View File

@ -66,4 +66,4 @@ qt5_wrap_cpp(QNODEEDITOR_SOURCES
OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp
) )
set(QNODEEDITOR_QRC_RESOURCES ${QNODEEDITOR_DIR}/resources/QNodeEditor_resources.qrc) set(QNODEEDITOR_QRC_RESOURCES ${QNODEEDITOR_DIR}/resources/resources.qrc)

View File

@ -1 +1 @@
4723 4726

View File

@ -650,7 +650,8 @@ void RouteEditor::on_enableBalancerCB_stateChanged(int arg1)
for (auto &&[_, conn] : nodeScene->connections()) for (auto &&[_, conn] : nodeScene->connections())
{ {
if (conn.get()->getNode(PortType::Out) == ruleNode) auto x = conn.get();
if (x != nullptr && x->getNode(PortType::Out) == ruleNode)
{ {
nodeScene->deleteConnection(*conn); nodeScene->deleteConnection(*conn);
} }

View File

@ -36,7 +36,7 @@ class QvInboundNodeModel : public NodeDataModel
return "InboundNode"; return "InboundNode";
} }
NodeDataType dataType(PortType portType, PortIndex portIndex) const override std::shared_ptr<NodeDataType> dataType(PortType portType, PortIndex portIndex) const override
{ {
Q_UNUSED(portType); Q_UNUSED(portType);
Q_UNUSED(portIndex); Q_UNUSED(portIndex);
@ -62,6 +62,10 @@ class QvInboundNodeModel : public NodeDataModel
{ {
return _label; return _label;
} }
std::unique_ptr<NodeDataModel> clone() const override
{
return std::make_unique<QvInboundNodeModel>(_in);
}
private: private:
NodeValidationState modelValidationState = NodeValidationState::Warning; NodeValidationState modelValidationState = NodeValidationState::Warning;

View File

@ -20,8 +20,8 @@ const int GRAPH_NODE_LABEL_FONTSIZE_INCREMENT = 3;
namespace Qv2ray::ui::nodemodels namespace Qv2ray::ui::nodemodels
{ {
const NodeDataType outboundType = { "outbound", "Outbound Object" }; const std::shared_ptr<NodeDataType> outboundType = std::make_shared<NodeDataType>("outbound", "Outbound Object");
const NodeDataType inboundType = { "inbound", "Inbound Object" }; const std::shared_ptr<NodeDataType> inboundType = std::make_shared<NodeDataType>("inbound", "Inbound Object");
/// The class can potentially incapsulate any user data /// The class can potentially incapsulate any user data
/// need to be transferred within the Node Editor graph /// need to be transferred within the Node Editor graph
class InboundNodeData : public NodeData class InboundNodeData : public NodeData
@ -32,7 +32,7 @@ namespace Qv2ray::ui::nodemodels
{ {
} }
NodeDataType type() const override std::shared_ptr<NodeDataType> type() const override
{ {
return inboundType; return inboundType;
} }
@ -57,7 +57,7 @@ namespace Qv2ray::ui::nodemodels
{ {
} }
NodeDataType type() const override std::shared_ptr<NodeDataType> type() const override
{ {
return outboundType; return outboundType;
} }
@ -81,7 +81,7 @@ namespace Qv2ray::ui::nodemodels
{ {
} }
NodeDataType type() const override std::shared_ptr<NodeDataType> type() const override
{ {
return outboundType; return outboundType;
} }

View File

@ -35,7 +35,7 @@ class QvOutboundNodeModel : public NodeDataModel
return "OutboundNode"; return "OutboundNode";
} }
NodeDataType dataType(PortType portType, PortIndex portIndex) const override std::shared_ptr<NodeDataType> dataType(PortType portType, PortIndex portIndex) const override
{ {
Q_UNUSED(portType); Q_UNUSED(portType);
Q_UNUSED(portIndex); Q_UNUSED(portIndex);
@ -70,6 +70,10 @@ class QvOutboundNodeModel : public NodeDataModel
{ {
return ConnectionPolicy::Many; return ConnectionPolicy::Many;
} }
std::unique_ptr<NodeDataModel> clone() const override
{
return std::make_unique<QvOutboundNodeModel>(_out);
}
private: private:
NodeValidationState modelValidationState = NodeValidationState::Warning; NodeValidationState modelValidationState = NodeValidationState::Warning;

View File

@ -47,7 +47,7 @@ class QvRuleNodeDataModel : public NodeDataModel
return "RuleNode"; return "RuleNode";
} }
NodeDataType dataType(PortType portType, PortIndex portIndex) const override std::shared_ptr<NodeDataType> dataType(PortType portType, PortIndex portIndex) const override
{ {
Q_UNUSED(portIndex) Q_UNUSED(portIndex)
@ -57,10 +57,8 @@ class QvRuleNodeDataModel : public NodeDataModel
case PortType::Out: return outboundType; case PortType::Out: return outboundType;
case PortType::None: break; default: return {};
} }
return NodeDataType();
} }
std::shared_ptr<NodeData> outData(PortIndex port) override std::shared_ptr<NodeData> outData(PortIndex port) override
@ -96,6 +94,10 @@ class QvRuleNodeDataModel : public NodeDataModel
{ {
return ConnectionPolicy::One; return ConnectionPolicy::One;
} }
std::unique_ptr<NodeDataModel> clone() const override
{
return std::make_unique<QvRuleNodeDataModel>(_ruleTag);
}
private: private:
NodeValidationState modelValidationState = NodeValidationState::Warning; NodeValidationState modelValidationState = NodeValidationState::Warning;