VPatternConverter use QStringLiteral where possible.
--HG-- branch : develop
This commit is contained in:
parent
00e36db0c5
commit
24e8a42aa7
|
@ -64,6 +64,45 @@ const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pa
|
||||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
|
|
||||||
|
// The list of all string we use for conversion
|
||||||
|
// Better to use global variables because repeating QStringLiteral blows up code size
|
||||||
|
const QString strUnit = QStringLiteral("unit");
|
||||||
|
const QString strVersion = QStringLiteral("version");
|
||||||
|
const QString strName = QStringLiteral("name");
|
||||||
|
const QString strBase = QStringLiteral("base");
|
||||||
|
const QString strFormula = QStringLiteral("formula");
|
||||||
|
const QString strId = QStringLiteral("id");
|
||||||
|
const QString strKGrowth = QStringLiteral("kgrowth");
|
||||||
|
const QString strKSize = QStringLiteral("ksize");
|
||||||
|
const QString strPoint = QStringLiteral("point");
|
||||||
|
const QString strLength = QStringLiteral("length");
|
||||||
|
const QString strAngle = QStringLiteral("angle");
|
||||||
|
const QString strC1Radius = QStringLiteral("c1Radius");
|
||||||
|
const QString strC2Radius = QStringLiteral("c2Radius");
|
||||||
|
const QString strCRadius = QStringLiteral("cRadius");
|
||||||
|
const QString strArc = QStringLiteral("arc");
|
||||||
|
const QString strAngle1 = QStringLiteral("angle1");
|
||||||
|
const QString strAngle2 = QStringLiteral("angle2");
|
||||||
|
const QString strRadius = QStringLiteral("radius");
|
||||||
|
const QString strPathPoint = QStringLiteral("pathPoint");
|
||||||
|
const QString strKAsm1 = QStringLiteral("kAsm1");
|
||||||
|
const QString strKAsm2 = QStringLiteral("kAsm2");
|
||||||
|
const QString strPath = QStringLiteral("path");
|
||||||
|
const QString strType = QStringLiteral("type");
|
||||||
|
const QString strCutArc = QStringLiteral("cutArc");
|
||||||
|
const QString strCutSpline = QStringLiteral("cutSpline");
|
||||||
|
const QString strCutSplinePath = QStringLiteral("cutSplinePath");
|
||||||
|
const QString strColor = QStringLiteral("color");
|
||||||
|
const QString strMeasurements = QStringLiteral("measurements");
|
||||||
|
const QString strIncrement = QStringLiteral("increment");
|
||||||
|
const QString strIncrements = QStringLiteral("increments");
|
||||||
|
const QString strModeling = QStringLiteral("modeling");
|
||||||
|
const QString strTools = QStringLiteral("tools");
|
||||||
|
const QString strIdTool = QStringLiteral("idTool");
|
||||||
|
const QString strIdObject = QStringLiteral("idObject");
|
||||||
|
const QString strChildren = QStringLiteral("children");
|
||||||
|
const QString strChild = QStringLiteral("child");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||||
:VAbstractConverter(fileName)
|
:VAbstractConverter(fileName)
|
||||||
|
@ -345,12 +384,12 @@ void VPatternConverter::ToV0_3_3()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::TagUnitToV0_2_0()
|
void VPatternConverter::TagUnitToV0_2_0()
|
||||||
{
|
{
|
||||||
QDomElement unit = createElement("unit");
|
QDomElement unit = createElement(strUnit);
|
||||||
QDomText newNodeText = createTextNode(MUnitV0_1_4());
|
QDomText newNodeText = createTextNode(MUnitV0_1_4());
|
||||||
unit.appendChild(newNodeText);
|
unit.appendChild(newNodeText);
|
||||||
|
|
||||||
QDomElement patternElement = documentElement();
|
QDomElement patternElement = documentElement();
|
||||||
patternElement.insertAfter(unit, patternElement.firstChildElement("version"));
|
patternElement.insertAfter(unit, patternElement.firstChildElement(strVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -385,16 +424,16 @@ QSet<QString> VPatternConverter::FixIncrementsToV0_2_0()
|
||||||
QDomElement domElement = domNode.toElement();
|
QDomElement domElement = domNode.toElement();
|
||||||
if (domElement.isNull() == false)
|
if (domElement.isNull() == false)
|
||||||
{
|
{
|
||||||
if (domElement.tagName() == "increment")
|
if (domElement.tagName() == strIncrement)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const QString name = GetParametrString(domElement, "name");
|
const QString name = GetParametrString(domElement, strName);
|
||||||
names.insert(name);
|
names.insert(name);
|
||||||
domElement.setAttribute("name", "#"+name);
|
domElement.setAttribute(strName, QLatin1String("#")+name);
|
||||||
|
|
||||||
const QString base = GetParametrString(domElement, "base");
|
const QString base = GetParametrString(domElement, strBase);
|
||||||
domElement.setAttribute("formula", base);
|
domElement.setAttribute(strFormula, base);
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -402,10 +441,10 @@ QSet<QString> VPatternConverter::FixIncrementsToV0_2_0()
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
excep.AddMoreInformation(e.ErrorMessage());
|
||||||
throw excep;
|
throw excep;
|
||||||
}
|
}
|
||||||
domElement.removeAttribute("id");
|
domElement.removeAttribute(strId);
|
||||||
domElement.removeAttribute("kgrowth");
|
domElement.removeAttribute(strKGrowth);
|
||||||
domElement.removeAttribute("ksize");
|
domElement.removeAttribute(strKSize);
|
||||||
domElement.removeAttribute("base");
|
domElement.removeAttribute(strBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -418,15 +457,15 @@ QSet<QString> VPatternConverter::FixIncrementsToV0_2_0()
|
||||||
void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("point");
|
const QDomNodeList list = elementsByTagName(strPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "length");
|
formula = GetParametrString(dom, strLength);
|
||||||
dom.setAttribute("length", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strLength, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -435,8 +474,8 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle");
|
formula = GetParametrString(dom, strAngle);
|
||||||
dom.setAttribute("angle", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -444,8 +483,8 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "c1Radius");
|
formula = GetParametrString(dom, strC1Radius);
|
||||||
dom.setAttribute("c1Radius", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strC1Radius, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -454,8 +493,8 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "c2Radius");
|
formula = GetParametrString(dom, strC2Radius);
|
||||||
dom.setAttribute("c2Radius", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strC2Radius, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -464,8 +503,8 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "cRadius");
|
formula = GetParametrString(dom, strCRadius);
|
||||||
dom.setAttribute("cRadius", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strCRadius, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -478,15 +517,15 @@ void VPatternConverter::FixPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("arc");
|
const QDomNodeList list = elementsByTagName(strArc);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle1");
|
formula = GetParametrString(dom, strAngle1);
|
||||||
dom.setAttribute("angle1", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle1, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -495,8 +534,8 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle2");
|
formula = GetParametrString(dom, strAngle2);
|
||||||
dom.setAttribute("angle2", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle2, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -505,8 +544,8 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "radius");
|
formula = GetParametrString(dom, strRadius);
|
||||||
dom.setAttribute("radius", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strRadius, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -515,8 +554,8 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "length");
|
formula = GetParametrString(dom, strLength);
|
||||||
dom.setAttribute("length", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strLength, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -529,15 +568,15 @@ void VPatternConverter::FixArcExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &names)
|
void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("pathPoint");
|
const QDomNodeList list = elementsByTagName(strPathPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "kAsm1");
|
formula = GetParametrString(dom, strKAsm1);
|
||||||
dom.setAttribute("kAsm1", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strKAsm1, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -546,8 +585,8 @@ void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &nam
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "kAsm2");
|
formula = GetParametrString(dom, strKAsm2);
|
||||||
dom.setAttribute("kAsm2", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strKAsm2, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -556,8 +595,8 @@ void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &nam
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle");
|
formula = GetParametrString(dom, strAngle);
|
||||||
dom.setAttribute("angle", FixIncrementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle, FixIncrementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -570,15 +609,15 @@ void VPatternConverter::FixPathPointExpressionsToV0_2_0(const QSet<QString> &nam
|
||||||
void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("point");
|
const QDomNodeList list = elementsByTagName(strPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "length");
|
formula = GetParametrString(dom, strLength);
|
||||||
dom.setAttribute("length", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strLength, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -587,8 +626,8 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle");
|
formula = GetParametrString(dom, strAngle);
|
||||||
dom.setAttribute("angle", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -596,8 +635,8 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "c1Radius");
|
formula = GetParametrString(dom, strC1Radius);
|
||||||
dom.setAttribute("c1Radius", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strC1Radius, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -606,8 +645,8 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "c2Radius");
|
formula = GetParametrString(dom, strC2Radius);
|
||||||
dom.setAttribute("c2Radius", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strC2Radius, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -616,8 +655,8 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "cRadius");
|
formula = GetParametrString(dom, strCRadius);
|
||||||
dom.setAttribute("cRadius", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strCRadius, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -630,15 +669,15 @@ void VPatternConverter::ConvertPointExpressionsToV0_2_0(const QMap<QString, QStr
|
||||||
void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("arc");
|
const QDomNodeList list = elementsByTagName(strArc);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle1");
|
formula = GetParametrString(dom, strAngle1);
|
||||||
dom.setAttribute("angle1", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle1, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -647,8 +686,8 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QStrin
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle2");
|
formula = GetParametrString(dom, strAngle2);
|
||||||
dom.setAttribute("angle2", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle2, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -657,8 +696,8 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QStrin
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "radius");
|
formula = GetParametrString(dom, strRadius);
|
||||||
dom.setAttribute("radius", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strRadius, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -667,8 +706,8 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QStrin
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "length");
|
formula = GetParametrString(dom, strLength);
|
||||||
dom.setAttribute("length", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strLength, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -681,15 +720,15 @@ void VPatternConverter::ConvertArcExpressionsToV0_2_0(const QMap<QString, QStrin
|
||||||
void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString, QString> &names)
|
||||||
{
|
{
|
||||||
QString formula;
|
QString formula;
|
||||||
const QDomNodeList list = elementsByTagName("pathPoint");
|
const QDomNodeList list = elementsByTagName(strPathPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement dom = list.at(i).toElement();
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "kAsm1");
|
formula = GetParametrString(dom, strKAsm1);
|
||||||
dom.setAttribute("kAsm1", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strKAsm1, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -698,8 +737,8 @@ void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString,
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "kAsm2");
|
formula = GetParametrString(dom, strKAsm2);
|
||||||
dom.setAttribute("kAsm2", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strKAsm2, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -708,8 +747,8 @@ void VPatternConverter::ConvertPathPointExpressionsToV0_2_0(const QMap<QString,
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
formula = GetParametrString(dom, "angle");
|
formula = GetParametrString(dom, strAngle);
|
||||||
dom.setAttribute("angle", FixMeasurementInFormulaToV0_2_0(formula, names));
|
dom.setAttribute(strAngle, FixMeasurementInFormulaToV0_2_0(formula, names));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -782,11 +821,11 @@ QString VPatternConverter::FixIncrementInFormulaToV0_2_0(const QString &formula,
|
||||||
void VPatternConverter::TagMeasurementsToV0_2_0()
|
void VPatternConverter::TagMeasurementsToV0_2_0()
|
||||||
{
|
{
|
||||||
QDomElement ms = TagMeasurementsV0_1_4();
|
QDomElement ms = TagMeasurementsV0_1_4();
|
||||||
const QString path = GetParametrString(ms, "path");
|
const QString path = GetParametrString(ms, strPath);
|
||||||
|
|
||||||
ms.removeAttribute("unit");
|
ms.removeAttribute(strUnit);
|
||||||
ms.removeAttribute("type");
|
ms.removeAttribute(strType);
|
||||||
ms.removeAttribute("path");
|
ms.removeAttribute(strPath);
|
||||||
|
|
||||||
QDomText newNodeText = createTextNode(QFileInfo(fileName).absoluteDir().relativeFilePath(path));
|
QDomText newNodeText = createTextNode(QFileInfo(fileName).absoluteDir().relativeFilePath(path));
|
||||||
ms.appendChild(newNodeText);
|
ms.appendChild(newNodeText);
|
||||||
|
@ -806,18 +845,16 @@ void VPatternConverter::ConvertMeasurementsToV0_2_1()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::RemoveColorToolCutV0_3_1()
|
void VPatternConverter::RemoveColorToolCutV0_3_1()
|
||||||
{
|
{
|
||||||
const QDomNodeList list = elementsByTagName("point");
|
const QDomNodeList list = elementsByTagName(strPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement element = list.at(i).toElement();
|
QDomElement element = list.at(i).toElement();
|
||||||
if (not element.isNull())
|
if (not element.isNull())
|
||||||
{
|
{
|
||||||
const QString type = element.attribute(QStringLiteral("type"));
|
const QString type = element.attribute(strType);
|
||||||
if (type == QStringLiteral("cutArc") ||
|
if (type == strCutArc || type == strCutSpline || type == strCutSplinePath)
|
||||||
type == QStringLiteral("cutSpline") ||
|
|
||||||
type == QStringLiteral("cutSplinePath"))
|
|
||||||
{
|
{
|
||||||
element.removeAttribute(QStringLiteral("color"));
|
element.removeAttribute(strColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -829,7 +866,7 @@ QString VPatternConverter::MUnitV0_1_4() const
|
||||||
const QDomElement element = TagMeasurementsV0_1_4();
|
const QDomElement element = TagMeasurementsV0_1_4();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return GetParametrString(element, "unit");
|
return GetParametrString(element, strUnit);
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -842,7 +879,7 @@ QString VPatternConverter::MUnitV0_1_4() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VPatternConverter::TagMeasurementsV0_1_4() const
|
QDomElement VPatternConverter::TagMeasurementsV0_1_4() const
|
||||||
{
|
{
|
||||||
const QDomNodeList list = elementsByTagName("measurements");
|
const QDomNodeList list = elementsByTagName(strMeasurements);
|
||||||
const QDomElement element = list.at(0).toElement();
|
const QDomElement element = list.at(0).toElement();
|
||||||
if (not element.isElement())
|
if (not element.isElement())
|
||||||
{
|
{
|
||||||
|
@ -855,7 +892,7 @@ QDomElement VPatternConverter::TagMeasurementsV0_1_4() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VPatternConverter::TagIncrementsV0_1_4() const
|
QDomElement VPatternConverter::TagIncrementsV0_1_4() const
|
||||||
{
|
{
|
||||||
const QDomNodeList list = elementsByTagName("increments");
|
const QDomNodeList list = elementsByTagName(strIncrements);
|
||||||
const QDomElement element = list.at(0).toElement();
|
const QDomElement element = list.at(0).toElement();
|
||||||
if (not element.isElement())
|
if (not element.isElement())
|
||||||
{
|
{
|
||||||
|
@ -869,14 +906,14 @@ QDomElement VPatternConverter::TagIncrementsV0_1_4() const
|
||||||
QStringList VPatternConverter::ListPathPointExpressionsV0_1_4() const
|
QStringList VPatternConverter::ListPathPointExpressionsV0_1_4() const
|
||||||
{
|
{
|
||||||
QStringList expressions;
|
QStringList expressions;
|
||||||
const QDomNodeList list = elementsByTagName("pathPoint");
|
const QDomNodeList list = elementsByTagName(strPathPoint);
|
||||||
for (int i=0; i < list.size(); ++i)
|
for (int i=0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
const QDomElement dom = list.at(i).toElement();
|
const QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expressions.append(GetParametrString(dom, "kAsm1"));
|
expressions.append(GetParametrString(dom, strKAsm1));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -885,7 +922,7 @@ QStringList VPatternConverter::ListPathPointExpressionsV0_1_4() const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expressions.append(GetParametrString(dom, "kAsm2"));
|
expressions.append(GetParametrString(dom, strKAsm2));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -894,7 +931,7 @@ QStringList VPatternConverter::ListPathPointExpressionsV0_1_4() const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
expressions.append(GetParametrString(dom, "angle"));
|
expressions.append(GetParametrString(dom, strAngle));
|
||||||
}
|
}
|
||||||
catch (VExceptionEmptyParameter &e)
|
catch (VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
|
@ -909,7 +946,7 @@ QStringList VPatternConverter::ListPathPointExpressionsV0_1_4() const
|
||||||
void VPatternConverter::FixToolUnionToV0_2_4()
|
void VPatternConverter::FixToolUnionToV0_2_4()
|
||||||
{
|
{
|
||||||
QDomElement root = documentElement();
|
QDomElement root = documentElement();
|
||||||
const QDomNodeList modelings = root.elementsByTagName(QStringLiteral("modeling"));
|
const QDomNodeList modelings = root.elementsByTagName(strModeling);
|
||||||
for (int i=0; i<modelings.size(); ++i)
|
for (int i=0; i<modelings.size(); ++i)
|
||||||
{
|
{
|
||||||
ParseModelingToV0_2_4(modelings.at(i).toElement());
|
ParseModelingToV0_2_4(modelings.at(i).toElement());
|
||||||
|
@ -922,17 +959,16 @@ void VPatternConverter::ParseModelingToV0_2_4(const QDomElement &modeling)
|
||||||
QDomElement node = modeling.firstChild().toElement();
|
QDomElement node = modeling.firstChild().toElement();
|
||||||
while (not node.isNull())
|
while (not node.isNull())
|
||||||
{
|
{
|
||||||
if (node.tagName() == QLatin1String("tools"))
|
if (node.tagName() == strTools)
|
||||||
{
|
{
|
||||||
const quint32 toolId = node.attribute(QStringLiteral("id")).toUInt();
|
const quint32 toolId = node.attribute(strId).toUInt();
|
||||||
QVector<quint32> children;
|
QVector<quint32> children;
|
||||||
QDomElement childNode = node.nextSibling().toElement();
|
QDomElement childNode = node.nextSibling().toElement();
|
||||||
const QString attrIdTool = QStringLiteral("idTool");
|
|
||||||
while (not childNode.isNull())
|
while (not childNode.isNull())
|
||||||
{
|
{
|
||||||
if (childNode.hasAttribute(attrIdTool) && childNode.attribute(attrIdTool).toUInt() == toolId)
|
if (childNode.hasAttribute(strIdTool) && childNode.attribute(strIdTool).toUInt() == toolId)
|
||||||
{
|
{
|
||||||
children.append(childNode.attribute(QStringLiteral("idObject")).toUInt());
|
children.append(childNode.attribute(strIdObject).toUInt());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -961,11 +997,11 @@ void VPatternConverter::SaveChildrenToolUnionToV0_2_4(quint32 id, const QVector<
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement tagChildren = createElement(QString("children"));
|
QDomElement tagChildren = createElement(strChildren);
|
||||||
|
|
||||||
for (int i=0; i<children.size(); ++i)
|
for (int i=0; i<children.size(); ++i)
|
||||||
{
|
{
|
||||||
QDomElement tagChild = createElement(QString("child"));
|
QDomElement tagChild = createElement(strChild);
|
||||||
tagChild.appendChild(createTextNode(QString().setNum(children.at(i))));
|
tagChild.appendChild(createTextNode(QString().setNum(children.at(i))));
|
||||||
tagChildren.appendChild(tagChild);
|
tagChildren.appendChild(tagChild);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user