mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 05:44:14 +02:00
Scripting: look up a table or a symbol text field by its uuid
qet.textIndex(), shapeIndex() and imageIndex() turn a free text's, shape's or picture's uuid into the index the other calls take. Tables and symbol text fields had no such lookup, so a script could only name them by index, and an index shifts when an earlier item is deleted: a script that deletes table 0 and then moves "table 1" moves the wrong table. - qet.tableIndex(folio, uuid): the table's current index in tables(folio), or -1. - qet.elementTextIndex(folio, elementUuid, textUuid): the field's current index in elementTexts(folio, elementUuid), or -1. The element is part of the address because a field's uuid is unique only within its element: copying an element keeps its fields' uuids (2612_ats_singlephase.qet has one field uuid on 20 copies). Tests in misc/qet-mcp's integration suite, which drives these through --run: a table followed across a deletion of the one before it, and the same field uuid resolving on two copies to each copy's own field. Both fail against a build without this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2891,6 +2891,27 @@ int QetScriptApi::imageIndex(int folioIndex, const QString &uuid) const
|
||||
return indexOfUuid(sortedImages(folioIndex), uuid);
|
||||
}
|
||||
|
||||
/// @brief QetScriptApi::tableIndex as textIndex(), for tables(folioIndex).
|
||||
int QetScriptApi::tableIndex(int folioIndex, const QString &uuid) const
|
||||
{
|
||||
return indexOfUuid(sortedTables(folioIndex), uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetScriptApi::elementTextIndex
|
||||
The current index in elementTexts() of the text field carrying
|
||||
@p textUuid, on the element @p elementUuid, or -1.
|
||||
A field's uuid is unique only within its element: copying an element
|
||||
keeps its fields' uuids, so the element is part of the address.
|
||||
*/
|
||||
int QetScriptApi::elementTextIndex(int folioIndex, const QString &elementUuid,
|
||||
const QString &textUuid) const
|
||||
{
|
||||
Element *element = findElement(folioIndex, elementUuid);
|
||||
if (!element) return -1;
|
||||
return indexOfUuid(element->dynamicTextItems(), textUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QetScriptApi::addImage
|
||||
Place a picture from a file, as the "add image" tool does after its file
|
||||
|
||||
Reference in New Issue
Block a user