Add a link table to the project database

One row per element and element it is linked to -- a coil and its
contacts, a pair of folio reports -- from each side, with the contact
group the element saved for it. Nothing reads it yet: cross-references
are the main thing one folio needs from another, and this is what lets
them be answered without building every folio.

Filled like the other tables: from the document when it can be read
exactly (a link only one side lists, between kinds that cannot link, or
giving a contact a second coil is left to the folios), from the folios
otherwise. A link made or undone afterwards rewrites that element's rows
when the database is next read, as drawing items are, since the contact
group is set after the link is made.

Test: tst_databasefromdocument compares the link table both ways on
every example; linksAreListed checks a coil and contact (with a group)
in m_000.qet, oneSidedLinkFallsBack the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Wga9B92BNurDEtxxtCDxf
This commit is contained in:
ispyisail
2026-10-10 17:22:56 +13:00
parent 613f05a05e
commit 3089408b19
3 changed files with 281 additions and 14 deletions
+8
View File
@@ -124,6 +124,8 @@ class projectDataBase : public QObject
//Queue the sender()'s drawing-item row for rewriting.
void drawingItemChanged();
void drawingItemDestroyed(QObject *object);
//Queue the sender()'s link rows for rewriting.
void linksChanged();
public:
@@ -141,6 +143,8 @@ class projectDataBase : public QObject
void populateElementInfoTable();
void populateDiagramInfoTable();
void populateConductorTable();
void populateLinkTable();
void flushLinks();
void populateDrawingItemTables();
bool populateFromDocument(const QDomDocument &document, QString *why = nullptr);
bool writeDrawingItem(QObject *object);
@@ -206,6 +210,10 @@ class projectDataBase : public QObject
QHash<QObject *, QUuid> m_drawing_item_row;
QHash<QUuid, QObject *> m_drawing_row_owner;
QSet<QObject *> m_dirty_drawing_items;
//Elements whose links changed since their link rows were last
//written: a link is made first and its contact group set after,
//so the rows are written when next read, as drawing items are.
QList<QPointer<Element>> m_dirty_link_elements;
#ifdef QET_EXPORT_PROJECT_DB
public: