add: added something

This commit is contained in:
QwQ 2020-07-28 16:43:22 +08:00
parent 5719ed92b4
commit c464499756
No known key found for this signature in database
GPG Key ID: E7FAEFAFCD031D4B
10 changed files with 51 additions and 87 deletions

View File

@ -1 +1 @@
5834
5835

View File

@ -18,6 +18,10 @@ std::shared_ptr<NodeDataType> RuleNodeModel::dataType(PortType portType, PortInd
default: return {};
}
}
std::shared_ptr<NodeDataType> ChainOutboundNodeModel::dataType(PortType, PortIndex) const
{
return NODE_TYPE_CHAINED_OUTBOUND;
}
//
// *******************************************************************************************
//
@ -35,6 +39,10 @@ unsigned int RuleNodeModel::nPorts(PortType) const
{
return 1;
}
unsigned int ChainOutboundNodeModel::nPorts(PortType) const
{
return 1;
}
//
// *******************************************************************************************
@ -54,6 +62,10 @@ std::shared_ptr<NodeData> RuleNodeModel::outData(PortIndex)
{
return std::make_shared<RuleNodeData>(dataptr);
}
std::shared_ptr<NodeData> ChainOutboundNodeModel::outData(PortIndex)
{
return std::make_shared<ChainOutboundData>(dataptr);
}
//
// *******************************************************************************************
@ -71,6 +83,10 @@ void RuleNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port
{
setInData(std::vector{ nodeData }, port);
}
void ChainOutboundNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port)
{
setInData(std::vector{ nodeData }, port);
}
//
// *******************************************************************************************
@ -89,6 +105,10 @@ QtNodes::NodeDataModel::ConnectionPolicy RuleNodeModel::portInConnectionPolicy(P
{
return NodeDataModel::ConnectionPolicy::Many;
}
QtNodes::NodeDataModel::ConnectionPolicy ChainOutboundNodeModel::portInConnectionPolicy(PortIndex) const
{
return NodeDataModel::ConnectionPolicy::One;
}
//
// *******************************************************************************************
@ -107,3 +127,7 @@ QtNodes::NodeDataModel::ConnectionPolicy RuleNodeModel::portOutConnectionPolicy(
{
return NodeDataModel::ConnectionPolicy::One;
}
QtNodes::NodeDataModel::ConnectionPolicy ChainOutboundNodeModel::portOutConnectionPolicy(PortIndex) const
{
return NodeDataModel::ConnectionPolicy::One;
}

View File

@ -60,7 +60,7 @@ namespace Qv2ray::ui::nodemodels
DECL_NODE_DATA_TYPE(InboundNodeData, NODE_TYPE_INBOUND, INBOUND);
DECL_NODE_DATA_TYPE(OutboundNodeData, NODE_TYPE_OUTBOUND, OutboundObjectMeta);
DECL_NODE_DATA_TYPE(RuleNodeData, NODE_TYPE_RULE, RuleObject);
DECL_NODE_DATA_TYPE(ChainOutboundData, NODE_TYPE_CHAINED_OUTBOUND, ChainObject);
DECL_NODE_DATA_TYPE(ChainOutboundData, NODE_TYPE_CHAINED_OUTBOUND, QString);
template<typename NODEMODEL_T>
NODEMODEL_T *convert_nodemodel(QtNodes::Node *node)
@ -81,7 +81,8 @@ namespace Qv2ray::ui::nodemodels
{ \
Q_OBJECT \
public: \
explicit NAME(std::shared_ptr<NodeDispatcher>, std::shared_ptr<CONTENT_TYPE>); \
typedef CONTENT_TYPE node_data_t; \
explicit NAME(std::shared_ptr<NodeDispatcher>, std::shared_ptr<node_data_t>); \
~NAME(){}; \
\
inline QString caption() const override \
@ -120,13 +121,13 @@ namespace Qv2ray::ui::nodemodels
void inputConnectionDeleted(const QtNodes::Connection &) override; \
void outputConnectionCreated(const QtNodes::Connection &) override; \
void outputConnectionDeleted(const QtNodes::Connection &) override; \
const std::shared_ptr<const CONTENT_TYPE> getData() const \
const std::shared_ptr<const node_data_t> getData() const \
{ \
return dataptr; \
} \
\
private: \
std::shared_ptr<CONTENT_TYPE> dataptr; \
std::shared_ptr<node_data_t> dataptr; \
QvNodeWidget *widget; \
std::shared_ptr<NodeDispatcher> dispatcher; \
}
@ -134,6 +135,7 @@ namespace Qv2ray::ui::nodemodels
DECL_NODE_DATA_MODEL(InboundNodeModel, INBOUND);
DECL_NODE_DATA_MODEL(OutboundNodeModel, OutboundObjectMeta);
DECL_NODE_DATA_MODEL(RuleNodeModel, RuleObject);
DECL_NODE_DATA_MODEL(ChainOutboundNodeModel, QString);
} // namespace Qv2ray::ui::nodemodels

View File

@ -1,14 +1,15 @@
#include "ChainOutboundNodeModel.hpp"
ChainOutboundNodeModel::ChainOutboundNodeModel(std::shared_ptr<ChainObject>)
#include "ui/node/widgets/ChainOutboundWidget.hpp"
ChainOutboundNodeModel::ChainOutboundNodeModel(std::shared_ptr<NodeDispatcher> dispatcher, std::shared_ptr<node_data_t> data)
{
this->dispatcher = dispatcher;
widget = new ChainOutboundWidget(dispatcher);
((ChainOutboundWidget *) widget)->setValue(data);
}
void ChainOutboundNodeModel::setInData(std::shared_ptr<NodeData> nodeData, PortIndex port)
{
}
void ChainOutboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port)
void ChainOutboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>>, PortIndex)
{
}
@ -27,3 +28,5 @@ void ChainOutboundNodeModel::outputConnectionCreated(const QtNodes::Connection &
void ChainOutboundNodeModel::outputConnectionDeleted(const QtNodes::Connection &)
{
}
void ChainOutboundNodeModel::onNodeHoverLeave(){};
void ChainOutboundNodeModel::onNodeHoverEnter(){};

View File

@ -1,71 +1,2 @@
#pragma once
#include "ui/node/NodeBase.hpp"
class ChainOutboundNodeModel : public NodeDataModel
{
Q_OBJECT
public:
explicit ChainOutboundNodeModel(std::shared_ptr<ChainObject>);
~ChainOutboundNodeModel(){};
inline QString caption() const override
{
return {};
}
inline bool captionVisible() const override
{
return false;
}
inline QString name() const override
{
return "ChainOutboundNodeModel";
}
ConnectionPolicy portOutConnectionPolicy(PortIndex) const override
{
return ConnectionPolicy::One;
}
ConnectionPolicy portInConnectionPolicy(PortIndex) const override
{
return ConnectionPolicy::One;
}
unsigned int nPorts(PortType) const override
{
return 1;
}
std::shared_ptr<NodeDataType> dataType(PortType, PortIndex) const override
{
return NODE_TYPE_CHAINED_OUTBOUND;
}
public:
void onNodeHoverEnter() override{};
void onNodeHoverLeave() override{};
virtual void setInData(std::shared_ptr<NodeData> nodeData, PortIndex port) override;
virtual void setInData(std::vector<std::shared_ptr<NodeData>> nodeData, PortIndex port) override;
virtual std::shared_ptr<NodeData> outData(PortIndex) override
{
return std::make_shared<ChainOutboundData>(dataptr);
}
inline QWidget *embeddedWidget() override
{
return widget;
}
inline std::unique_ptr<NodeDataModel> clone() const override
{
return {};
}
void inputConnectionCreated(const QtNodes::Connection &) override;
void inputConnectionDeleted(const QtNodes::Connection &) override;
void outputConnectionCreated(const QtNodes::Connection &) override;
void outputConnectionDeleted(const QtNodes::Connection &) override;
const std::shared_ptr<const ChainObject> getData() const
{
return dataptr;
}
private:
std::shared_ptr<ChainObject> dataptr;
QvNodeWidget *widget;
};

View File

@ -2,7 +2,7 @@
#include "core/CoreUtils.hpp"
#include "ui/node/widgets/InboundOutboundWidget.hpp"
InboundNodeModel::InboundNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<INBOUND> data) : NodeDataModel()
InboundNodeModel::InboundNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<node_data_t> data) : NodeDataModel()
{
dataptr = data;
dispatcher = _dispatcher;
@ -18,10 +18,9 @@ void InboundNodeModel::inputConnectionDeleted(const QtNodes::Connection &){};
void InboundNodeModel::outputConnectionCreated(const QtNodes::Connection &){};
void InboundNodeModel::outputConnectionDeleted(const QtNodes::Connection &){};
void InboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>>, PortIndex){};
void InboundNodeModel::onNodeHoverLeave(){};
void InboundNodeModel::onNodeHoverEnter()
{
emit dispatcher->OnInboundOutboundNodeHovered(getTag(*dataptr.get()), GetInboundInfo(*dataptr.get()));
}
void InboundNodeModel::onNodeHoverLeave(){};

