From acc340bff10f3f437cd56e07cb414ff73af5c38a Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 2 Aug 2017 14:10:10 +0300 Subject: [PATCH] Performance improvement. Speed up method VDomDocument::elementById. --HG-- branch : develop --- src/libs/ifc/xml/vabstractpattern.cpp | 8 ++--- src/libs/ifc/xml/vdomdocument.cpp | 30 +++++++++++++++---- src/libs/ifc/xml/vdomdocument.h | 4 +-- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 6 ++-- .../tools/nodeDetails/vabstractnode.cpp | 4 +-- .../vtools/tools/nodeDetails/vnodepoint.cpp | 2 +- .../tools/nodeDetails/vtoolpiecepath.cpp | 4 +-- src/libs/vtools/tools/vtoolseamallowance.cpp | 2 +- src/libs/vtools/tools/vtooluniondetails.cpp | 22 +++++++------- src/libs/vtools/undocommands/addgroup.cpp | 2 +- src/libs/vtools/undocommands/addpiece.cpp | 2 +- src/libs/vtools/undocommands/deletepiece.cpp | 4 +-- src/libs/vtools/undocommands/delgroup.cpp | 2 +- .../undocommands/label/movedoublelabel.cpp | 4 +-- .../vtools/undocommands/label/movelabel.cpp | 4 +-- .../undocommands/label/operationmovelabel.cpp | 2 +- src/libs/vtools/undocommands/movepiece.cpp | 6 ++-- src/libs/vtools/undocommands/movespline.cpp | 2 +- .../vtools/undocommands/movesplinepath.cpp | 2 +- src/libs/vtools/undocommands/movespoint.cpp | 4 +-- .../vtools/undocommands/savepieceoptions.cpp | 4 +-- .../undocommands/savepiecepathoptions.cpp | 4 +-- .../undocommands/togglepieceinlayout.cpp | 2 +- 23 files changed, 73 insertions(+), 53 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 97a9023e3..1b9366d6c 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2207,7 +2207,7 @@ QString VAbstractPattern::GetGroupName(quint32 id) QDomElement groups = CreateGroups(); if (not groups.isNull()) { - QDomElement group = elementById(id); + QDomElement group = elementById(id, TagGroup); if (group.isElement()) { name = GetParametrString(group, AttrName, name); @@ -2238,7 +2238,7 @@ void VAbstractPattern::SetGroupName(quint32 id, const QString &name) QDomElement groups = CreateGroups(); if (not groups.isNull()) { - QDomElement group = elementById(id); + QDomElement group = elementById(id, TagGroup); if (group.isElement()) { group.setAttribute(AttrName, name); @@ -2311,7 +2311,7 @@ QMap > VAbstractPattern::GetGroups() //--------------------------------------------------------------------------------------------------------------------- bool VAbstractPattern::GetGroupVisivility(quint32 id) { - QDomElement group = elementById(id); + QDomElement group = elementById(id, TagGroup); if (group.isElement()) { return GetParametrBool(group, AttrVisible, trueStr); @@ -2326,7 +2326,7 @@ bool VAbstractPattern::GetGroupVisivility(quint32 id) //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible) { - QDomElement group = elementById(id); + QDomElement group = elementById(id, TagGroup); if (group.isElement()) { SetAttribute(group, AttrVisible, visible); diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 9d87154e6..a13dada7d 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -194,7 +194,7 @@ VDomDocument::VDomDocument() * @param id value id attribute. * @return dom element. */ -QDomElement VDomDocument::elementById(const QString& id) +QDomElement VDomDocument::elementById(const QString& id, const QString &tagName) { if (map.contains(id)) { @@ -206,18 +206,38 @@ QDomElement VDomDocument::elementById(const QString& id) map.remove(id); } - if (this->find(this->documentElement(), id)) + if (tagName.isEmpty()) { - return map[id]; + if (this->find(this->documentElement(), id)) + { + return map[id]; + } + } + else + { + const QDomNodeList list = elementsByTagName(tagName); + for (int i=0; i < list.size(); ++i) + { + const QDomElement domElement = list.at(i).toElement(); + if (not domElement.isNull() && domElement.hasAttribute(AttrId)) + { + const QString value = domElement.attribute(AttrId); + this->map[value] = domElement; + if (value == id) + { + return domElement; + } + } + } } return QDomElement(); } //--------------------------------------------------------------------------------------------------------------------- -QDomElement VDomDocument::elementById(quint32 id) +QDomElement VDomDocument::elementById(quint32 id, const QString &tagName) { - return elementById(QString().setNum(id)); + return elementById(QString().setNum(id), tagName); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vdomdocument.h b/src/libs/ifc/xml/vdomdocument.h index 6685fdd51..7fd73547a 100644 --- a/src/libs/ifc/xml/vdomdocument.h +++ b/src/libs/ifc/xml/vdomdocument.h @@ -88,8 +88,8 @@ public: VDomDocument(); virtual ~VDomDocument() Q_DECL_EQ_DEFAULT; - QDomElement elementById(const QString& id); - QDomElement elementById(quint32 id); + QDomElement elementById(const QString& id, const QString &tagName = QString()); + QDomElement elementById(quint32 id, const QString &tagName = QString()); template void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 6e0125aa8..41f6092b4 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -106,7 +106,7 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) void VDrawTool::SaveDialogChange() { qCDebug(vTool, "Saving tool options after using dialog"); - QDomElement oldDomElement = doc->elementById(id); + QDomElement oldDomElement = doc->elementById(id, getTagName()); if (oldDomElement.isElement()) { QDomElement newDomElement = oldDomElement.cloneNode().toElement(); @@ -138,7 +138,7 @@ void VDrawTool::AddToFile() void VDrawTool::SaveOption(QSharedPointer &obj) { qCDebug(vTool, "Saving tool options"); - QDomElement oldDomElement = doc->elementById(id); + QDomElement oldDomElement = doc->elementById(id, getTagName()); if (oldDomElement.isElement()) { QDomElement newDomElement = oldDomElement.cloneNode().toElement(); @@ -179,7 +179,7 @@ bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const //--------------------------------------------------------------------------------------------------------------------- void VDrawTool::ReadAttributes() { - const QDomElement domElement = doc->elementById(id); + const QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { ReadToolAttributes(domElement); diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp index 93a9f62fc..c710648d6 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp @@ -90,7 +90,7 @@ void VAbstractNode::incrementReferens() doc->IncrementReferens(node->getIdTool()); } ShowNode(); - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse); @@ -117,7 +117,7 @@ void VAbstractNode::decrementReferens() doc->DecrementReferens(node->getIdTool()); } HideNode(); - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse); diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index b5c6172f4..194a84e4b 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -230,7 +230,7 @@ void VNodePoint::NameChangePosition(const QPointF &pos) */ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) { - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx))); diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index 6e088f964..c52351f91 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -146,7 +146,7 @@ void VToolPiecePath::incrementReferens() IncrementNodes(VAbstractTool::data.GetPiecePath(id)); } ShowNode(); - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse); @@ -169,7 +169,7 @@ void VToolPiecePath::decrementReferens() DecrementNodes(VAbstractTool::data.GetPiecePath(id)); } HideNode(); - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 0b36ce074..f98bf0c92 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -857,7 +857,7 @@ void VToolSeamAllowance::AddToFile() //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::RefreshDataInFile() { - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { // Refresh only parts that we possibly need to update diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index 7e6d516e6..6f0c38f62 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -97,7 +97,7 @@ namespace //--------------------------------------------------------------------------------------------------------------------- VPiecePath GetPiecePath(int piece, VAbstractPattern *doc, quint32 id) { - const QDomElement tool = doc->elementById(id); + const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools); if (tool.isNull()) { VException e(QString("Can't get tool by id='%1'.").arg(id)); @@ -140,7 +140,7 @@ VPiecePath GetPiece2MainPath(VAbstractPattern *doc, quint32 id) //--------------------------------------------------------------------------------------------------------------------- QVector GetPiece2CSAPaths(VAbstractPattern *doc, quint32 id) { - const QDomElement tool = doc->elementById(id); + const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools); if (tool.isNull()) { VException e(QString("Can't get tool by id='%1'.").arg(id)); @@ -171,7 +171,7 @@ QVector GetPiece2CSAPaths(VAbstractPattern *doc, quint32 id) //--------------------------------------------------------------------------------------------------------------------- QVector GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id) { - const QDomElement tool = doc->elementById(id); + const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools); if (tool.isNull()) { VException e(QString("Can't get tool by id='%1'.").arg(id)); @@ -202,7 +202,7 @@ QVector GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id) //--------------------------------------------------------------------------------------------------------------------- QVector GetPiece2Pins(VAbstractPattern *doc, quint32 id) { - const QDomElement tool = doc->elementById(id); + const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools); if (tool.isNull()) { VException e(QString("Can't get tool by id='%1'.").arg(id)); @@ -233,13 +233,13 @@ QVector GetPiece2Pins(VAbstractPattern *doc, quint32 id) //--------------------------------------------------------------------------------------------------------------------- QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id) { - const QDomElement detail1 = doc->elementById(d1id); + const QDomElement detail1 = doc->elementById(d1id, VAbstractPattern::TagDetail); if (detail1.isNull()) { return QString(); } - const QDomElement detail2 = doc->elementById(d2id); + const QDomElement detail2 = doc->elementById(d2id, VAbstractPattern::TagDetail); if (detail2.isNull()) { return QString(); @@ -656,7 +656,7 @@ void FindIndexJ(qint32 pointsD2, const VPiecePath &d2Path, quint32 indexD2, qint //--------------------------------------------------------------------------------------------------------------------- QDomElement GetTagChildren(VAbstractPattern *doc, quint32 id) { - QDomElement toolUnion = doc->elementById(id); + QDomElement toolUnion = doc->elementById(id, VAbstractPattern::TagTools); if (toolUnion.isNull()) { VException e(QString("Can't get tool by id='%1'.").arg(id)); @@ -717,7 +717,7 @@ void SavePinsChildren(VAbstractPattern *doc, quint32 id, const QVector //--------------------------------------------------------------------------------------------------------------------- QVector GetChildren(VAbstractPattern *doc, quint32 id, const QString &tagName) { - const QDomElement toolUnion = doc->elementById(id); + const QDomElement toolUnion = doc->elementById(id, VAbstractPattern::TagTools); if (toolUnion.isNull()) { return QVector(); @@ -1390,7 +1390,7 @@ void VToolUnionDetails::incrementReferens() doc->IncrementReferens(objects.at(i)); } - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse); @@ -1410,7 +1410,7 @@ void VToolUnionDetails::decrementReferens() doc->DecrementReferens(objects.at(i)); } - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, getTagName()); if (domElement.isElement()) { doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse); @@ -1558,7 +1558,7 @@ void VToolUnionDetails::AddToModeling(const QDomElement &domElement) QVector VToolUnionDetails::GetReferenceObjects() const { QVector list; - const QDomElement tool = doc->elementById(id); + const QDomElement tool = doc->elementById(id, getTagName()); if (tool.isNull()) { return list; diff --git a/src/libs/vtools/undocommands/addgroup.cpp b/src/libs/vtools/undocommands/addgroup.cpp index 2a5645044..5da3c07e3 100644 --- a/src/libs/vtools/undocommands/addgroup.cpp +++ b/src/libs/vtools/undocommands/addgroup.cpp @@ -61,7 +61,7 @@ void AddGroup::undo() QDomElement groups = doc->CreateGroups(); if (not groups.isNull()) { - QDomElement group = doc->elementById(nodeId); + QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup); if (group.isElement()) { group.setAttribute(VAbstractPattern::AttrVisible, trueStr); diff --git a/src/libs/vtools/undocommands/addpiece.cpp b/src/libs/vtools/undocommands/addpiece.cpp index a99b6747f..0867ede9f 100644 --- a/src/libs/vtools/undocommands/addpiece.cpp +++ b/src/libs/vtools/undocommands/addpiece.cpp @@ -53,7 +53,7 @@ void AddPiece::undo() QDomElement details = GetDetailsSection(); if (not details.isNull()) { - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { if (details.removeChild(domElement).isNull()) diff --git a/src/libs/vtools/undocommands/deletepiece.cpp b/src/libs/vtools/undocommands/deletepiece.cpp index 1a58eff5b..0aad0cb3e 100644 --- a/src/libs/vtools/undocommands/deletepiece.cpp +++ b/src/libs/vtools/undocommands/deletepiece.cpp @@ -50,7 +50,7 @@ DeletePiece::DeletePiece(VAbstractPattern *doc, quint32 id, const VPiece &detail { setText(tr("delete tool")); nodeId = id; - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, VAbstractPattern::TagDetail); if (domElement.isElement()) { xml = domElement.cloneNode().toElement(); @@ -91,7 +91,7 @@ void DeletePiece::redo() { qCDebug(vUndo, "Redo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { m_parentNode.removeChild(domElement); diff --git a/src/libs/vtools/undocommands/delgroup.cpp b/src/libs/vtools/undocommands/delgroup.cpp index 7e35e0d94..a769863e6 100644 --- a/src/libs/vtools/undocommands/delgroup.cpp +++ b/src/libs/vtools/undocommands/delgroup.cpp @@ -86,7 +86,7 @@ void DelGroup::redo() QDomElement groups = doc->CreateGroups(); if (not groups.isNull()) { - QDomElement group = doc->elementById(nodeId); + QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup); if (group.isElement()) { group.setAttribute(VAbstractPattern::AttrVisible, trueStr); diff --git a/src/libs/vtools/undocommands/label/movedoublelabel.cpp b/src/libs/vtools/undocommands/label/movedoublelabel.cpp index 55eddc744..88fc9ea13 100644 --- a/src/libs/vtools/undocommands/label/movedoublelabel.cpp +++ b/src/libs/vtools/undocommands/label/movedoublelabel.cpp @@ -54,7 +54,7 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const d setText(tr("move the second dart label")); } - const QDomElement domElement = doc->elementById(m_idTool); + const QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint); if (domElement.isElement()) { if (type == DoublePoint::FirstPoint) @@ -134,7 +134,7 @@ void MoveDoubleLabel::Do(double mx, double my) qCDebug(vUndo, "New my2 %f", my); } - QDomElement domElement = doc->elementById(m_idTool); + QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint); if (domElement.isElement()) { if (m_type == DoublePoint::FirstPoint) diff --git a/src/libs/vtools/undocommands/label/movelabel.cpp b/src/libs/vtools/undocommands/label/movelabel.cpp index 7f37ea7c8..b344498c6 100644 --- a/src/libs/vtools/undocommands/label/movelabel.cpp +++ b/src/libs/vtools/undocommands/label/movelabel.cpp @@ -44,7 +44,7 @@ MoveLabel::MoveLabel(VAbstractPattern *doc, const double &x, const double &y, co { setText(tr("move point label")); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); @@ -95,7 +95,7 @@ void MoveLabel::Do(double mx, double my) qCDebug(vUndo, "New mx %f", mx); qCDebug(vUndo, "New my %f", my); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx))); diff --git a/src/libs/vtools/undocommands/label/operationmovelabel.cpp b/src/libs/vtools/undocommands/label/operationmovelabel.cpp index f93842f05..e3c67734e 100644 --- a/src/libs/vtools/undocommands/label/operationmovelabel.cpp +++ b/src/libs/vtools/undocommands/label/operationmovelabel.cpp @@ -118,7 +118,7 @@ void OperationMoveLabel::Do(double mx, double my) //--------------------------------------------------------------------------------------------------------------------- QDomElement OperationMoveLabel::GetDestinationObject(quint32 idTool, quint32 idPoint) const { - const QDomElement tool = doc->elementById(idTool); + const QDomElement tool = doc->elementById(idTool, VAbstractPattern::TagOperation); if (tool.isElement()) { QDomElement correctDest; diff --git a/src/libs/vtools/undocommands/movepiece.cpp b/src/libs/vtools/undocommands/movepiece.cpp index c294d4e31..961dc787b 100644 --- a/src/libs/vtools/undocommands/movepiece.cpp +++ b/src/libs/vtools/undocommands/movepiece.cpp @@ -52,7 +52,7 @@ MovePiece::MovePiece(VAbstractPattern *doc, const double &x, const double &y, co nodeId = id; SCASSERT(scene != nullptr) - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, VAbstractPattern::TagDetail); if (domElement.isElement()) { m_oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0")); @@ -74,7 +74,7 @@ void MovePiece::undo() { qCDebug(vUndo, "Undo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { SaveCoordinates(domElement, m_oldX, m_oldY); @@ -93,7 +93,7 @@ void MovePiece::redo() { qCDebug(vUndo, "Redo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { SaveCoordinates(domElement, m_newX, m_newY); diff --git a/src/libs/vtools/undocommands/movespline.cpp b/src/libs/vtools/undocommands/movespline.cpp index b0176a9c9..5a9eb0032 100644 --- a/src/libs/vtools/undocommands/movespline.cpp +++ b/src/libs/vtools/undocommands/movespline.cpp @@ -101,7 +101,7 @@ int MoveSpline::id() const //--------------------------------------------------------------------------------------------------------------------- void MoveSpline::Do(const VSpline &spl) { - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagSpline); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); diff --git a/src/libs/vtools/undocommands/movesplinepath.cpp b/src/libs/vtools/undocommands/movesplinepath.cpp index ccd7ff331..d418fcc7c 100644 --- a/src/libs/vtools/undocommands/movesplinepath.cpp +++ b/src/libs/vtools/undocommands/movesplinepath.cpp @@ -100,7 +100,7 @@ int MoveSplinePath::id() const //--------------------------------------------------------------------------------------------------------------------- void MoveSplinePath::Do(const VSplinePath &splPath) { - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagSpline); if (domElement.isElement()) { VToolSplinePath::UpdatePathPoints(doc, domElement, splPath); diff --git a/src/libs/vtools/undocommands/movespoint.cpp b/src/libs/vtools/undocommands/movespoint.cpp index d4f621369..61635229c 100644 --- a/src/libs/vtools/undocommands/movespoint.cpp +++ b/src/libs/vtools/undocommands/movespoint.cpp @@ -50,7 +50,7 @@ MoveSPoint::MoveSPoint(VAbstractPattern *doc, const double &x, const double &y, qCDebug(vUndo, "SPoint newY %f", newY); SCASSERT(scene != nullptr) - QDomElement domElement = doc->elementById(id); + QDomElement domElement = doc->elementById(id, VAbstractPattern::TagPoint); if (domElement.isElement()) { oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrX, "0.0")); @@ -120,7 +120,7 @@ void MoveSPoint::Do(double x, double y) qCDebug(vUndo, "Move to x %f", x); qCDebug(vUndo, "Move to y %f", y); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint); if (domElement.isElement()) { doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(x))); diff --git a/src/libs/vtools/undocommands/savepieceoptions.cpp b/src/libs/vtools/undocommands/savepieceoptions.cpp index 91b587586..7f6aa2400 100644 --- a/src/libs/vtools/undocommands/savepieceoptions.cpp +++ b/src/libs/vtools/undocommands/savepieceoptions.cpp @@ -64,7 +64,7 @@ void SavePieceOptions::undo() { qCDebug(vUndo, "Undo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_oldDet); @@ -95,7 +95,7 @@ void SavePieceOptions::redo() { qCDebug(vUndo, "Redo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail); if (domElement.isElement()) { VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_newDet); diff --git a/src/libs/vtools/undocommands/savepiecepathoptions.cpp b/src/libs/vtools/undocommands/savepiecepathoptions.cpp index 4dee60e08..f9c26e785 100644 --- a/src/libs/vtools/undocommands/savepiecepathoptions.cpp +++ b/src/libs/vtools/undocommands/savepiecepathoptions.cpp @@ -58,7 +58,7 @@ void SavePiecePathOptions::undo() { qCDebug(vUndo, "Undo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPath); if (domElement.isElement()) { VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_oldPath); @@ -82,7 +82,7 @@ void SavePiecePathOptions::redo() { qCDebug(vUndo, "Redo."); - QDomElement domElement = doc->elementById(nodeId); + QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPath); if (domElement.isElement()) { VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_newPath); diff --git a/src/libs/vtools/undocommands/togglepieceinlayout.cpp b/src/libs/vtools/undocommands/togglepieceinlayout.cpp index 2e5d4cd05..9f88e566f 100644 --- a/src/libs/vtools/undocommands/togglepieceinlayout.cpp +++ b/src/libs/vtools/undocommands/togglepieceinlayout.cpp @@ -101,7 +101,7 @@ bool TogglePieceInLayout::getNewState() const //--------------------------------------------------------------------------------------------------------------------- void TogglePieceInLayout::Do(bool state) { - QDomElement detail = doc->elementById(m_id); + QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail); if (detail.isElement()) { if (state == false)