Refactoring.

Redesign SetAttributeOrRemoveIf. Add use of a lambda function.
This commit is contained in:
Roman Telezhynskyi 2021-05-25 21:31:02 +03:00
parent fc06da908f
commit 66283709d1
47 changed files with 220 additions and 192 deletions

View File

@ -4312,7 +4312,7 @@ void VPattern::SetReadOnly(bool rOnly)
if (not pattern.isNull()) if (not pattern.isNull())
{ {
SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, not rOnly); SetAttributeOrRemoveIf<bool>(pattern, AttrReadOnly, rOnly, [](bool rOnly){return not rOnly;});
modified = true; modified = true;
} }
} }

View File

@ -1950,7 +1950,8 @@ 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);
SetAttributeOrRemoveIf(tagFMeasurement, AttrDescription, m.description, m.description.isEmpty()); SetAttributeOrRemoveIf<QString>(tagFMeasurement, AttrDescription, m.description,
[](const QString &description){return description.isEmpty();});
element.appendChild(tagFMeasurement); element.appendChild(tagFMeasurement);
} }
@ -2027,8 +2028,9 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const
SetAttribute(group, AttrId, id); SetAttribute(group, AttrId, id);
SetAttribute(group, AttrName, name); SetAttribute(group, AttrName, name);
SetAttribute(group, AttrVisible, true); SetAttribute(group, AttrVisible, true);
SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id); SetAttributeOrRemoveIf<vidtype>(group, AttrTool, tool, [](vidtype tool){ return tool == null_id;});
SetAttributeOrRemoveIf(group, AttrTags, preparedTags, preparedTags.isEmpty()); SetAttributeOrRemoveIf<QString>(group, AttrTags, preparedTags,
[](const QString &preparedTags){return preparedTags.isEmpty();});
auto i = groupData.constBegin(); auto i = groupData.constBegin();
while (i != groupData.constEnd()) while (i != groupData.constEnd())
@ -2108,8 +2110,8 @@ void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags)
QDomElement group = elementById(id, TagGroup); QDomElement group = elementById(id, TagGroup);
if (group.isElement()) if (group.isElement())
{ {
const QString rawTags = tags.join(','); SetAttributeOrRemoveIf<QString>(group, AttrTags, tags.join(','),
SetAttributeOrRemoveIf(group, AttrTags, rawTags, rawTags.isEmpty()); [](const QString &rawTags){return rawTags.isEmpty();});
modified = true; modified = true;
emit patternChanged(false); emit patternChanged(false);
} }

View File

@ -103,7 +103,7 @@ public:
template <typename T> template <typename T>
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value, void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
bool removeCondition) const; const std::function<bool(const T&)> &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 int GetParametrInt(const QDomElement& domElement, const QString &name, const QString &defValue); static int GetParametrInt(const QDomElement& domElement, const QString &name, const QString &defValue);
@ -218,9 +218,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,
bool removeCondition) const const std::function<bool(const T&)> &removeCondition) const
{ {
not removeCondition ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name); not removeCondition(value) ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
} }
QT_WARNING_POP QT_WARNING_POP

View File

