38 std::optional<StatechartGroupMapping>
42 const QString packageName = QFileInfo(packageDir).fileName();
43 const QString mappingFilePath = packageDir + QDir::separator() +
"data" +
44 QDir::separator() + packageName + QDir::separator() +
45 "StatechartGroupMapping-" + packageName +
".xml";
47 if (!QFileInfo(mappingFilePath).exists())
57 if (groupNode.name() !=
"Group")
62 const auto groupName = QString::fromUtf8(groupNode.attribute_value(
"name").c_str());
63 const auto newGroupName =
64 QString::fromUtf8(groupNode.attribute_value(
"new-name").c_str());
66 QString::fromUtf8(groupNode.attribute_value("source-package").c_str());
72 if (stateNode.name() !=
"Mapping")
77 const auto stateName =
78 QString::fromUtf8(stateNode.attribute_value(
"state").c_str());
79 const auto fromUuid = QString::fromUtf8(stateNode.attribute_value(
"from").c_str());
80 const auto toUuid = QString::fromUtf8(stateNode.attribute_value(
"to").c_str());
81 groupMapping.stateMappings.insert({stateName, fromUuid, toUuid});
90 std::optional<QString>
95 if (groupMapping.groupName == sourceGroupName)
97 return groupMapping.newGroupName;
104 std::optional<QString>
109 for (
const auto& stateMapping : groupMapping.stateMappings)
111 if (stateMapping.fromUuid == sourceUuid)
113 return stateMapping.toUuid;
124 const QString packageName = QFileInfo(packageDir).fileName();
125 const QString packageDataDir =
126 packageDir + QDir::separator() +
"data" + QDir::separator() + packageName;
127 QDir(packageDataDir).mkpath(
".");
128 const QString mappingFilePath =
129 packageDataDir + QDir::separator() +
"StatechartGroupMapping-" + packageName +
".xml";
136 auto groupNode = rootNode.append_node(
"Group");
137 groupNode.append_attribute(
"name", g.groupName.toUtf8().data());
138 groupNode.append_attribute(
"new-name", g.newGroupName.toUtf8().data());
139 groupNode.append_attribute(
"source-package", g.groupPackage.toUtf8().data());
141 for (
const auto&
s : g.stateMappings)
143 auto stateNode = groupNode.append_node(
"Mapping");
144 stateNode.append_attribute(
"state",
s.stateName.toUtf8().data());
145 stateNode.append_attribute(
"from",
s.fromUuid.toUtf8().data());
146 stateNode.append_attribute(
"to",
s.toUuid.toUtf8().data());
150 writer.
saveToFile(mappingFilePath.toUtf8().data(),
true);