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
@@ -18,15 +18,17 @@
#include "pastepartscommand.h"
#include "../elementview.h"
#include "../graphicspart/partdynamictextfield.h"
#include "../graphicspart/partterminal.h"
#include "../graphicspart/parttext.h"
/**
@brief PastePartsCommand::PastePartsCommand
@param view : view where this command work
@param content_to_paste : content to paste
@param parent : parent undo command
@note all terminal stored in content_to_paste get a new uuid
in the constructor of this class to avoid have several terminal
@note all terminal and primitives stored in content_to_paste get a new
uuid in the constructor of this class to avoid have several parts
of an element with the same uuid.
*/
PastePartsCommand::PastePartsCommand(
@@ -40,6 +42,20 @@ PastePartsCommand::PastePartsCommand(
if (qgi->type() == PartTerminal::Type) {
auto part_terminal = static_cast<PartTerminal*>(qgi);
part_terminal->setNewUuid();
}
//Same for the primitives, whose uuid would otherwise name both
//the original and its copy.
else if (qgi->type() == PartText::Type) {
static_cast<PartText *>(qgi)->setNewUuid();
}
//Only the definition's own identity: a placed element gives
//each of its dynamic texts a fresh uuid anyway (see
//Element::parseDynamicText()).
else if (qgi->type() == PartDynamicTextField::Type) {
static_cast<PartDynamicTextField *>(qgi)->setNewUuid();
}
else if (auto graphic_part = dynamic_cast<CustomElementGraphicPart *>(qgi)) {
graphic_part->setNewUuid();
}
m_pasted_content.append(qgi);
}