View File

@ -5,7 +5,7 @@
#include "ui/node/widgets/ChainWidget.hpp"
#include "ui/node/widgets/InboundOutboundWidget.hpp"
OutboundNodeModel::OutboundNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<OutboundObjectMeta> data) : NodeDataModel()
OutboundNodeModel::OutboundNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<node_data_t> data) : NodeDataModel()
{
dataptr = data;
dispatcher = _dispatcher;
@ -41,6 +41,7 @@ void OutboundNodeModel::inputConnectionDeleted(const QtNodes::Connection &){};
void OutboundNodeModel::outputConnectionCreated(const QtNodes::Connection &){};
void OutboundNodeModel::outputConnectionDeleted(const QtNodes::Connection &){};
void OutboundNodeModel::setInData(std::vector<std::shared_ptr<NodeData>>, PortIndex){};
void OutboundNodeModel::onNodeHoverLeave(){};
void OutboundNodeModel::onNodeHoverEnter()
{
@ -54,5 +55,3 @@ void OutboundNodeModel::onNodeHoverEnter()
emit dispatcher->OnInboundOutboundNodeHovered(dataptr->getTag(), GetConnectionInfo(dataptr->connectionId));
}
}
void OutboundNodeModel::onNodeHoverLeave(){};

View File

@ -3,7 +3,7 @@
#include "core/CoreUtils.hpp"
#include "ui/node/widgets/RuleWidget.hpp"
RuleNodeModel::RuleNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<RuleObject> data) : NodeDataModel()
RuleNodeModel::RuleNodeModel(std::shared_ptr<NodeDispatcher> _dispatcher, std::shared_ptr<node_data_t> data) : NodeDataModel()
{
dataptr = data;
dispatcher = _dispatcher;

View File

@ -14,3 +14,8 @@ void ChainOutboundWidget::changeEvent(QEvent *e)
default: break;
}
}
void ChainOutboundWidget::setValue(std::shared_ptr<QString> tag)
{
tagLabel->setText(*tag);
}

View File

@ -11,6 +11,7 @@ class ChainOutboundWidget
public:
explicit ChainOutboundWidget(std::shared_ptr<NodeDispatcher> _dispatcher, QWidget *parent = nullptr);
void setValue(std::shared_ptr<QString>);
protected:
void changeEvent(QEvent *e);