From 0e78efc71464da9c5ee4bafde78bdab5a0e792b0 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 24 Nov 2016 21:35:07 +0200 Subject: [PATCH] Move tag strings from VToolSeamAllowance class to VAbstractPattern class. The same strings use also VToolPiecePath class. --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 18 +++++++------- src/libs/ifc/xml/vabstractpattern.cpp | 9 +++++++ src/libs/ifc/xml/vabstractpattern.h | 9 +++++++ src/libs/vtools/tools/vtoolseamallowance.cpp | 25 +++++++------------- src/libs/vtools/tools/vtoolseamallowance.h | 9 ------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 65e808953..77962e3ea 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -651,7 +651,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr)); - const QStringList tags = QStringList() << VToolSeamAllowance::TagNodes + const QStringList tags = QStringList() << VAbstractPattern::TagNodes << TagData << TagPatternInfo << TagGrainline; @@ -664,7 +664,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document { switch (tags.indexOf(element.tagName())) { - case 0:// VToolSeamAllowance::TagNodes + case 0:// VAbstractPattern::TagNodes ParseDetailNodes(element, detail); break; case 1:// TagData @@ -763,24 +763,24 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document //--------------------------------------------------------------------------------------------------------------------- void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail) const { - const QStringList types = QStringList() << VToolSeamAllowance::NodePoint - << VToolSeamAllowance::NodeArc - << VToolSeamAllowance::NodeSpline - << VToolSeamAllowance::NodeSplinePath; + const QStringList types = QStringList() << VAbstractPattern::NodePoint + << VAbstractPattern::NodeArc + << VAbstractPattern::NodeSpline + << VAbstractPattern::NodeSplinePath; const QDomNodeList nodeList = domElement.childNodes(); for (qint32 i = 0; i < nodeList.size(); ++i) { const QDomElement element = nodeList.at(i).toElement(); - if (not element.isNull() && element.tagName() == VToolSeamAllowance::TagNode) + if (not element.isNull() && element.tagName() == VAbstractPattern::TagNode) { const quint32 id = GetParametrUInt(element, AttrIdObject, NULL_ID_STR); - const bool reverse = GetParametrUInt(element, VToolSeamAllowance::AttrNodeReverse, "0"); + const bool reverse = GetParametrUInt(element, VAbstractPattern::AttrNodeReverse, "0"); const qreal saBefore = GetParametrDouble(element, VToolSeamAllowance::AttrSABefore, "-1"); const qreal saAfter = GetParametrDouble(element, VToolSeamAllowance::AttrSAAfter, "-1"); const PieceNodeAngle angle = static_cast(GetParametrUInt(element, AttrAngle, "0")); - const QString t = GetParametrString(element, AttrType, VToolSeamAllowance::NodePoint); + const QString t = GetParametrString(element, AttrType, VAbstractPattern::NodePoint); Tool tool; switch (types.indexOf(t)) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 974d9f9ce..3dd8510ad 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -89,6 +89,9 @@ const QString VAbstractPattern::TagSize = QStringLiteral("size"); const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements"); const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline"); +const QString VAbstractPattern::TagPath = QStringLiteral("path"); +const QString VAbstractPattern::TagNodes = QStringLiteral("nodes"); +const QString VAbstractPattern::TagNode = QStringLiteral("node"); const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); @@ -101,6 +104,7 @@ const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); +const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); @@ -158,6 +162,11 @@ const QString VAbstractPattern::IncrementName = QStringLiteral("name"); const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula"); const QString VAbstractPattern::IncrementDescription = QStringLiteral("description"); +const QString VAbstractPattern::NodeArc = QStringLiteral("NodeArc"); +const QString VAbstractPattern::NodePoint = QStringLiteral("NodePoint"); +const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline"); +const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath"); + //--------------------------------------------------------------------------------------------------------------------- VAbstractPattern::VAbstractPattern(QObject *parent) : QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash()), diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 86e38028e..d951656a5 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -193,6 +193,9 @@ public: static const QString TagShowDate; static const QString TagShowMeasurements; static const QString TagGrainline; + static const QString TagPath; + static const QString TagNodes; + static const QString TagNode; static const QString AttrName; static const QString AttrVisible; @@ -205,6 +208,7 @@ public: static const QString AttrCutNumber; static const QString AttrPlacement; static const QString AttrArrows; + static const QString AttrNodeReverse; static const QString AttrAll; @@ -262,6 +266,11 @@ public: static const QString IncrementFormula; static const QString IncrementDescription; + static const QString NodeArc; + static const QString NodePoint; + static const QString NodeSpline; + static const QString NodeSplinePath; + signals: /** * @brief ChangedActivPP change active pattern peace. diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index aa6c46758..c3f06b6cf 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -57,11 +57,7 @@ // Current version of seam allowance tag nned for backward compatibility const quint8 VToolSeamAllowance::pieceVersion = 2; -const QString VToolSeamAllowance::TagNodes = QStringLiteral("nodes"); -const QString VToolSeamAllowance::TagNode = QStringLiteral("node"); - const QString VToolSeamAllowance::AttrVersion = QStringLiteral("version"); -const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance"); const QString VToolSeamAllowance::AttrWidth = QStringLiteral("width"); @@ -69,11 +65,6 @@ const QString VToolSeamAllowance::AttrSABefore = QStringLiteral("before"); const QString VToolSeamAllowance::AttrSAAfter = QStringLiteral("after"); const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united"); -const QString VToolSeamAllowance::NodeArc = QStringLiteral("NodeArc"); -const QString VToolSeamAllowance::NodePoint = QStringLiteral("NodePoint"); -const QString VToolSeamAllowance::NodeSpline = QStringLiteral("NodeSpline"); -const QString VToolSeamAllowance::NodeSplinePath = QStringLiteral("NodeSplinePath"); - //--------------------------------------------------------------------------------------------------------------------- VToolSeamAllowance::~VToolSeamAllowance() { @@ -204,14 +195,14 @@ void VToolSeamAllowance::Remove(bool ask) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node) { - QDomElement nod = doc->createElement(TagNode); + QDomElement nod = doc->createElement(VAbstractPattern::TagNode); doc->SetAttribute(nod, AttrIdObject, node.GetId()); const Tool type = node.GetTypeTool(); if (type != Tool::NodePoint) { - doc->SetAttribute(nod, AttrNodeReverse, static_cast(node.GetReverse())); + doc->SetAttribute(nod, VAbstractPattern::AttrNodeReverse, static_cast(node.GetReverse())); } else { @@ -225,16 +216,16 @@ void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement, switch (type) { case (Tool::NodeArc): - doc->SetAttribute(nod, AttrType, NodeArc); + doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeArc); break; case (Tool::NodePoint): - doc->SetAttribute(nod, AttrType, NodePoint); + doc->SetAttribute(nod, AttrType, VAbstractPattern::NodePoint); break; case (Tool::NodeSpline): - doc->SetAttribute(nod, AttrType, NodeSpline); + doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeSpline); break; case (Tool::NodeSplinePath): - doc->SetAttribute(nod, AttrType, NodeSplinePath); + doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeSplinePath); break; default: qDebug()<<"May be wrong tool type!!! Ignoring."< 0) { - QDomElement nodesElement = doc->createElement(TagNodes); + QDomElement nodesElement = doc->createElement(VAbstractPattern::TagNodes); for (int i = 0; i < piece.GetPath().CountNodes(); ++i) { AddNode(doc, nodesElement, piece.GetPath().at(i)); @@ -722,7 +713,7 @@ void VToolSeamAllowance::SaveDialogChange() const VPiece newDet = dialogTool->GetPiece(); const VPiece oldDet = VAbstractTool::data.GetPiece(id); - SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id, this->scene()); + SavePieceOptions *saveCommand = new SavePieceOptions(oldDet, newDet, doc, id); connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(saveCommand); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 04605a66e..a12de91d3 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -54,11 +54,7 @@ public: static const quint8 pieceVersion; - static const QString TagNodes; - static const QString TagNode; - static const QString AttrVersion; - static const QString AttrNodeReverse; static const QString AttrForbidFlipping; static const QString AttrSeamAllowance; static const QString AttrWidth; @@ -66,11 +62,6 @@ public: static const QString AttrSAAfter; static const QString AttrUnited; - static const QString NodeArc; - static const QString NodePoint; - static const QString NodeSpline; - static const QString NodeSplinePath; - void Remove(bool ask); static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);