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.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<PieceNodeAngle>(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))

View File

@ -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<quint32, VDataTool*>()),

View File

@ -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.

View File

@ -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<quint8>(node.GetReverse()));
doc->SetAttribute(nod, VAbstractPattern::AttrNodeReverse, static_cast<quint8>(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."<<Q_FUNC_INFO;
@ -256,7 +247,7 @@ void VToolSeamAllowance::AddNodes(VAbstractPattern *doc, QDomElement &domElement
{
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)
{
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);
}

View File

@ -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);