diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 51c1ce34c..f4e7fccfd 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -54,6 +54,9 @@ int main(int argc, char *argv[]) qt_qhash_seed.store(0); // Lock producing random attribute order in XML + // Need to internally move a node inside a piece main path + qRegisterMetaTypeStreamOperators("VPieceNode"); + #ifndef Q_OS_MAC // supports natively InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp index 36df0b31b..e2692521d 100644 --- a/src/libs/vpatterndb/vpiecenode.cpp +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -97,6 +97,21 @@ VPieceNode &VPieceNode::operator=(const VPieceNode &node) VPieceNode::~VPieceNode() {} +// Friend functions +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator<<(QDataStream &out, const VPieceNode &p) +{ + out << p.d; + return out; +} + +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator>>(QDataStream &in, VPieceNode &p) +{ + in >> *p.d; + return in; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VPieceNode::GetId() const { diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h index 66684686f..c4215586f 100644 --- a/src/libs/vpatterndb/vpiecenode.h +++ b/src/libs/vpatterndb/vpiecenode.h @@ -47,6 +47,9 @@ public: VPieceNode &operator=(const VPieceNode &node); ~VPieceNode(); + friend QDataStream& operator<<(QDataStream& out, const VPieceNode& p); + friend QDataStream& operator>>(QDataStream& in, VPieceNode& p); + quint32 GetId() const; void SetId(quint32 id); diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index bd53c1ef3..8e91c7a10 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -92,6 +92,9 @@ public: ~VPieceNodeData(); + friend QDataStream& operator<<(QDataStream& out, const VPieceNodeData& p); + friend QDataStream& operator>>(QDataStream& in, VPieceNodeData& p); + /** @brief id object id. */ quint32 m_id; @@ -116,7 +119,7 @@ public: PieceNodeAngle m_angleType; - PassmarkLineType m_passmarkLineType; + PassmarkLineType m_passmarkLineType; PassmarkAngleType m_passmarkAngleType; private: @@ -126,6 +129,54 @@ private: VPieceNodeData::~VPieceNodeData() {} +// Friend functions +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p) +{ + out << p.m_id + << static_cast(p.m_typeTool) + << p.m_reverse + << p.m_excluded + << p.m_isPassmark + << p.m_saBefore + << p.m_saAfter + << p.m_formulaWidthBefore + << p.m_formulaWidthAfter + << static_cast(p.m_angleType) + << static_cast(p.m_passmarkLineType) + << static_cast(p.m_passmarkAngleType); + return out; +} + +//--------------------------------------------------------------------------------------------------------------------- +QDataStream &operator>>(QDataStream &in, VPieceNodeData &p) +{ + int typeTool = 0; + int angleType = 0; + int passmarkLineType = 0; + int passmarkAngleType = 0; + + in >> p.m_id + >> typeTool + >> p.m_reverse + >> p.m_excluded + >> p.m_isPassmark + >> p.m_saBefore + >> p.m_saAfter + >> p.m_formulaWidthBefore + >> p.m_formulaWidthAfter + >> angleType + >> passmarkLineType + >> passmarkAngleType; + + p.m_typeTool = static_cast(typeTool); + p.m_angleType = static_cast(angleType); + p.m_passmarkLineType = static_cast(passmarkLineType); + p.m_passmarkAngleType = static_cast(passmarkAngleType); + + return in; +} + QT_WARNING_POP #endif // VPIECENODE_P_H