Move tag strings from VToolSeamAllowance class to VAbstractPattern class. The

same strings use also VToolPiecePath class.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-24 21:35:07 +02:00
parent 7f1bab1ac6
commit 0e78efc714
5 changed files with 35 additions and 35 deletions

View File

@ -651,7 +651,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr)); detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr)); detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));
const QStringList tags = QStringList() << VToolSeamAllowance::TagNodes const QStringList tags = QStringList() << VAbstractPattern::TagNodes
<< TagData << TagData
<< TagPatternInfo << TagPatternInfo
<< TagGrainline; << TagGrainline;
@ -664,7 +664,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
{ {
switch (tags.indexOf(element.tagName())) switch (tags.indexOf(element.tagName()))
{ {
case 0:// VToolSeamAllowance::TagNodes case 0:// VAbstractPattern::TagNodes
ParseDetailNodes(element, detail); ParseDetailNodes(element, detail);
break; break;
case 1:// TagData case 1:// TagData
@ -763,24 +763,24 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail) const void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail) const
{ {
const QStringList types = QStringList() << VToolSeamAllowance::NodePoint const QStringList types = QStringList() << VAbstractPattern::NodePoint
<< VToolSeamAllowance::NodeArc << VAbstractPattern::NodeArc
<< VToolSeamAllowance::NodeSpline << VAbstractPattern::NodeSpline
<< VToolSeamAllowance::NodeSplinePath; << VAbstractPattern::NodeSplinePath;
const QDomNodeList nodeList = domElement.childNodes(); const QDomNodeList nodeList = domElement.childNodes();
for (qint32 i = 0; i < nodeList.size(); ++i) for (qint32 i = 0; i < nodeList.size(); ++i)
{ {
const QDomElement element = nodeList.at(i).toElement(); 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 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 saBefore = GetParametrDouble(element, VToolSeamAllowance::AttrSABefore, "-1");
const qreal saAfter = GetParametrDouble(element, VToolSeamAllowance::AttrSAAfter, "-1"); const qreal saAfter = GetParametrDouble(element, VToolSeamAllowance::AttrSAAfter, "-1");
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(GetParametrUInt(element, AttrAngle, "0")); const PieceNodeAngle angle = static_cast<PieceNodeAngle>(GetParametrUInt(element, AttrAngle, "0"));
const QString t = GetParametrString(element, AttrType, VToolSeamAllowance::NodePoint); const QString t = GetParametrString(element, AttrType, VAbstractPattern::NodePoint);
Tool tool; Tool tool;
switch (types.indexOf(t)) switch (types.indexOf(t))

View File

@ -89,6 +89,9 @@ const QString VAbstractPattern::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements"); const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline"); 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::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); 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::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement"); const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows"); const QString VAbstractPattern::AttrArrows = QStringLiteral("arrows");
const QString VAbstractPattern::AttrNodeReverse = QStringLiteral("reverse");
const QString VAbstractPattern::AttrAll = QStringLiteral("all"); 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::IncrementFormula = QStringLiteral("formula");
const QString VAbstractPattern::IncrementDescription = QStringLiteral("description"); 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) VAbstractPattern::VAbstractPattern(QObject *parent)
: QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()), : QObject(parent), VDomDocument(), nameActivPP(QString()), cursor(0), tools(QHash<quint32, VDataTool*>()),

View File

@ -193,6 +193,9 @@ public:
static const QString TagShowDate; static const QString TagShowDate;
static const QString TagShowMeasurements; static const QString TagShowMeasurements;
static const QString TagGrainline; static const QString TagGrainline;
static const QString TagPath;
static const QString TagNodes;
static const QString TagNode;
static const QString AttrName; static const QString AttrName;
static const QString AttrVisible; static const QString AttrVisible;
@ -205,6 +208,7 @@ public:
static const QString AttrCutNumber; static const QString AttrCutNumber;
static const QString AttrPlacement; static const QString AttrPlacement;
static const QString AttrArrows; static const QString AttrArrows;
static const QString AttrNodeReverse;
static const QString AttrAll; static const QString AttrAll;
@ -262,6 +266,11 @@ public:
static const QString IncrementFormula; static const QString IncrementFormula;
static const QString IncrementDescription; static const QString IncrementDescription;
static const QString NodeArc;
static const QString NodePoint;
static const QString NodeSpline;
static const QString NodeSplinePath;
signals: signals:
/** /**
* @brief ChangedActivPP change active pattern peace. * @brief ChangedActivPP change active pattern peace.

View File

@ -57,11 +57,7 @@
// Current version of seam allowance tag nned for backward compatibility // Current version of seam allowance tag nned for backward compatibility
const quint8 VToolSeamAllowance::pieceVersion = 2; 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::AttrVersion = QStringLiteral("version");
const QString VToolSeamAllowance::AttrNodeReverse = QStringLiteral("reverse");
const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString VToolSeamAllowance::AttrForbidFlipping = QStringLiteral("forbidFlipping");
const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance"); const QString VToolSeamAllowance::AttrSeamAllowance = QStringLiteral("seamAllowance");
const QString VToolSeamAllowance::AttrWidth = QStringLiteral("width"); 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::AttrSAAfter = QStringLiteral("after");
const QString VToolSeamAllowance::AttrUnited = QStringLiteral("united"); 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() VToolSeamAllowance::~VToolSeamAllowance()
{ {
@ -204,14 +195,14 @@ void VToolSeamAllowance::Remove(bool ask)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node) 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()); doc->SetAttribute(nod, AttrIdObject, node.GetId());
const Tool type = node.GetTypeTool(); const Tool type = node.GetTypeTool();
if (type != Tool::NodePoint) if (type != Tool::NodePoint)
{ {
doc->SetAttribute(nod, AttrNodeReverse, static_cast<quint8>(node.GetReverse())); doc->SetAttribute(nod, VAbstractPattern::AttrNodeReverse, static_cast<quint8>(node.GetReverse()));
} }
else else
{ {
@ -225,16 +216,16 @@ void VToolSeamAllowance::AddNode(VAbstractPattern *doc, QDomElement &domElement,
switch (type) switch (type)
{ {
case (Tool::NodeArc): case (Tool::NodeArc):
doc->SetAttribute(nod, AttrType, NodeArc); doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeArc);
break; break;
case (Tool::NodePoint): case (Tool::NodePoint):
doc->SetAttribute(nod, AttrType, NodePoint); doc->SetAttribute(nod, AttrType, VAbstractPattern::NodePoint);
break; break;
case (Tool::NodeSpline): case (Tool::NodeSpline):
doc->SetAttribute(nod, AttrType, NodeSpline); doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeSpline);
break; break;
case (Tool::NodeSplinePath): case (Tool::NodeSplinePath):
doc->SetAttribute(nod, AttrType, NodeSplinePath); doc->SetAttribute(nod, AttrType, VAbstractPattern::NodeSplinePath);
break; break;
default: default:
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO; qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
@ -256,7 +247,7 @@ void VToolSeamAllowance::AddNodes(VAbstractPattern *doc, QDomElement &domElement
{ {
if (piece.GetPath().CountNodes() > 0) if (piece.GetPath().CountNodes() > 0)
{ {
QDomElement nodesElement = doc->createElement(TagNodes); QDomElement nodesElement = doc->createElement(VAbstractPattern::TagNodes);
for (int i = 0; i < piece.GetPath().CountNodes(); ++i) for (int i = 0; i < piece.GetPath().CountNodes(); ++i)
{ {
AddNode(doc, nodesElement, piece.GetPath().at(i)); AddNode(doc, nodesElement, piece.GetPath().at(i));
@ -722,7 +713,7 @@ void VToolSeamAllowance::SaveDialogChange()
const VPiece newDet = dialogTool->GetPiece(); const VPiece newDet = dialogTool->GetPiece();
const VPiece oldDet = VAbstractTool::data.GetPiece(id); 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); connect(saveCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
qApp->getUndoStack()->push(saveCommand); qApp->getUndoStack()->push(saveCommand);
} }

View File

@ -54,11 +54,7 @@ public:
static const quint8 pieceVersion; static const quint8 pieceVersion;
static const QString TagNodes;
static const QString TagNode;
static const QString AttrVersion; static const QString AttrVersion;
static const QString AttrNodeReverse;
static const QString AttrForbidFlipping; static const QString AttrForbidFlipping;
static const QString AttrSeamAllowance; static const QString AttrSeamAllowance;
static const QString AttrWidth; static const QString AttrWidth;
@ -66,11 +62,6 @@ public:
static const QString AttrSAAfter; static const QString AttrSAAfter;
static const QString AttrUnited; static const QString AttrUnited;
static const QString NodeArc;
static const QString NodePoint;
static const QString NodeSpline;
static const QString NodeSplinePath;
void Remove(bool ask); void Remove(bool ask);
static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node); static void AddNode(VAbstractPattern *doc, QDomElement &domElement, const VPieceNode &node);