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
+29
View File
@@ -357,6 +357,19 @@ const BorderProperties *BorderTitleBlock::storedBorder() const
return nullptr;
}
/**
@brief BorderTitleBlock::storedFolioNumber
@param index set to the stored folio index, when found
@param total set to the stored folio total, when found
@return whether the project's store holds a number for this folio
*/
bool BorderTitleBlock::storedFolioNumber(int *index, int *total) const
{
if (projectDataBase *store = placedStore())
return store->storedFolioNumber(m_owner_folio->uuid(), index, total);
return false;
}
/**
@brief BorderTitleBlock::setOwnerFolio
@param folio : the folio this border and title block belongs to
@@ -401,6 +414,21 @@ void BorderTitleBlock::storeBorder()
store->storeFolioBorder(m_owner_folio->uuid(), exportBorder());
}
/**
@brief BorderTitleBlock::storeFolioNumber
Write this folio's index and total to its project's store, once its
folio is placed: every change of them comes through here.
*/
void BorderTitleBlock::storeFolioNumber()
{
//Read the members directly, not the getters: the getters check the
//store first, which this call is about to update -- going through
//them here would echo back the old stored value instead of the new
//one, the same trap storeBorder() avoids with exportBorder().
if (projectDataBase *store = placedStore())
store->storeFolioNumber(m_owner_folio->uuid(), folio_index_, folio_total_);
}
/**
@brief BorderTitleBlock::importTitleBlock
@param ip the new properties of titleblock
@@ -1178,6 +1206,7 @@ void BorderTitleBlock::setFolioData(
}
btb_final_folio_.replace("%id", QString::number(folio_index_));
btb_final_folio_.replace("%total", QString::number(folio_total_));
storeFolioNumber();
updateDiagramContextForTitleBlock(project_properties);
}