Fix wrong use of SetAttributeOrRemoveIf(). The remove condition must be

calculated not hardcoded.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-03-27 09:46:33 +02:00
parent 3b1d753360
commit 0f226d6cdf
4 changed files with 11 additions and 8 deletions

View File

@ -4227,7 +4227,7 @@ void VPattern::SetDefCustomHeight(int value)
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
SetAttributeOrRemoveIf(domElement, AttrDefHeight, value, 0);
SetAttributeOrRemoveIf(domElement, AttrDefHeight, value, value == 0);
modified = true;
}
else
@ -4279,7 +4279,7 @@ void VPattern::SetDefCustomSize(int value)
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
SetAttributeOrRemoveIf(domElement, AttrDefSize, value, 0);
SetAttributeOrRemoveIf(domElement, AttrDefSize, value, value == 0);
modified = true;
}
else
@ -4308,7 +4308,7 @@ void VPattern::SetReadOnly(bool rOnly)
if (not pattern.isNull())
{
SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, false);
SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, not rOnly);
modified = true;
}
}

View File

@ -523,8 +523,9 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
}
}
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), false);
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), true);
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), not node.IsExcluded());
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(),
node.IsCheckUniqueness());
switch (type)
{
@ -581,7 +582,8 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle);
}
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), true);
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(),
node.IsShowSecondPassmark());
return nod;
}

View File

@ -276,7 +276,8 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping());
doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance());
doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath());
doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), false);
doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(),
not piece.IsSeamAllowanceBuiltIn());
doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth());
doc->SetAttribute(domElement, AttrUnited, piece.IsUnited());
}

View File

@ -75,7 +75,7 @@ void TogglePieceInLayout::Do(bool state)
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
if (detail.isElement())
{
doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, true);
doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, state);
VPiece det = m_data->DataPieces()->value(m_id);
det.SetInLayout(state);