41 const QString packageName = QFileInfo(packageDir).fileName();
42 const QString mappingFilePath =
43 packageDir + QDir::separator() +
44 "data" + QDir::separator() +
45 packageName + QDir::separator() +
46 "StatechartGroupMapping-" + packageName +
".xml";
48 if (!QFileInfo(mappingFilePath).exists())
58 if (groupNode.name() !=
"Group")
63 const auto groupName = QString::fromUtf8(groupNode.attribute_value(
"name").c_str());
64 const auto newGroupName = QString::fromUtf8(groupNode.attribute_value(
"new-name").c_str());
65 const auto package = QString::fromUtf8(groupNode.attribute_value("source-package").c_str());
71 if (stateNode.name() !=
"Mapping")
76 const auto stateName = QString::fromUtf8(stateNode.attribute_value(
"state").c_str());
77 const auto fromUuid = QString::fromUtf8(stateNode.attribute_value(
"from").c_str());
78 const auto toUuid = QString::fromUtf8(stateNode.attribute_value(
"to").c_str());
79 groupMapping.stateMappings.insert({stateName, fromUuid, toUuid});
92 if (groupMapping.groupName == sourceGroupName)
94 return groupMapping.newGroupName;
105 for (
const auto& stateMapping : groupMapping.stateMappings)
107 if (stateMapping.fromUuid == sourceUuid)
109 return stateMapping.toUuid;
119 const QString packageName = QFileInfo(packageDir).fileName();
120 const QString packageDataDir = packageDir + QDir::separator() +
"data" + QDir::separator() + packageName;
121 QDir(packageDataDir).mkpath(
".");
122 const QString mappingFilePath = packageDataDir + QDir::separator() +
"StatechartGroupMapping-" + packageName +
".xml";
129 auto groupNode = rootNode.append_node(
"Group");
130 groupNode.append_attribute(
"name", g.groupName.toUtf8().data());
131 groupNode.append_attribute(
"new-name", g.newGroupName.toUtf8().data());
132 groupNode.append_attribute(
"source-package", g.groupPackage.toUtf8().data());
134 for (
const auto&
s : g.stateMappings)
136 auto stateNode = groupNode.append_node(
"Mapping");
137 stateNode.append_attribute(
"state",
s.stateName.toUtf8().data());
138 stateNode.append_attribute(
"from",
s.fromUuid.toUtf8().data());
139 stateNode.append_attribute(
"to",
s.toUuid.toUtf8().data());
143 writer.
saveToFile(mappingFilePath.toUtf8().data(),
true);