Move a folio's number and total through the project database

QETZ-DB-FIRST 2d-1: the first sub-stage of 2d (QETZ-DB-FIRST-2D-SCOPE.md).
A folio's 1-based position among the project's folios, and the project's
folio count, were purely computed on the fly from QETProject's live
m_diagrams_list (QETProject::folioIndex(), updateDiagramsFolioData()) and
cached only as BorderTitleBlock's own folio_index_/folio_total_ members --
never in projectDataBase, so nothing could query a folio's number without
walking the live project.

Add a folio_number table (diagram_uuid, folio_index, folio_total), written
through from two places: BorderTitleBlock::setFolioData() (every live
folio add/remove/reorder, same point that already sets the members), and
projectDataBase::populateFromDocument() (straight from the document for a
folio not yet built, same habit as folio_titleblock/folio_border). Added
BorderTitleBlock::folioIndex() as a public getter alongside the existing
folioTotal(), both now reading the store first like the other title-block
and border accessors added in stage 2c.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-23 07:26:45 +13:00
parent df73934bfb
commit 44c96a4c95
4 changed files with 117 additions and 2 deletions
+8
View File
@@ -154,6 +154,13 @@ class projectDataBase : public QObject
const BorderProperties *storedFolioBorder(const QUuid &folio) const;
void storeFolioBorder(const QUuid &folio, const BorderProperties &properties);
//The folio number and total folio count of every folio of the
//project, by folio uuid: recomputed whenever a folio is added,
//removed or reordered (QETProject::updateDiagramsFolioData()),
//the store each folio's number is written through.
bool storedFolioNumber(const QUuid &folio, int *index, int *total) const;
void storeFolioNumber(const QUuid &folio, int index, int total);
//The properties of every wire placed in the project, by wire
//uuid: the store each wire's properties are written through
//A wire not placed keeps its own.
@@ -430,6 +437,7 @@ class projectDataBase : public QObject
QHash<QUuid, UnbuiltWireEdit> m_unbuilt_wire_edits;
QHash<QUuid, TitleBlockProperties> m_folio_titleblocks;
QHash<QUuid, BorderProperties> m_folio_borders;
QHash<QUuid, QPair<int, int>> m_folio_numbers; // index, total
QHash<QUuid, QPointer<Diagram>> m_placed_folios;
QHash<QUuid, ConductorProperties> m_conductor_properties;
//The rows of conductor_properties, to write only what changes