@ -649,7 +649,7 @@ void VMeasurements::SetFullCircumference(bool fc)
QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions); QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions);
if (not dimenstionsTag.isNull()) if (not dimenstionsTag.isNull())
{ {
SetAttributeOrRemoveIf(dimenstionsTag, AttrFullCircumference, fc, not fc); SetAttributeOrRemoveIf<bool>(dimenstionsTag, AttrFullCircumference, fc, [](bool fc){return not fc;});
} }
else else
{ {
@ -747,7 +747,7 @@ void VMeasurements::SetMSpecialUnits(const QString &name, bool special)
QDomElement node = FindM(name); QDomElement node = FindM(name);
if (not node.isNull()) if (not node.isNull())
{ {
SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, not special); SetAttributeOrRemoveIf<bool>(node, AttrSpecialUnits, special, [](bool special){return not special;});
} }
else else
{ {
@ -819,7 +819,8 @@ void VMeasurements::SetMDimension(const QString &name, IMD type)
QDomElement node = FindM(name); QDomElement node = FindM(name);
if (not node.isNull()) if (not node.isNull())
{ {
SetAttributeOrRemoveIf(node, AttrDimension, VMeasurements::IMDToStr(type), type == IMD::N); SetAttributeOrRemoveIf<QString>(node, AttrDimension, VMeasurements::IMDToStr(type),
[](const QString &type){return type == VMeasurements::IMDToStr(IMD::N);});
} }
else else
{ {
@ -893,10 +894,12 @@ void VMeasurements::SetRestrictions(const QMap<QString, VDimensionRestriction> &
QDomElement restrictionTag = createElement(TagRestriction); QDomElement restrictionTag = createElement(TagRestriction);
SetAttribute(restrictionTag, AttrCoordinates, i.key()); SetAttribute(restrictionTag, AttrCoordinates, i.key());
SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().GetMin(), qFuzzyIsNull(i.value().GetMin())); SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMin, i.value().GetMin(),
SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().GetMax(), qFuzzyIsNull(i.value().GetMax())); [](qreal min){return qFuzzyIsNull(min);});
SetAttributeOrRemoveIf(restrictionTag, AttrExclude, i.value().GetExcludeString(), SetAttributeOrRemoveIf<qreal>(restrictionTag, AttrMax, i.value().GetMax(),
i.value().GetExcludeString().isEmpty()); [](qreal max){return qFuzzyIsNull(max);});
SetAttributeOrRemoveIf<QString>(restrictionTag, AttrExclude, i.value().GetExcludeString(),
[](const QString &exlcuded){return exlcuded.isEmpty();});
restrictionsTag.appendChild(restrictionTag); restrictionsTag.appendChild(restrictionTag);
++i; ++i;

View File

@ -1117,7 +1117,8 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
SetAttribute(step, AttrPenStyle, tool->GetPenStyle()); SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
SetAttribute(step, AttrAScale, tool->GetApproximationScale()); SetAttribute(step, AttrAScale, tool->GetApproximationScale());
SetAttribute(step, AttrDuplicate, tool->GetDuplicate()); SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
SetAttributeOrRemoveIf(step, AttrAlias, tool->GetAliasSuffix(), tool->GetAliasSuffix().isEmpty()); SetAttributeOrRemoveIf<QString>(step, AttrAlias, tool->GetAliasSuffix(),
[](const QString &suffix){return suffix.isEmpty();});
} }
@ -1125,8 +1126,10 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
template<typename T> template<typename T>
void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
{ {
SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), tool->GetAliasSuffix1().isEmpty()); SetAttributeOrRemoveIf<QString>(step, AttrAlias1, tool->GetAliasSuffix1(),
SetAttributeOrRemoveIf(step, AttrAlias2, tool->GetAliasSuffix2(), tool->GetAliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
SetAttributeOrRemoveIf<QString>(step, AttrAlias2, tool->GetAliasSuffix2(),
[](const QString &suffix){return suffix.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1168,7 +1171,7 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
} }
SetAttribute(node, AttrItem, obj->ObjectName()); SetAttribute(node, AttrItem, obj->ObjectName());
SetAttributeOrRemoveIf(node, AttrAlias, item.alias, item.alias.isEmpty()); SetAttributeOrRemoveIf<QString>(node, AttrAlias, item.alias, [](const QString &alias){return alias.isEmpty();});
if (obj->getType() != GOType::Point) if (obj->getType() != GOType::Point)
{ {

View File

@ -130,19 +130,24 @@ void VWatermark::SetWatermark(const VWatermarkData &data)
if (not text.isNull()) if (not text.isNull())
{ {
SetAttribute(text, AttrShow, data.showText); SetAttribute(text, AttrShow, data.showText);
SetAttributeOrRemoveIf(text, AttrText, data.text, data.text.isEmpty()); SetAttributeOrRemoveIf<QString>(text, AttrText, data.text,
SetAttributeOrRemoveIf(text, AttrRotation, data.textRotation, data.textRotation == 0); [](const QString &text){return text.isEmpty();});
const QString fontString = data.font.toString(); SetAttributeOrRemoveIf<int>(text, AttrRotation, data.textRotation,
SetAttributeOrRemoveIf(text, AttrFont, fontString, fontString.isEmpty()); [](int textRotation){return textRotation == 0;});
SetAttributeOrRemoveIf<QString>(text, AttrFont, data.font.toString(),
[](const QString &fontString){return fontString.isEmpty();});
} }
QDomElement image = rootElement.firstChildElement(TagImage); QDomElement image = rootElement.firstChildElement(TagImage);
if (not image.isNull()) if (not image.isNull())
{ {
SetAttribute(image, AttrShow, data.showImage); SetAttribute(image, AttrShow, data.showImage);
SetAttributeOrRemoveIf(image, AttrPath, data.path, data.path.isEmpty()); SetAttributeOrRemoveIf<QString>(image, AttrPath, data.path,
SetAttributeOrRemoveIf(image, AttrRotation, data.imageRotation, data.imageRotation == 0); [](const QString &path){return path.isEmpty();});
SetAttributeOrRemoveIf(image, AttrGrayscale, data.grayscale, data.grayscale == false); SetAttributeOrRemoveIf<int>(image, AttrRotation, data.imageRotation,
[](int imageRotation){return imageRotation == 0;});
SetAttributeOrRemoveIf<bool>(image, AttrGrayscale, data.grayscale,
[](bool grayscale){return not grayscale;});
} }
} }
} }

View File

@ -228,9 +228,8 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId())); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId()));
doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType()))); doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType())));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects(); source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement); SaveSourceDestination(domElement);

