From d92979bafcf016d98472a97c8ba03deee030e2b9 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:58:23 +0800 Subject: [PATCH] fix: some upgrades to the QNodeEditor --- 3rdparty/QNodeEditor | 2 +- cmake/qnodeeditor.cmake | 2 +- makespec/BUILDVERSION | 2 +- src/ui/editors/w_RoutesEditor.cpp | 3 ++- src/ui/models/InboundNodeModel.hpp | 6 +++++- src/ui/models/NodeModelsBase.hpp | 10 +++++----- src/ui/models/OutboundNodeModel.hpp | 6 +++++- src/ui/models/RuleNodeModel.hpp | 10 ++++++---- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/3rdparty/QNodeEditor b/3rdparty/QNodeEditor index c93f1c18..63af7f3d 160000 --- a/3rdparty/QNodeEditor +++ b/3rdparty/QNodeEditor @@ -1 +1 @@ -Subproject commit c93f1c1826d46d5d60f118688cd830b39af8b9c6 +Subproject commit 63af7f3d0db5b52b10c270912b49fd8cf7f250c1 diff --git a/cmake/qnodeeditor.cmake b/cmake/qnodeeditor.cmake index 1563ee0c..1708cb72 100644 --- a/cmake/qnodeeditor.cmake +++ b/cmake/qnodeeditor.cmake @@ -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 ) -set(QNODEEDITOR_QRC_RESOURCES ${QNODEEDITOR_DIR}/resources/QNodeEditor_resources.qrc) +set(QNODEEDITOR_QRC_RESOURCES ${QNODEEDITOR_DIR}/resources/resources.qrc) diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index d9c2ba3e..e34c801c 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -4723 \ No newline at end of file +4726 \ No newline at end of file diff --git a/src/ui/editors/w_RoutesEditor.cpp b/src/ui/editors/w_RoutesEditor.cpp index 3f9d9c15..8f36a2ea 100644 --- a/src/ui/editors/w_RoutesEditor.cpp +++ b/src/ui/editors/w_RoutesEditor.cpp @@ -650,7 +650,8 @@ void RouteEditor::on_enableBalancerCB_stateChanged(int arg1) 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); } diff --git a/src/ui/models/InboundNodeModel.hpp b/src/ui/models/InboundNodeModel.hpp index fac642d4..5d3e990b 100644 --- a/src/ui/models/InboundNodeModel.hpp +++ b/src/ui/models/InboundNodeModel.hpp @@ -36,7 +36,7 @@ class QvInboundNodeModel : public NodeDataModel return "InboundNode"; } - NodeDataType dataType(PortType portType, PortIndex portIndex) const override + std::shared_ptr dataType(PortType portType, PortIndex portIndex) const override { Q_UNUSED(portType); Q_UNUSED(portIndex); @@ -62,6 +62,10 @@ class QvInboundNodeModel : public NodeDataModel { return _label; } + std::unique_ptr clone() const override + { + return std::make_unique(_in); + } private: NodeValidationState modelValidationState = NodeValidationState::Warning; diff --git a/src/ui/models/NodeModelsBase.hpp b/src/ui/models/NodeModelsBase.hpp index 69b5f204..3e5d0068 100644 --- a/src/ui/models/NodeModelsBase.hpp +++ b/src/ui/models/NodeModelsBase.hpp @@ -20,8 +20,8 @@ const int GRAPH_NODE_LABEL_FONTSIZE_INCREMENT = 3; namespace Qv2ray::ui::nodemodels { - const NodeDataType outboundType = { "outbound", "Outbound Object" }; - const NodeDataType inboundType = { "inbound", "Inbound Object" }; + const std::shared_ptr outboundType = std::make_shared("outbound", "Outbound Object"); + const std::shared_ptr inboundType = std::make_shared("inbound", "Inbound Object"); /// The class can potentially incapsulate any user data /// need to be transferred within the Node Editor graph class InboundNodeData : public NodeData @@ -32,7 +32,7 @@ namespace Qv2ray::ui::nodemodels { } - NodeDataType type() const override + std::shared_ptr type() const override { return inboundType; } @@ -57,7 +57,7 @@ namespace Qv2ray::ui::nodemodels { } - NodeDataType type() const override + std::shared_ptr type() const override { return outboundType; } @@ -81,7 +81,7 @@ namespace Qv2ray::ui::nodemodels { } - NodeDataType type() const override + std::shared_ptr type() const override { return outboundType; } diff --git a/src/ui/models/OutboundNodeModel.hpp b/src/ui/models/OutboundNodeModel.hpp index d1e9ce2a..780dee4e 100644 --- a/src/ui/models/OutboundNodeModel.hpp +++ b/src/ui/models/OutboundNodeModel.hpp @@ -35,7 +35,7 @@ class QvOutboundNodeModel : public NodeDataModel return "OutboundNode"; } - NodeDataType dataType(PortType portType, PortIndex portIndex) const override + std::shared_ptr dataType(PortType portType, PortIndex portIndex) const override { Q_UNUSED(portType); Q_UNUSED(portIndex); @@ -70,6 +70,10 @@ class QvOutboundNodeModel : public NodeDataModel { return ConnectionPolicy::Many; } + std::unique_ptr clone() const override + { + return std::make_unique(_out); + } private: NodeValidationState modelValidationState = NodeValidationState::Warning; diff --git a/src/ui/models/RuleNodeModel.hpp b/src/ui/models/RuleNodeModel.hpp index 7d889e0f..5839f6de 100644 --- a/src/ui/models/RuleNodeModel.hpp +++ b/src/ui/models/RuleNodeModel.hpp @@ -47,7 +47,7 @@ class QvRuleNodeDataModel : public NodeDataModel return "RuleNode"; } - NodeDataType dataType(PortType portType, PortIndex portIndex) const override + std::shared_ptr dataType(PortType portType, PortIndex portIndex) const override { Q_UNUSED(portIndex) @@ -57,10 +57,8 @@ class QvRuleNodeDataModel : public NodeDataModel case PortType::Out: return outboundType; - case PortType::None: break; + default: return {}; } - - return NodeDataType(); } std::shared_ptr outData(PortIndex port) override @@ -96,6 +94,10 @@ class QvRuleNodeDataModel : public NodeDataModel { return ConnectionPolicy::One; } + std::unique_ptr clone() const override + { + return std::make_unique(_ruleTag); + } private: NodeValidationState modelValidationState = NodeValidationState::Warning;