diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c532ce063..d723c0365 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1494,3 +1494,35 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const return group; } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetGroupName(quint32 id, const QString &name) +{ + QDomElement groups = CreateGroups(); + if (not groups.isNull()) + { + QDomElement group = elementById(id); + if (group.isElement()) + { + group.setAttribute(AttrName, name); + modified = true; + emit patternChanged(false); + } + else + { + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + + qDebug("Can't get group by id = %u.", id); + return; + } + } + else + { + qDebug("Can't get tag Groups."); + return; + } +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 77ada5d8a..90e8c1b3c 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -118,6 +118,7 @@ public: QDomElement CreateGroups(); QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData); + void SetGroupName(quint32 id, const QString &name); static const QString TagPattern; static const QString TagCalculation; diff --git a/src/libs/vtools/undocommands/addgroup.cpp b/src/libs/vtools/undocommands/addgroup.cpp index b4b86ef90..2a5bdf65b 100644 --- a/src/libs/vtools/undocommands/addgroup.cpp +++ b/src/libs/vtools/undocommands/addgroup.cpp @@ -67,6 +67,12 @@ void AddGroup::undo() } else { + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + qCDebug(vUndo, "Can't get group by id = %u.", nodeId); return; }