View File

@ -215,9 +215,8 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId())); doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects(); source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement); SaveSourceDestination(domElement);

View File

@ -748,9 +748,12 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
{ {
QDomElement item = doc->createElement(TagItem); QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, sItem.id); doc->SetAttribute(item, AttrIdObject, sItem.id);
doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, sItem.alias.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(item, AttrAlias, sItem.alias,
doc->SetAttributeOrRemoveIf(item, AttrPenStyle, sItem.penStyle, sItem.penStyle == TypeLineDefault); [](const QString &alias){return alias.isEmpty();});
doc->SetAttributeOrRemoveIf(item, AttrColor, sItem.color, sItem.color == ColorDefault); doc->SetAttributeOrRemoveIf<QString>(item, AttrPenStyle, sItem.penStyle,
[](const QString &penStyle){return penStyle == TypeLineDefault;});
doc->SetAttributeOrRemoveIf<QString>(item, AttrColor, sItem.color,
[](const QString &color){return color == ColorDefault;});
tagObjects.appendChild(item); tagObjects.appendChild(item);
} }
tag.appendChild(tagObjects); tag.appendChild(tagObjects);
@ -763,11 +766,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr); VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr);
doc->SetAttributeOrRemoveIf(item, AttrMx, VAbstractValApplication::VApp()->fromPixel(dItem.mx), doc->SetAttributeOrRemoveIf<double>(item, AttrMx, VAbstractValApplication::VApp()->fromPixel(dItem.mx),
obj && obj->GetType() != GOType::Point); [obj](double){return obj && obj->GetType() != GOType::Point;});
doc->SetAttributeOrRemoveIf(item, AttrMy, VAbstractValApplication::VApp()->fromPixel(dItem.my), doc->SetAttributeOrRemoveIf<double>(item, AttrMy, VAbstractValApplication::VApp()->fromPixel(dItem.my),
obj && obj->GetType() != GOType::Point); [obj](double){return obj && obj->GetType() != GOType::Point;});
doc->SetAttributeOrRemoveIf<bool>(item, AttrShowLabel, dItem.showLabel, dItem.showLabel); doc->SetAttributeOrRemoveIf<bool>(item, AttrShowLabel, dItem.showLabel, [](bool showLabel){return showLabel;});
tagObjects.appendChild(item); tagObjects.appendChild(item);
} }

View File

@ -488,9 +488,8 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId())); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle()); doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects(); source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement); SaveSourceDestination(domElement);

View File

@ -364,9 +364,8 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId())); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId()));
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects(); source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement); SaveSourceDestination(domElement);

View File

