Fix bug in method SetAttributeOrRemoveIf.
--HG-- branch : develop
This commit is contained in:
parent
9b1cdb1848
commit
ab93e4d448
|
@ -102,7 +102,8 @@ public:
|
||||||
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value, const T &condition) const;
|
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
|
||||||
|
bool removeCondition) const;
|
||||||
|
|
||||||
static quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue);
|
static quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue);
|
||||||
static bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue);
|
static bool GetParametrBool(const QDomElement& domElement, const QString &name, const QString &defValue);
|
||||||
|
@ -216,9 +217,9 @@ inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
|
inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
|
||||||
const T &condition) const
|
bool removeCondition) const
|
||||||
{
|
{
|
||||||
value != condition ? domElement.setAttribute(name, value) : domElement.removeAttribute(name);
|
not removeCondition ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
|
@ -286,16 +286,5 @@ void VToolCubicBezier::SetSplineAttributes(QDomElement &domElement, const VCubic
|
||||||
doc->SetAttribute(domElement, AttrColor, spl.GetColor());
|
doc->SetAttribute(domElement, AttrColor, spl.GetColor());
|
||||||
doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
|
doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
|
||||||
doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale());
|
doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale());
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0);
|
||||||
if (spl.GetDuplicate() > 0)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, AttrDuplicate, spl.GetDuplicate());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (domElement.hasAttribute(AttrDuplicate))
|
|
||||||
{
|
|
||||||
domElement.removeAttribute(AttrDuplicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,19 +269,7 @@ void VToolCubicBezierPath::AddPathPoint(VAbstractPattern *doc, QDomElement &domE
|
||||||
void VToolCubicBezierPath::SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path)
|
void VToolCubicBezierPath::SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path)
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0);
|
||||||
if (path.GetDuplicate() > 0)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, AttrDuplicate, path.GetDuplicate());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (domElement.hasAttribute(AttrDuplicate))
|
|
||||||
{
|
|
||||||
domElement.removeAttribute(AttrDuplicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrColor, path.GetColor());
|
doc->SetAttribute(domElement, AttrColor, path.GetColor());
|
||||||
doc->SetAttribute(domElement, AttrPenStyle, path.GetPenStyle());
|
doc->SetAttribute(domElement, AttrPenStyle, path.GetPenStyle());
|
||||||
doc->SetAttribute(domElement, AttrAScale, path.GetApproximationScale());
|
doc->SetAttribute(domElement, AttrAScale, path.GetApproximationScale());
|
||||||
|
|
|
@ -645,18 +645,7 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp
|
||||||
doc->SetAttribute(domElement, AttrColor, spl.GetColor());
|
doc->SetAttribute(domElement, AttrColor, spl.GetColor());
|
||||||
doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
|
doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle());
|
||||||
doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale());
|
doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale());
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0);
|
||||||
if (spl.GetDuplicate() > 0)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, AttrDuplicate, spl.GetDuplicate());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (domElement.hasAttribute(AttrDuplicate))
|
|
||||||
{
|
|
||||||
domElement.removeAttribute(AttrDuplicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (domElement.hasAttribute(AttrKCurve))
|
if (domElement.hasAttribute(AttrKCurve))
|
||||||
{
|
{
|
||||||
|
|
|
@ -339,18 +339,7 @@ void VToolSplinePath::UpdateControlPoints(const VSpline &spl, QSharedPointer<VSp
|
||||||
void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path)
|
void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSplinePath &path)
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0);
|
||||||
if (path.GetDuplicate() > 0)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domElement, AttrDuplicate, path.GetDuplicate());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (domElement.hasAttribute(AttrDuplicate))
|
|
||||||
{
|
|
||||||
domElement.removeAttribute(AttrDuplicate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (domElement.hasAttribute(AttrKCurve))
|
if (domElement.hasAttribute(AttrKCurve))
|
||||||
{
|
{
|
||||||
|
|
|
@ -358,10 +358,9 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
|
||||||
doc->SetAttribute(domData, AttrHeight, data.GetLabelHeight());
|
doc->SetAttribute(domData, AttrHeight, data.GetLabelHeight());
|
||||||
doc->SetAttribute(domData, AttrFont, data.GetFontSize());
|
doc->SetAttribute(domData, AttrFont, data.GetFontSize());
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
|
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrCenterPin, data.CenterPin(), not (data.CenterPin() > NULL_ID));
|
doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, data.CenterPin(), data.CenterPin() <= NULL_ID);
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrTopLeftPin, data.TopLeftPin(), not (data.TopLeftPin() > NULL_ID));
|
doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, data.TopLeftPin(), data.TopLeftPin() <= NULL_ID);
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrBottomRightPin, data.BottomRightPin(),
|
doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, data.BottomRightPin(), data.BottomRightPin() <= NULL_ID);
|
||||||
not (data.BottomRightPin() > NULL_ID));
|
|
||||||
doc->SetLabelTemplate(domData, data.GetLabelTemplate());
|
doc->SetLabelTemplate(domData, data.GetLabelTemplate());
|
||||||
|
|
||||||
domElement.appendChild(domData);
|
domElement.appendChild(domData);
|
||||||
|
@ -379,33 +378,9 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE
|
||||||
doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight());
|
doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight());
|
||||||
doc->SetAttribute(domData, AttrFont, geom.GetFontSize());
|
doc->SetAttribute(domData, AttrFont, geom.GetFontSize());
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation());
|
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation());
|
||||||
|
doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, geom.CenterPin(), geom.CenterPin() <= NULL_ID);
|
||||||
if (geom.CenterPin() > NULL_ID)
|
doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, geom.TopLeftPin(), geom.TopLeftPin() <= NULL_ID);
|
||||||
{
|
doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, geom.BottomRightPin(), geom.BottomRightPin() <= NULL_ID);
|
||||||
doc->SetAttribute(domData, AttrCenterPin, geom.CenterPin());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
domData.removeAttribute(AttrCenterPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (geom.TopLeftPin() > NULL_ID)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domData, AttrTopLeftPin, geom.TopLeftPin());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
domData.removeAttribute(AttrTopLeftPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (geom.BottomRightPin() > NULL_ID)
|
|
||||||
{
|
|
||||||
doc->SetAttribute(domData, AttrBottomRightPin, geom.BottomRightPin());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
domData.removeAttribute(AttrBottomRightPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
domElement.appendChild(domData);
|
domElement.appendChild(domData);
|
||||||
}
|
}
|
||||||
|
@ -422,9 +397,9 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle
|
||||||
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
|
doc->SetAttribute(domData, AttrLength, glGeom.GetLength());
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation());
|
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation());
|
||||||
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
|
doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType()));
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrCenterPin, glGeom.CenterPin(), not (glGeom.CenterPin() > NULL_ID));
|
doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, glGeom.CenterPin(), glGeom.CenterPin() <= NULL_ID);
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrTopPin, glGeom.TopPin(), not (glGeom.TopPin() > NULL_ID));
|
doc->SetAttributeOrRemoveIf(domData, AttrTopPin, glGeom.TopPin(), glGeom.TopPin() <= NULL_ID);
|
||||||
doc->SetAttributeOrRemoveIf<bool>(domData, AttrBottomPin, glGeom.BottomPin(), not (glGeom.BottomPin() > NULL_ID));
|
doc->SetAttributeOrRemoveIf(domData, AttrBottomPin, glGeom.BottomPin(), glGeom.BottomPin() <= NULL_ID);
|
||||||
|
|
||||||
domElement.appendChild(domData);
|
domElement.appendChild(domData);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user