diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 005d42216..6ef087d8d 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -4312,7 +4312,7 @@ void VPattern::SetReadOnly(bool rOnly) if (not pattern.isNull()) { - SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, not rOnly); + SetAttributeOrRemoveIf(pattern, AttrReadOnly, rOnly, [](bool rOnly){return not rOnly;}); modified = true; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 68688fffb..926c76fba 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1950,7 +1950,8 @@ void VAbstractPattern::SetFMeasurements(QDomElement &element, const QVector(tagFMeasurement, AttrDescription, m.description, + [](const QString &description){return description.isEmpty();}); element.appendChild(tagFMeasurement); } @@ -2027,8 +2028,9 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const SetAttribute(group, AttrId, id); SetAttribute(group, AttrName, name); SetAttribute(group, AttrVisible, true); - SetAttributeOrRemoveIf(group, AttrTool, tool, tool == null_id); - SetAttributeOrRemoveIf(group, AttrTags, preparedTags, preparedTags.isEmpty()); + SetAttributeOrRemoveIf(group, AttrTool, tool, [](vidtype tool){ return tool == null_id;}); + SetAttributeOrRemoveIf(group, AttrTags, preparedTags, + [](const QString &preparedTags){return preparedTags.isEmpty();}); auto i = groupData.constBegin(); while (i != groupData.constEnd()) @@ -2108,8 +2110,8 @@ void VAbstractPattern::SetGroupTags(quint32 id, const QStringList &tags) QDomElement group = elementById(id, TagGroup); if (group.isElement()) { - const QString rawTags = tags.join(','); - SetAttributeOrRemoveIf(group, AttrTags, rawTags, rawTags.isEmpty()); + SetAttributeOrRemoveIf(group, AttrTags, tags.join(','), + [](const QString &rawTags){return rawTags.isEmpty();}); modified = true; emit patternChanged(false); } diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index c3b12d6d0..077a658d5 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -103,7 +103,7 @@ public: template void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value, - bool removeCondition) const; + const std::function &removeCondition) const; static quint32 GetParametrUInt(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(QDomElement &domElement //--------------------------------------------------------------------------------------------------------------------- template inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value, - bool removeCondition) const + const std::function &removeCondition) const { - not removeCondition ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name); + not removeCondition(value) ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name); } QT_WARNING_POP diff --git a/src/libs/vformat/vmeasurements.cpp b/src/libs/vformat/vmeasurements.cpp index 9f5feb51c..904fd9f52 100644 --- a/src/libs/vformat/vmeasurements.cpp +++ b/src/libs/vformat/vmeasurements.cpp @@ -649,7 +649,7 @@ void VMeasurements::SetFullCircumference(bool fc) QDomElement dimenstionsTag = documentElement().firstChildElement(TagDimensions); if (not dimenstionsTag.isNull()) { - SetAttributeOrRemoveIf(dimenstionsTag, AttrFullCircumference, fc, not fc); + SetAttributeOrRemoveIf(dimenstionsTag, AttrFullCircumference, fc, [](bool fc){return not fc;}); } else { @@ -747,7 +747,7 @@ void VMeasurements::SetMSpecialUnits(const QString &name, bool special) QDomElement node = FindM(name); if (not node.isNull()) { - SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, not special); + SetAttributeOrRemoveIf(node, AttrSpecialUnits, special, [](bool special){return not special;}); } else { @@ -819,7 +819,8 @@ void VMeasurements::SetMDimension(const QString &name, IMD type) QDomElement node = FindM(name); if (not node.isNull()) { - SetAttributeOrRemoveIf(node, AttrDimension, VMeasurements::IMDToStr(type), type == IMD::N); + SetAttributeOrRemoveIf(node, AttrDimension, VMeasurements::IMDToStr(type), + [](const QString &type){return type == VMeasurements::IMDToStr(IMD::N);}); } else { @@ -893,10 +894,12 @@ void VMeasurements::SetRestrictions(const QMap & QDomElement restrictionTag = createElement(TagRestriction); SetAttribute(restrictionTag, AttrCoordinates, i.key()); - SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().GetMin(), qFuzzyIsNull(i.value().GetMin())); - SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().GetMax(), qFuzzyIsNull(i.value().GetMax())); - SetAttributeOrRemoveIf(restrictionTag, AttrExclude, i.value().GetExcludeString(), - i.value().GetExcludeString().isEmpty()); + SetAttributeOrRemoveIf(restrictionTag, AttrMin, i.value().GetMin(), + [](qreal min){return qFuzzyIsNull(min);}); + SetAttributeOrRemoveIf(restrictionTag, AttrMax, i.value().GetMax(), + [](qreal max){return qFuzzyIsNull(max);}); + SetAttributeOrRemoveIf(restrictionTag, AttrExclude, i.value().GetExcludeString(), + [](const QString &exlcuded){return exlcuded.isEmpty();}); restrictionsTag.appendChild(restrictionTag); ++i; diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 241f9a99a..beac750d5 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -1117,7 +1117,8 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool) SetAttribute(step, AttrPenStyle, tool->GetPenStyle()); SetAttribute(step, AttrAScale, tool->GetApproximationScale()); SetAttribute(step, AttrDuplicate, tool->GetDuplicate()); - SetAttributeOrRemoveIf(step, AttrAlias, tool->GetAliasSuffix(), tool->GetAliasSuffix().isEmpty()); + SetAttributeOrRemoveIf(step, AttrAlias, tool->GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); } @@ -1125,8 +1126,10 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool) template void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) { - SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), tool->GetAliasSuffix1().isEmpty()); - SetAttributeOrRemoveIf(step, AttrAlias2, tool->GetAliasSuffix2(), tool->GetAliasSuffix2().isEmpty()); + SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + SetAttributeOrRemoveIf(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()); - SetAttributeOrRemoveIf(node, AttrAlias, item.alias, item.alias.isEmpty()); + SetAttributeOrRemoveIf(node, AttrAlias, item.alias, [](const QString &alias){return alias.isEmpty();}); if (obj->getType() != GOType::Point) { diff --git a/src/libs/vformat/vwatermark.cpp b/src/libs/vformat/vwatermark.cpp index 04cb94b55..b07c808d8 100644 --- a/src/libs/vformat/vwatermark.cpp +++ b/src/libs/vformat/vwatermark.cpp @@ -130,19 +130,24 @@ void VWatermark::SetWatermark(const VWatermarkData &data) if (not text.isNull()) { SetAttribute(text, AttrShow, data.showText); - SetAttributeOrRemoveIf(text, AttrText, data.text, data.text.isEmpty()); - SetAttributeOrRemoveIf(text, AttrRotation, data.textRotation, data.textRotation == 0); - const QString fontString = data.font.toString(); - SetAttributeOrRemoveIf(text, AttrFont, fontString, fontString.isEmpty()); + SetAttributeOrRemoveIf(text, AttrText, data.text, + [](const QString &text){return text.isEmpty();}); + SetAttributeOrRemoveIf(text, AttrRotation, data.textRotation, + [](int textRotation){return textRotation == 0;}); + SetAttributeOrRemoveIf(text, AttrFont, data.font.toString(), + [](const QString &fontString){return fontString.isEmpty();}); } QDomElement image = rootElement.firstChildElement(TagImage); if (not image.isNull()) { SetAttribute(image, AttrShow, data.showImage); - SetAttributeOrRemoveIf(image, AttrPath, data.path, data.path.isEmpty()); - SetAttributeOrRemoveIf(image, AttrRotation, data.imageRotation, data.imageRotation == 0); - SetAttributeOrRemoveIf(image, AttrGrayscale, data.grayscale, data.grayscale == false); + SetAttributeOrRemoveIf(image, AttrPath, data.path, + [](const QString &path){return path.isEmpty();}); + SetAttributeOrRemoveIf(image, AttrRotation, data.imageRotation, + [](int imageRotation){return imageRotation == 0;}); + SetAttributeOrRemoveIf(image, AttrGrayscale, data.grayscale, + [](bool grayscale){return not grayscale;}); } } } diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index 6ff388ebf..b10c4bba3 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -228,9 +228,8 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList &ol doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId())); doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast(dialogTool->GetAxisType()))); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); source = dialogTool->GetSourceObjects(); SaveSourceDestination(domElement); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 576f78eca..23d102bff 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -215,9 +215,8 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList &ol doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId())); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); source = dialogTool->GetSourceObjects(); SaveSourceDestination(domElement); diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index c63e6ed6b..41904a500 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -748,9 +748,12 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) { QDomElement item = doc->createElement(TagItem); doc->SetAttribute(item, AttrIdObject, sItem.id); - doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, sItem.alias.isEmpty()); - doc->SetAttributeOrRemoveIf(item, AttrPenStyle, sItem.penStyle, sItem.penStyle == TypeLineDefault); - doc->SetAttributeOrRemoveIf(item, AttrColor, sItem.color, sItem.color == ColorDefault); + doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, + [](const QString &alias){return alias.isEmpty();}); + doc->SetAttributeOrRemoveIf(item, AttrPenStyle, sItem.penStyle, + [](const QString &penStyle){return penStyle == TypeLineDefault;}); + doc->SetAttributeOrRemoveIf(item, AttrColor, sItem.color, + [](const QString &color){return color == ColorDefault;}); tagObjects.appendChild(item); } tag.appendChild(tagObjects); @@ -763,11 +766,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag) VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr); - doc->SetAttributeOrRemoveIf(item, AttrMx, VAbstractValApplication::VApp()->fromPixel(dItem.mx), - obj && obj->GetType() != GOType::Point); - doc->SetAttributeOrRemoveIf(item, AttrMy, VAbstractValApplication::VApp()->fromPixel(dItem.my), - obj && obj->GetType() != GOType::Point); - doc->SetAttributeOrRemoveIf(item, AttrShowLabel, dItem.showLabel, dItem.showLabel); + doc->SetAttributeOrRemoveIf(item, AttrMx, VAbstractValApplication::VApp()->fromPixel(dItem.mx), + [obj](double){return obj && obj->GetType() != GOType::Point;}); + doc->SetAttributeOrRemoveIf(item, AttrMy, VAbstractValApplication::VApp()->fromPixel(dItem.my), + [obj](double){return obj && obj->GetType() != GOType::Point;}); + doc->SetAttributeOrRemoveIf(item, AttrShowLabel, dItem.showLabel, [](bool showLabel){return showLabel;}); tagObjects.appendChild(item); } diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 624d91b57..7872249d0 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -488,9 +488,8 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList &oldDependenc doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId())); doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); source = dialogTool->GetSourceObjects(); SaveSourceDestination(domElement); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index f45aad1cf..37abec95a 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -364,9 +364,8 @@ void VToolRotation::SaveDialog(QDomElement &domElement, QList &oldDepen doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); source = dialogTool->GetSourceObjects(); SaveSourceDestination(domElement); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 7902830d9..760ef26ef 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -322,7 +322,8 @@ void VAbstractSpline::SaveOptions(QDomElement &tag, QSharedPointer &ob doc->SetAttribute(tag, AttrColor, curve->GetColor()); doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle()); doc->SetAttribute(tag, AttrAScale, curve->GetApproximationScale()); - doc->SetAttributeOrRemoveIf(tag, AttrAlias, curve->GetAliasSuffix(), curve->GetAliasSuffix().isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrAlias, curve->GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 0261bbeb7..1670da3f2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -341,11 +341,10 @@ void VToolArc::SaveDialog(QDomElement &domElement, QList &oldDependenci doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), - dialogTool->GetAliasSuffix().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index cb0029d35..c4a7bdf6a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -320,11 +320,10 @@ void VToolArcWithLength::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), - dialogTool->GetAliasSuffix().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index f28e5b3d2..1fa0ae4f9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -232,9 +232,8 @@ void VToolCubicBezier::SaveDialog(QDomElement &domElement, QList &oldDe AddDependence(newDependencies, spl.GetP2().id()); AddDependence(newDependencies, spl.GetP3().id()); AddDependence(newDependencies, spl.GetP4().id()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); SetSplineAttributes(domElement, spl); } @@ -291,6 +290,8 @@ void VToolCubicBezier::SetSplineAttributes(QDomElement &domElement, const VCubic doc->SetAttribute(domElement, AttrColor, spl.GetColor()); doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale()); - doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), spl.GetAliasSuffix().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), + [](quint32 duplicate){return duplicate == 0;}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index 174717407..9444a3aad 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -219,8 +219,8 @@ void VToolCubicBezierPath::SaveDialog(QDomElement &domElement, QList &o AddDependence(newDependencies, splPath.at(i).id()); } - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); SetSplinePathAttributes(domElement, splPath); } @@ -274,7 +274,8 @@ void VToolCubicBezierPath::AddPathPoint(VAbstractPattern *doc, QDomElement &domE void VToolCubicBezierPath::SetSplinePathAttributes(QDomElement &domElement, const VCubicBezierPath &path) { doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0); + doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), + [](quint32 duplicate){return duplicate <= 0;}); doc->SetAttribute(domElement, AttrColor, path.GetColor()); doc->SetAttribute(domElement, AttrPenStyle, path.GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, path.GetApproximationScale()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index a35e91227..df61bd134 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -388,11 +388,10 @@ void VToolEllipticalArc::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle()); doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), - dialogTool->GetAliasSuffix().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 84b646ead..1772042aa 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -345,8 +345,8 @@ void VToolSpline::SaveDialog(QDomElement &domElement, QList &oldDepende controlPoints[0]->blockSignals(false); controlPoints[1]->blockSignals(false); - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); SetSplineAttributes(domElement, spl); } @@ -655,8 +655,10 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp doc->SetAttribute(domElement, AttrColor, spl.GetColor()); doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale()); - doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), spl.GetAliasSuffix().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), + [](quint32 duplicate){return duplicate == 0;}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); if (domElement.hasAttribute(AttrKCurve)) { diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index de573af14..a4adb561d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -397,7 +397,8 @@ void VToolSplinePath::UpdateControlPoints(const VSpline &spl, QSharedPointerSetAttribute(domElement, AttrType, ToolType); - doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), path.GetDuplicate() <= 0); + doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, path.GetDuplicate(), + [](quint32 duplicate){return duplicate == 0;}); if (domElement.hasAttribute(AttrKCurve)) { @@ -407,7 +408,8 @@ void VToolSplinePath::SetSplinePathAttributes(QDomElement &domElement, const VSp doc->SetAttribute(domElement, AttrColor, path.GetColor()); doc->SetAttribute(domElement, AttrPenStyle, path.GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, path.GetApproximationScale()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias, path.GetAliasSuffix(), path.GetAliasSuffix().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, path.GetAliasSuffix(), + [](const QString &suffix){return suffix.isEmpty();}); UpdatePathPoints(doc, domElement, path); } @@ -544,8 +546,8 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement, QList &oldDep controlPoints[j-1]->blockSignals(false); } - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); SetSplinePathAttributes(domElement, splPath); } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index 74fa8a91e..18dec073e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -290,9 +290,8 @@ void VToolTrueDarts::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrDartP1, QString().setNum(dialogTool->GetFirstDartPointId())); doc->SetAttribute(domElement, AttrDartP2, QString().setNum(dialogTool->GetSecondDartPointId())); doc->SetAttribute(domElement, AttrDartP3, QString().setNum(dialogTool->GetThirdDartPointId())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index d95ce21a7..ba96d0dbf 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -191,8 +191,10 @@ void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer &obj) { VToolSinglePoint::SaveOptions(tag, obj); - doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); - doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, + [](const QString &suffix){return suffix.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index e59ee7e37..66b62cf9e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -233,13 +233,14 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList &oldDepende doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - dialogTool->GetAliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - dialogTool->GetAliasSuffix2().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index b290ea1a1..8096b5ad3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -230,13 +230,12 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - dialogTool->GetAliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - dialogTool->GetAliasSuffix2().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 927e1a804..5b1c42afd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -326,13 +326,14 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - dialogTool->GetAliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - dialogTool->GetAliasSuffix2().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index e830f755f..5689f4841 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -107,7 +107,8 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->GetSecondPointId()); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index f5f23dab4..43083c032 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -264,9 +264,8 @@ void VToolBisector::SaveDialog(QDomElement &domElement, QList &oldDepen doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->GetThirdPointId())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index e988feda5..725c77a4d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -277,13 +277,12 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement, QList doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), - dialogTool->GetAliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), - dialogTool->GetAliasSuffix2().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- @@ -295,8 +294,10 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointerSetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrCurve, curveId); - doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty()); - doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, + [](const QString &suffix){return suffix.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index c57824b11..fd32cecbd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -193,9 +193,8 @@ void VToolEndLine::SaveDialog(QDomElement &domElement, QList &oldDepend doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 787878526..8eeded7ee 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -225,7 +225,8 @@ void VToolHeight::SaveDialog(QDomElement &domElement, QList &oldDepende doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2LineId())); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 5134682fc..738f3bd34 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -281,9 +281,8 @@ void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement, QList doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondPointId())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index e223b26d4..55960d625 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -234,9 +234,8 @@ void VToolNormal::SaveDialog(QDomElement &domElement, QList &oldDepende doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->GetAngle())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index dfc03f864..cb272ce5b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -284,7 +284,8 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->GetP3())); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index fa967e5e8..bcb7b5c2a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -274,9 +274,8 @@ void VToolBasePoint::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrName, name); doc->SetAttribute(domElement, AttrX, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.x()))); doc->SetAttribute(domElement, AttrY, QString().setNum(VAbstractValApplication::VApp()->fromPixel(p.y()))); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 0031d57fa..903a6a6bd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -261,9 +261,8 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement, QList &old doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1())); doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2())); doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 36b6d2c23..1c15670be 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -301,8 +301,8 @@ void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast(dialogTool->GetCrossCirclesPoint()))); - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index cfb9a6d71..5bdcac6c5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -293,9 +293,8 @@ void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrCRadius, dialogTool->GetCircleRadius()); doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast(dialogTool->GetCrossCirclesPoint()))); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 8cd5ab9fe..51e2a6540 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -316,9 +316,8 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement, QList &ol doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index c6c1d6c4f..ec56ed44f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -209,7 +209,8 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index a5d58c658..a20b622df 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -321,9 +321,8 @@ void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId())); doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId())); doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast(dialogTool->GetCrossArcPoint()))); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 956229048..aa05af470 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -333,9 +333,8 @@ void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement, QList< doc->SetAttribute(domElement, AttrC2Radius, dialogTool->GetSecondCircleRadius()); doc->SetAttribute(domElement, AttrCrossPoint, QString().setNum(static_cast(dialogTool->GetCrossCirclesPoint()))); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index e859fc58a..83d987c41 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -412,17 +412,16 @@ void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement, QListSetAttribute(domElement, AttrCurve2, QString().setNum(dialogTool->GetSecondCurveId())); doc->SetAttribute(domElement, AttrVCrossPoint, QString().setNum(static_cast(dialogTool->GetVCrossPoint()))); doc->SetAttribute(domElement, AttrHCrossPoint, QString().setNum(static_cast(dialogTool->GetHCrossPoint()))); - doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(), - dialogTool->GetCurve1AliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(), - dialogTool->GetCurve1AliasSuffix2().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(), - dialogTool->GetCurve2AliasSuffix1().isEmpty()); - doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(), - dialogTool->GetCurve2AliasSuffix2().isEmpty()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias1, dialogTool->GetCurve1AliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve1Alias2, dialogTool->GetCurve1AliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias1, dialogTool->GetCurve2AliasSuffix1(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrCurve2Alias2, dialogTool->GetCurve2AliasSuffix2(), + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- @@ -435,10 +434,14 @@ void VToolPointOfIntersectionCurves::SaveOptions(QDomElement &tag, QSharedPointe doc->SetAttribute(tag, AttrCurve2, secondCurveId); doc->SetAttribute(tag, AttrVCrossPoint, static_cast(vCrossPoint)); doc->SetAttribute(tag, AttrHCrossPoint, static_cast(hCrossPoint)); - doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias1, m_curve1AliasSuffix1, m_curve1AliasSuffix1.isEmpty()); - doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias2, m_curve1AliasSuffix2, m_curve1AliasSuffix2.isEmpty()); - doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias1, m_curve2AliasSuffix1, m_curve2AliasSuffix1.isEmpty()); - doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias2, m_curve2AliasSuffix2, m_curve2AliasSuffix2.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias1, m_curve1AliasSuffix1, + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(tag, AttrCurve1Alias2, m_curve1AliasSuffix2, + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias1, m_curve2AliasSuffix1, + [](const QString &suffix){return suffix.isEmpty();}); + doc->SetAttributeOrRemoveIf(tag, AttrCurve2Alias2, m_curve2AliasSuffix2, + [](const QString &suffix){return suffix.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 69d689438..e6b6f08db 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -306,7 +306,8 @@ void VToolTriangle::SaveDialog(QDomElement &domElement, QList &oldDepen doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 1a30a49ea..45e3ab8e6 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -176,7 +176,7 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_UNUSED(obj) doc->SetAttribute(tag, VDomDocument::AttrId, m_id); - doc->SetAttributeOrRemoveIf(tag, AttrNotes, m_notes, m_notes.isEmpty()); + doc->SetAttributeOrRemoveIf(tag, AttrNotes, m_notes, [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index c5356fb07..0be50d268 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -393,9 +393,8 @@ void VToolLine::SaveDialog(QDomElement &domElement, QList &oldDependenc doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); - - const QString notes = dialogTool->GetNotes(); - doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrNotes, dialogTool->GetNotes(), + [](const QString ¬es){return notes.isEmpty();}); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp index 863609606..f32b38d25 100644 --- a/src/libs/vtools/tools/vabstracttool.cpp +++ b/src/libs/vtools/tools/vabstracttool.cpp @@ -541,9 +541,10 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa } } - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), not node.IsExcluded()); - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), - node.IsCheckUniqueness()); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeExcluded, node.IsExcluded(), + [](bool exclude){return not exclude;}); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrCheckUniqueness, node.IsCheckUniqueness(), + [](bool uniqueness){return uniqueness;}); switch (type) { @@ -600,13 +601,13 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle); } - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), - node.IsShowSecondPassmark()); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), + [](bool show){return show;}); - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(), - not node.IsManualPassmarkLength()); - doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(), - not node.IsManualPassmarkLength()); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(), + [](bool manualPassmarkLength){return not manualPassmarkLength;}); + doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(), + [node](const QString &){return not node.IsManualPassmarkLength();}); return nod; } diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 6815a0c8f..953dcb8c9 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -335,17 +335,19 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); doc->SetAttribute(domElement, AttrMx, VAbstractValApplication::VApp()->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(piece.GetMy())); - doc->SetAttributeOrRemoveIf(domElement, AttrInLayout, piece.IsInLayout(), piece.IsInLayout()); + doc->SetAttributeOrRemoveIf(domElement, AttrInLayout, piece.IsInLayout(), + [](bool inLayout){return inLayout;}); doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping()); doc->SetAttribute(domElement, AttrForceFlipping, piece.IsForceFlipping()); - doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowance, piece.IsSeamAllowance(), - not piece.IsSeamAllowance()); + doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowance, piece.IsSeamAllowance(), + [](bool seamAllowance){return not seamAllowance;}); doc->SetAttribute(domElement, AttrHideMainPath, piece.IsHideMainPath()); - doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), - not piece.IsSeamAllowanceBuiltIn()); + doc->SetAttributeOrRemoveIf(domElement, AttrSeamAllowanceBuiltIn, piece.IsSeamAllowanceBuiltIn(), + [](bool builtin){return not builtin;}); doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth()); - doc->SetAttributeOrRemoveIf(domElement, AttrUnited, piece.IsUnited(), not piece.IsUnited()); - doc->SetAttributeOrRemoveIf(domElement, AttrPiecePriority, piece.GetPriority(), piece.GetPriority() == 0); + doc->SetAttributeOrRemoveIf(domElement, AttrUnited, piece.IsUnited(), [](bool united){return not united;}); + doc->SetAttributeOrRemoveIf(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, AttrFont, data.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation()); - doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, data.CenterPin(), data.CenterPin() <= NULL_ID); - doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, data.TopLeftPin(), data.TopLeftPin() <= NULL_ID); - doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, data.BottomRightPin(), data.BottomRightPin() <= NULL_ID); + doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, data.CenterPin(), + [](quint32 pin){return pin == NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, data.TopLeftPin(), + [](quint32 leftPin){return leftPin == NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, data.BottomRightPin(), + [](quint32 rightPin){return rightPin == NULL_ID;}); doc->SetLabelTemplate(domData, data.GetLabelTemplate()); domElement.appendChild(domData); @@ -446,9 +451,12 @@ void VToolSeamAllowance::AddPatternInfo(VAbstractPattern *doc, QDomElement &domE doc->SetAttribute(domData, AttrHeight, geom.GetLabelHeight()); doc->SetAttribute(domData, AttrFont, geom.GetFontSize()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, geom.GetRotation()); - doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, geom.CenterPin(), 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->SetAttributeOrRemoveIf(domData, AttrCenterPin, geom.CenterPin(), + [](quint32 pin){return pin <= NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrTopLeftPin, geom.TopLeftPin(), + [](quint32 pin){return pin <= NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrBottomRightPin, geom.BottomRightPin(), + [](quint32 pin){return pin <= NULL_ID;}); domElement.appendChild(domData); } @@ -465,9 +473,12 @@ void VToolSeamAllowance::AddGrainline(VAbstractPattern *doc, QDomElement &domEle doc->SetAttribute(domData, AttrLength, glGeom.GetLength()); doc->SetAttribute(domData, VAbstractPattern::AttrRotation, glGeom.GetRotation()); doc->SetAttribute(domData, VAbstractPattern::AttrArrows, int(glGeom.GetArrowType())); - doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, glGeom.CenterPin(), glGeom.CenterPin() <= NULL_ID); - doc->SetAttributeOrRemoveIf(domData, AttrTopPin, glGeom.TopPin(), glGeom.TopPin() <= NULL_ID); - doc->SetAttributeOrRemoveIf(domData, AttrBottomPin, glGeom.BottomPin(), glGeom.BottomPin() <= NULL_ID); + doc->SetAttributeOrRemoveIf(domData, AttrCenterPin, glGeom.CenterPin(), + [](quint32 pin){return pin <= NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrTopPin, glGeom.TopPin(), + [](quint32 pin){return pin <= NULL_ID;}); + doc->SetAttributeOrRemoveIf(domData, AttrBottomPin, glGeom.BottomPin(), + [](quint32 pin){return pin <= NULL_ID;}); domElement.appendChild(domData); } diff --git a/src/libs/vtools/undocommands/togglepiecestate.cpp b/src/libs/vtools/undocommands/togglepiecestate.cpp index 7b8d71458..dac2ebfb9 100644 --- a/src/libs/vtools/undocommands/togglepiecestate.cpp +++ b/src/libs/vtools/undocommands/togglepiecestate.cpp @@ -74,7 +74,7 @@ void TogglePieceInLayout::Do(bool state) QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail); if (detail.isElement()) { - doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, state); + doc->SetAttributeOrRemoveIf(detail, AttrInLayout, state, [](bool state){return state;}); VPiece det = m_data->DataPieces()->value(m_id); det.SetInLayout(state);