@ -322,7 +322,8 @@ void VAbstractSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
doc->SetAttribute(tag, AttrColor, curve->GetColor()); doc->SetAttribute(tag, AttrColor, curve->GetColor());
doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle()); doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle());
doc->SetAttribute(tag, AttrAScale, curve->GetApproximationScale()); doc->SetAttribute(tag, AttrAScale, curve->GetApproximationScale());
doc->SetAttributeOrRemoveIf(tag, AttrAlias, curve->GetAliasSuffix(), curve->GetAliasSuffix().isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrAlias, curve->GetAliasSuffix(),
[](const QString &suffix){return suffix.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -341,11 +341,10 @@ void VToolArc::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenci
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale()); doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
dialogTool->GetAliasSuffix().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -320,11 +320,10 @@ void VToolArcWithLength::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale()); doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
dialogTool->GetAliasSuffix().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -232,9 +232,8 @@ void VToolCubicBezier::SaveDialog(QDomElement &domElement, QList<quint32> &oldDe
AddDependence(newDependencies, spl.GetP2().id()); AddDependence(newDependencies, spl.GetP2().id());
AddDependence(newDependencies, spl.GetP3().id()); AddDependence(newDependencies, spl.GetP3().id());
AddDependence(newDependencies, spl.GetP4().id()); AddDependence(newDependencies, spl.GetP4().id());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
SetSplineAttributes(domElement, spl); SetSplineAttributes(domElement, spl);
} }
@ -291,6 +290,8 @@ 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); doc->SetAttributeOrRemoveIf<quint32>(domElement, AttrDuplicate, spl.GetDuplicate(),
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), spl.GetAliasSuffix().isEmpty()); [](quint32 duplicate){return duplicate == 0;});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, spl.GetAliasSuffix(),
[](const QString &suffix){return suffix.isEmpty();});
} }

View File

@ -219,8 +219,8 @@ void VToolCubicBezierPath::SaveDialog(QDomElement &domElement, QList<quint32> &o
AddDependence(newDependencies, splPath.at(i).id()); AddDependence(newDependencies, splPath.at(i).id());
} }
const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); [](const QString &notes){return notes.isEmpty();});
SetSplinePathAttributes(domElement, splPath); SetSplinePathAttributes(domElement, splPath);
} }
@ -274,7 +274,8 @@ 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); doc->SetAttributeOrRemoveIf<quint32>(domElement, AttrDuplicate, path.GetDuplicate(),
[](quint32 duplicate){return duplicate <= 0;});
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());

View File

@ -388,11 +388,10 @@ void VToolEllipticalArc::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle()); doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
dialogTool->GetAliasSuffix().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -345,8 +345,8 @@ void VToolSpline::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
controlPoints[0]->blockSignals(false); controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false); controlPoints[1]->blockSignals(false);
const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); [](const QString &notes){return notes.isEmpty();});
SetSplineAttributes(domElement, spl); SetSplineAttributes(domElement, spl);
} }
@ -655,8 +655,10 @@ 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); doc->SetAttributeOrRemoveIf<quint32>(domElement, AttrDuplicate, spl.GetDuplicate(),
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), spl.GetAliasSuffix().isEmpty()); [](quint32 duplicate){return duplicate == 0;});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, spl.GetAliasSuffix(),
[](const QString &suffix){return suffix.isEmpty();});
if (domElement.hasAttribute(AttrKCurve)) if (domElement.hasAttribute(AttrKCurve))
{ {

View File

@ -397,7 +397,8 @@ 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); doc->SetAttributeOrRemoveIf<quint32>(domElement, AttrDuplicate, path.GetDuplicate(),
[](quint32 duplicate){return duplicate == 0;});
if (domElement.hasAttribute(AttrKCurve)) if (domElement.hasAttribute(AttrKCurve))
{ {
@ -407,7 +408,8 @@ void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSp
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());
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, path.GetAliasSuffix(), path.GetAliasSuffix().isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias, path.GetAliasSuffix(),
[](const QString &suffix){return suffix.isEmpty();});
UpdatePathPoints(doc, domElement, path); UpdatePathPoints(doc, domElement, path);
} }
@ -544,8 +546,8 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement, QList<quint32> &oldDep
controlPoints[j-1]->blockSignals(false); controlPoints[j-1]->blockSignals(false);
} }
const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); [](const QString &notes){return notes.isEmpty();});
SetSplinePathAttributes(domElement, splPath); SetSplinePathAttributes(domElement, splPath);
} }

View File

@ -290,9 +290,8 @@ void VToolTrueDarts::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
doc->SetAttribute(domElement, AttrDartP1, QString().setNum(dialogTool->GetFirstDartPointId())); doc->SetAttribute(domElement, AttrDartP1, QString().setNum(dialogTool->GetFirstDartPointId()));
doc->SetAttribute(domElement, AttrDartP2, QString().setNum(dialogTool->GetSecondDartPointId())); doc->SetAttribute(domElement, AttrDartP2, QString().setNum(dialogTool->GetSecondDartPointId()));
doc->SetAttribute(domElement, AttrDartP3, QString().setNum(dialogTool->GetThirdDartPointId())); doc->SetAttribute(domElement, AttrDartP3, QString().setNum(dialogTool->GetThirdDartPointId()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -191,8 +191,10 @@ void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{ {
VToolSinglePoint::SaveOptions(tag, obj); VToolSinglePoint::SaveOptions(tag, obj);
doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrAlias1, m_aliasSuffix1,
doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(tag, AttrAlias2, m_aliasSuffix2,
[](const QString &suffix){return suffix.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -233,13 +233,14 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId()));
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
dialogTool->GetAliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
dialogTool->GetAliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -230,13 +230,12 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId()));
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
dialogTool->GetAliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
dialogTool->GetAliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -326,13 +326,14 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
dialogTool->GetAliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
dialogTool->GetAliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -107,7 +107,8 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->GetSecondPointId()); doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->GetSecondPointId());
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -264,9 +264,8 @@ void VToolBisector::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId()));
doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->GetThirdPointId())); doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->GetThirdPointId()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -277,13 +277,12 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList<quint32>
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId()));
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
dialogTool->GetAliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
dialogTool->GetAliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -295,8 +294,10 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObj
doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrCurve, curveId); doc->SetAttribute(tag, AttrCurve, curveId);
doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrAlias1, m_aliasSuffix1,
doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(tag, AttrAlias2, m_aliasSuffix2,
[](const QString &suffix){return suffix.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -193,9 +193,8 @@ void VToolEndLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepend
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -225,7 +225,8 @@ void VToolHeight::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2LineId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2LineId()));
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -281,9 +281,8 @@ void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement, QList<quint32>
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstPointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondPointId()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -234,9 +234,8 @@ void VToolNormal::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->GetAngle())); doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->GetAngle()));
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -284,7 +284,8 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->GetP3())); doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->GetP3()));
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -274,9 +274,8 @@ void VToolBasePoint::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
doc->SetAttribute(domElement, AttrName, name); doc->SetAttribute(domElement, AttrName, name);
doc->SetAttribute(domElement, AttrX, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.x()))); doc->SetAttribute(domElement, AttrX, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.x())));
doc->SetAttribute(domElement, AttrY, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.y()))); doc->SetAttribute(domElement, AttrY, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.y())));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -261,9 +261,8 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement, QList<quint32> &old
doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1())); doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1()));
doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2())); doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2()));
doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2())); doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -301,8 +301,8 @@ void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement, QList<quin
doc->SetAttribute(domElement, AttrCrossPoint, doc->SetAttribute(domElement, AttrCrossPoint,
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint()))); QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); [](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -293,9 +293,8 @@ void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement, QList<q
doc->SetAttribute(domElement, AttrCRadius, dialogTool->GetCircleRadius()); doc->SetAttribute(domElement, AttrCRadius, dialogTool->GetCircleRadius());
doc->SetAttribute(domElement, AttrCrossPoint, doc->SetAttribute(domElement, AttrCrossPoint,
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint()))); QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -316,9 +316,8 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter()));
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint()));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -209,7 +209,8 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement, QList<quint32
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId()));
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -321,9 +321,8 @@ void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement, QList<qui
doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId())); doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId()));
doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId())); doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId()));
doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetCrossArcPoint()))); doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetCrossArcPoint())));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -333,9 +333,8 @@ void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement, QList<
doc->SetAttribute(domElement, AttrC2Radius, dialogTool->GetSecondCircleRadius()); doc->SetAttribute(domElement, AttrC2Radius, dialogTool->GetSecondCircleRadius());
doc->SetAttribute(domElement, AttrCrossPoint, doc->SetAttribute(domElement, AttrCrossPoint,
QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint()))); QString().setNum(static_cast<int>(dialogTool->GetCrossCirclesPoint())));
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -412,17 +412,16 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QList<q
doc->SetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId())); doc->SetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId()));
doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetVCrossPoint()))); doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetVCrossPoint())));
doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetHCrossPoint()))); doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast<int>(dialogTool->GetHCrossPoint())));
doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(),
dialogTool->GetCurve1AliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(),
dialogTool->GetCurve1AliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(),
dialogTool->GetCurve2AliasSuffix1().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(), doc->SetAttributeOrRemoveIf<QString>(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(),
dialogTool->GetCurve2AliasSuffix2().isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -435,10 +434,14 @@ void VToolPointOfIntersectionCurves::SaveOptions(QDomElement &tag, QSharedPointe
doc->SetAttribute(tag, AttrCurve2, secondCurveId); doc->SetAttribute(tag, AttrCurve2, secondCurveId);
doc->SetAttribute(tag, AttrVCrossPoint, static_cast<int>(vCrossPoint)); doc->SetAttribute(tag, AttrVCrossPoint, static_cast<int>(vCrossPoint));
doc->SetAttribute(tag, AttrHCrossPoint, static_cast<int>(hCrossPoint)); doc->SetAttribute(tag, AttrHCrossPoint, static_cast<int>(hCrossPoint));
doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias1, m_curve1AliasSuffix1, m_curve1AliasSuffix1.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrCurve1Alias1, m_curve1AliasSuffix1,
doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias2, m_curve1AliasSuffix2, m_curve1AliasSuffix2.isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias1, m_curve2AliasSuffix1, m_curve2AliasSuffix1.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrCurve1Alias2, m_curve1AliasSuffix2,
doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias2, m_curve2AliasSuffix2, m_curve2AliasSuffix2.isEmpty()); [](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(tag, AttrCurve2Alias1, m_curve2AliasSuffix1,
[](const QString &suffix){return suffix.isEmpty();});
doc->SetAttributeOrRemoveIf<QString>(tag, AttrCurve2Alias2, m_curve2AliasSuffix2,
[](const QString &suffix){return suffix.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -306,7 +306,8 @@ void VToolTriangle::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepen
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId()));
const QString notes = dialogTool->GetNotes(); const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, notes,
[](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -176,7 +176,7 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
Q_UNUSED(obj) Q_UNUSED(obj)
doc->SetAttribute(tag, VDomDocument::AttrId, m_id); doc->SetAttribute(tag, VDomDocument::AttrId, m_id);
doc->SetAttributeOrRemoveIf(tag, AttrNotes, m_notes, m_notes.isEmpty()); doc->SetAttributeOrRemoveIf<QString>(tag, AttrNotes, m_notes, [](const QString &notes){return notes.isEmpty();});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -393,9 +393,8 @@ void VToolLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint()));
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
const QString notes = dialogTool->GetNotes(); [](const QString &notes){return notes.isEmpty();});
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -541,9 +541,10 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
} }
} }
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), not node.IsExcluded()); doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(),
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), [](bool exclude){return not exclude;});
node.IsCheckUniqueness()); doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(),
[](bool uniqueness){return uniqueness;});
switch (type) switch (type)
{ {
@ -600,13 +601,13 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle); nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle);
} }
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(),
node.IsShowSecondPassmark()); [](bool show){return show;});
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(), doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(),
not node.IsManualPassmarkLength()); [](bool manualPassmarkLength){return not manualPassmarkLength;});
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(), doc->SetAttributeOrRemoveIf<QString>(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(),
not node.IsManualPassmarkLength()); [node](const QString &){return not node.IsManualPassmarkLength();});
return nod; return nod;
} }

