Add, move or remove a folio without building the others (stage D5)

Adding, moving or removing a folio rewrote every folio's position in
the project database through diagrams(), which builds every folio: 3 s
on a 50-folio project opened lazily. A folio not built has its position
and title block already, so folios() is enough. The list of tables a
table can continue builds only the folios holding a table (from the
index of a .qetz), and the wiring list's count of wires left out looks
at built folios only: reading a wire drops it unless both its ends are
found.

tst_lazyfolios: a folio added, moved and removed builds no other, with
the folios' rows as when every folio is built (fails with diagrams():
47 built); the tables listed as when built, building the 12 folios that
hold one (fails when every folio is built). ctest 96/96 eager and lazy;
342 corpus projects save the same in all four arms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-12 08:46:31 +13:00
parent 8ae937007c
commit e7fd820db6
5 changed files with 91 additions and 4 deletions
+55
View File
@@ -725,6 +725,61 @@ int main(int argc, char **argv)
check(asked.folioPartsRead() == built, "asking a .qetz reads no file of a folio not built");
}
//A folio added, moved and removed: no other folio built, the
//folios' rows as when every folio is built (D5)
{
auto shuffle = [](QETProject &project) {
Diagram *added = project.addNewDiagram();
project.diagramOrderChanged(1, 0);
project.removeDiagram(added);
};
auto folioRows = [](QETProject &project) {
QStringList rows;
for (const QString &row : tables(project))
if (row.startsWith("diagram")) rows << row;
return rows;
};
QETProject shuffled(zipped);
const int unbuilt = shuffled.unloadedFolioCount();
shuffle(shuffled);
std::printf(".qetz folio added, moved, removed: %d folios built\n",
unbuilt - shuffled.unloadedFolioCount());
check(shuffled.unloadedFolioCount() == unbuilt, "adding, moving and removing a folio builds no other");
qunsetenv("QET_LAZY_FOLIOS");
QETProject usual_shuffled(zipped);
qputenv("QET_LAZY_FOLIOS", "1");
shuffle(usual_shuffled);
check(folioRows(shuffled) == folioRows(usual_shuffled), "folios' rows after a move as when built");
}
//The tables a table can continue (its properties editor) and
//the wiring list's count of wires left out: only the folios
//holding a table built (D5)
{
QETProject listed(zipped);
const int unbuilt = listed.unloadedFolioCount();
auto tableUuids = [](const QVector<QetGraphicsTableItem *> &list) {
QStringList uuids;
for (QetGraphicsTableItem *table : list) uuids << table->uuid().toString();
uuids.sort();
return uuids;
};
const QStringList lazy_tables = tableUuids(ElementProvider(&listed).table(nullptr, nullptr));
check(!lazy_tables.isEmpty(), "the project has tables");
check(lazy_tables == tableUuids(ElementProvider(&eager).table(nullptr, nullptr)),
"the project's tables listed as when built");
check(listed.dataBase()->excludedConductorCount() == eager.dataBase()->excludedConductorCount(),
"wires left out of the wiring list counted as when built");
int with_tables = 0;
for (Diagram *folio : folios) {
for (QGraphicsItem *item : folio->items())
if (item->type() == QetGraphicsTableItem::Type) { ++with_tables; break; }
}
std::printf(".qetz tables listed: %d folios built, %d hold a table\n",
unbuilt - listed.unloadedFolioCount(), with_tables);
check(listed.unloadedFolioCount() > 0, "listing the tables does not build every folio");
}
//Saved as a .qetz without building the folios not touched
//(D4): their parts and rows copied as they were
QETProject untouched(zipped);