Optimize size, rely more on default values for attributes.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-04-18 15:28:07 +03:00
parent 72eeae24e6
commit 35a0fd74e1
3 changed files with 18 additions and 5 deletions

View File

@ -3983,9 +3983,21 @@ void VPattern::SetIncrementFormula(const QString &name, const QString &text)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::SetIncrementDescription(const QString &name, const QString &text) void VPattern::SetIncrementDescription(const QString &name, const QString &text)
{
if (not text.isEmpty())
{ {
SetIncrementAttribute(name, AttrDescription, text); SetIncrementAttribute(name, AttrDescription, text);
} }
else
{
QDomElement node = FindIncrement(name);
if (not node.isNull())
{
node.removeAttribute(AttrDescription);
emit patternChanged(false);
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName) void VPattern::ReplaceNameInFormula(QVector<VFormulaField> &expressions, const QString &name, const QString &newName)

View File

@ -2285,7 +2285,7 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector<VFin
SetAttribute(tagFMeasurement, AttrName, m.name); SetAttribute(tagFMeasurement, AttrName, m.name);
SetAttribute(tagFMeasurement, AttrFormula, m.formula); SetAttribute(tagFMeasurement, AttrFormula, m.formula);
SetAttribute(tagFMeasurement, AttrDescription, m.description); SetAttributeOrRemoveIf(tagFMeasurement, AttrDescription, m.description, m.description.isEmpty());
element.appendChild(tagFMeasurement); element.appendChild(tagFMeasurement);
} }

View File

@ -271,15 +271,16 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy()));
doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout()); doc->SetAttributeOrRemoveIf(domElement, AttrInLayout, piece.IsInLayout(), piece.IsInLayout());
doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping()); doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping());
doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping()); doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping());
doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance()); doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowance, piece.IsSeamAllowance(),
not piece.IsSeamAllowance());
doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath()); doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath());
doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(),
not piece.IsSeamAllowanceBuiltIn()); not piece.IsSeamAllowanceBuiltIn());
doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth()); doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth());
doc->SetAttribute(domElement, AttrUnited, piece.IsUnited()); doc->SetAttributeOrRemoveIf(domElement, AttrUnited, piece.IsUnited(), not piece.IsUnited());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------