Save a symbol's links from the project database

A symbol's <links_uuids> are now what the project database's link rows
list for it, in their order (projectDataBase::savedLinks()), instead of
a list the save built itself from the symbol's partners: QETZ-DB-FIRST
stage 2a, the save reads links from the database. A symbol the database
does not hold (saved outside a project) still lists them itself.

The rows leave out a partner the project no longer has, so removing a
folio with every folio built no longer saves links to its symbols, as
lazy folios already did (the links part of F113). Every other save is
unchanged.

tst_resaveunchanged removedFolioLeavesNoLinkToIt: affuteuse_250h with
every folio built, folio 3 removed: 4 links named symbols no longer in
the file, none now.

Needs #1522 (each symbol its own uuid) and #1523 (rows in saved order);
local only until both are merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XCdg2Er2vYhB8Vwa5G7fSR
This commit is contained in:
ispyisail
2026-10-18 19:26:42 +13:00
parent a98f8e33be
commit b473a07b7d
4 changed files with 88 additions and 5 deletions
+33
View File
@@ -3954,6 +3954,39 @@ QStringList projectDataBase::linkRowMismatches()
return mismatches;
}
/**
@brief projectDataBase::savedLinks
The links @p element saves, read from its link rows, in their order
(insertLinkRows()): what Element::toXml() writes (QETZ-DB-FIRST stage
2a). A partner the project no longer has, on a removed folio, has no
row, so it is not saved.
@return false if the database does not hold @p element (not placed in
this project): the caller then takes the links from the symbol itself
*/
bool projectDataBase::savedLinks(const Element *element, QList<std::pair<QUuid, int>> *links)
{
if (!element || !m_placed_elements.contains(element->uuid(), const_cast<Element *>(element))) {
return false;
}
flushLinks();
if (m_saved_links_query.lastQuery().isEmpty()) {
m_saved_links_query = QSqlQuery(m_data_base);
m_saved_links_query.prepare(QStringLiteral("SELECT linked_uuid, group_index FROM link "
"WHERE element_uuid = :uuid ORDER BY ord, rowid"));
}
m_saved_links_query.bindValue(QStringLiteral(":uuid"), element->uuid().toString());
if (!m_saved_links_query.exec()) {
qDebug() << "projectDataBase::savedLinks error : " << m_saved_links_query.lastError();
return false;
}
links->clear();
while (m_saved_links_query.next()) {
links->append({QUuid(m_saved_links_query.value(0).toString()),
m_saved_links_query.value(1).isNull() ? -1 : m_saved_links_query.value(1).toInt()});
}
return true;
}
/**
@brief projectDataBase::waitingSymbols
@return the symbols on folios not built yet (lazy folios): partners a