Element editor: give every primitive a uuid

Lines, rectangles, ellipses, arcs, polygons, PLC tables and static texts
now save a uuid, as terminals and dynamic texts already did, so a tool can
name one part of a symbol. The graphic parts keep it next to their styles,
since all of them save through stylesToXml(); a part read from a
definition that predates this gets one on the next save.

Paste renews them, as it already did for terminals -- and now for dynamic
texts too, which were pasted with their source's uuid. A placed element
gives its dynamic texts fresh uuids anyway, so only the definition's own
identity changes. PartTerminal::uuid() returns the terminal's saved uuid
rather than inheriting the graphic-part one it never writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-27 11:16:37 +13:00
parent 3a50cd9b0e
commit 30e83d8c52
8 changed files with 57 additions and 2 deletions
+6
View File
@@ -115,6 +115,11 @@ void PartText::flip(qreal axis_y) {
void PartText::fromXml(const QDomElement &xml_element) {
bool ok;
const QUuid uuid(xml_element.attribute(QStringLiteral("uuid")));
if (!uuid.isNull()) {
m_uuid = uuid;
}
if (xml_element.hasAttribute("size")) {
int font_size = xml_element.attribute("size").toInt(&ok);
if (!ok || font_size < 1) {
@@ -169,6 +174,7 @@ const QDomElement PartText::toXml(QDomDocument &xml_document) const
xml_element.setAttribute("font", QETUtils::fontToString(font()));
xml_element.setAttribute("rotation", QString::number(rot));
xml_element.setAttribute("color", defaultTextColor().name());
xml_element.setAttribute("uuid", m_uuid.toString());
// Only written when different from the historical behaviour, so
// existing .elmt files round-trip byte-identical.