View File

@ -335,17 +335,19 @@ 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, VAbstractValApplication::VApp()->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMx, VAbstractValApplication::VApp()->fromPixel(piece.GetMx()));
doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(piece.GetMy())); doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(piece.GetMy()));
doc->SetAttributeOrRemoveIf(domElement, AttrInLayout, piece.IsInLayout(), piece.IsInLayout()); doc->SetAttributeOrRemoveIf<bool>(domElement, AttrInLayout, piece.IsInLayout(),
[](bool inLayout){return inLayout;});
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->SetAttributeOrRemoveIf(domElement, AttrSeamAllowance, piece.IsSeamAllowance(), doc->SetAttributeOrRemoveIf<bool>(domElement, AttrSeamAllowance, piece.IsSeamAllowance(),
not piece.IsSeamAllowance()); [](bool seamAllowance){return not seamAllowance;});
doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath()); doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath());
doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), doc->SetAttributeOrRemoveIf<bool>(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(),
not piece.IsSeamAllowanceBuiltIn()); [](bool builtin){return not builtin;});
doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth()); doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth());
doc->SetAttributeOrRemoveIf(domElement, AttrUnited, piece.IsUnited(), not piece.IsUnited()); doc->SetAttributeOrRemoveIf<bool>(domElement, AttrUnited, piece.IsUnited(), [](bool united){return not united;});
doc->SetAttributeOrRemoveIf(domElement, AttrPiecePriority, piece.GetPriority(), piece.GetPriority() == 0); doc->SetAttributeOrRemoveIf<uint>(domElement, AttrPiecePriority, piece.GetPriority(),
[](uint priority){return priority == 0;});
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -426,9 +428,12 @@ 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(domData, AttrCenterPin, data.CenterPin(), data.CenterPin() <= NULL_ID); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrCenterPin, data.CenterPin(),
doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, data.TopLeftPin(), data.TopLeftPin() <= NULL_ID); [](quint32 pin){return pin == NULL_ID;});
doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, data.BottomRightPin(), data.BottomRightPin() <= NULL_ID); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrTopLeftPin, data.TopLeftPin(),
[](quint32 leftPin){return leftPin == NULL_ID;});
doc->SetAttributeOrRemoveIf<quint32>(domData, AttrBottomRightPin, data.BottomRightPin(),
[](quint32 rightPin){return rightPin == NULL_ID;});
doc->SetLabelTemplate(domData, data.GetLabelTemplate()); doc->SetLabelTemplate(domData, data.GetLabelTemplate());
domElement.appendChild(domData); domElement.appendChild(domData);
@ -446,9 +451,12 @@ 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); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrCenterPin, geom.CenterPin(),
doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, geom.TopLeftPin(), geom.TopLeftPin() <= NULL_ID); [](quint32 pin){return pin <= NULL_ID;});
doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, geom.BottomRightPin(), geom.BottomRightPin() <= NULL_ID); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrTopLeftPin, geom.TopLeftPin(),
[](quint32 pin){return pin <= NULL_ID;});
doc->SetAttributeOrRemoveIf<quint32>(domData, AttrBottomRightPin, geom.BottomRightPin(),
[](quint32 pin){return pin <= NULL_ID;});
domElement.appendChild(domData); domElement.appendChild(domData);
} }
@ -465,9 +473,12 @@ 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(domData, AttrCenterPin, glGeom.CenterPin(), glGeom.CenterPin() <= NULL_ID); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrCenterPin, glGeom.CenterPin(),
doc->SetAttributeOrRemoveIf(domData, AttrTopPin, glGeom.TopPin(), glGeom.TopPin() <= NULL_ID); [](quint32 pin){return pin <= NULL_ID;});
doc->SetAttributeOrRemoveIf(domData, AttrBottomPin, glGeom.BottomPin(), glGeom.BottomPin() <= NULL_ID); doc->SetAttributeOrRemoveIf<quint32>(domData, AttrTopPin, glGeom.TopPin(),
[](quint32 pin){return pin <= NULL_ID;});
doc->SetAttributeOrRemoveIf<quint32>(domData, AttrBottomPin, glGeom.BottomPin(),
[](quint32 pin){return pin <= NULL_ID;});
domElement.appendChild(domData); domElement.appendChild(domData);
} }

View File

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