Number terminals and export wire numbers without building every folio (stage D5)

Terminal numbering builds only the folios holding a terminal. The wire
numbers export reads the wires of the folios not built from the project
database, and walks a built folio's own wires instead of a
DiagramContent, which followed their potentials through folio reports
and built the folios at the other end. The wiring list export names a
folio from its title block, which a folio not built has; it still
builds every folio, writing the whole project out (toXml()).

tst_lazyfolios: wire numbers exported as when built, from a .qet and a
.qetz, building no folio (fails with DiagramContent: 27 built);
terminal numbering builds 7 folios, those with a terminal (fails with
diagrams(): 47); the wiring list as when 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 10:37:27 +13:00
parent e7fd820db6
commit b972dbec4b
6 changed files with 108 additions and 8 deletions
+25 -4
View File
@@ -19,11 +19,12 @@
#include "qetproject.h"
#include "qetapp.h"
#include "diagram.h"
#include "diagramcontent.h"
#include "qetgraphicsitem/conductor.h"
#include "qetgraphicsitem/conductortextitem.h"
#include "qetgraphicsitem/element.h"
#include "qetgraphicsitem/terminal.h"
#include "dataBase/projectdatabase.h"
#include "properties/elementdata.h"
#include <QFileDialog>
@@ -114,10 +115,30 @@ void ConductorNumExport::fillHash()
{
//We used this rx to avoid insert num composed only withe white space.
QRegularExpression rx("^ *$");
for (Diagram *d : m_project->diagrams())
auto count = [this](const QString &num) {
m_hash.insert(num, m_hash.value(num, 0) + 1);
};
//The folios not built (QET_LAZY_FOLIOS): their wires from the
//project database, by the same rules
QList<QUuid> unbuilt;
for (Diagram *d : m_project->folios())
if (!d->isLoaded()) unbuilt << d->uuid();
for (const auto &wire : m_project->dataBase()->wiresOnFolios(unbuilt))
{
DiagramContent dc(d, false);
for (Conductor *c : dc.conductors())
if (wire.text.isEmpty() || wire.text.contains(rx)) {
continue;
}
const bool report1 = ElementData::typeFromString(wire.kind1) & ElementData::AllReport;
const bool report2 = ElementData::typeFromString(wire.kind2) & ElementData::AllReport;
if (!(report1 && report2)) {
count(wire.text);
}
}
for (Diagram *d : m_project->builtFolios())
{
//Its wires only: a DiagramContent would follow their
//potentials onto other folios, building those not built
for (Conductor *c : d->conductors())
{
QString num = c->textItem()->toPlainText();
if (num.isEmpty() || num.contains(rx)) {