mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 22:24:13 +02:00
Fill the project database from the file as it is read
The project database -- behind parts lists, summary tables and the wiring list -- was filled by walking the built folios: every element and conductor object of every scene. Filling it from the document the project was just read from instead is what the database needs before a project could be opened without building every folio (qelectrotech-docker DB-FROM-XML-SCOPE.md). updateDB(document), called by readProjectXml(), fills diagram, diagram_info, element, element_info, terminal and conductor from the document, through the code the folios use: a BorderTitleBlock read from each folio's XML gives the title-block values and each element's grid cell, the embedded collection gives each definition, and the binders are shared with the live path. Shapes, texts and pictures still come from the folios (their boxes need fonts and pens). It falls back to the folios, saying why in the log, when the document does not carry what that needs: an item without a saved uuid (older files -- the folios derive them on load), a conductor naming its ends the older way, a %autonum folio number, a terminal showing its master's label, a missing or unbuildable definition. A symbol label computed from a formula is the one saved in the file, which QElectroTech writes as it computes it on every save. QET_DATABASE_FROM_FOLIOS=1 forces the folio path. tst_databasefromdocument saves every example once, then fills both ways and requires identical tables (24/24, filled from the document each time), and checks that an older file falls back with its reason. Red when the document path is made to write a wrong grid cell. Database phase of loading unchanged: industrial.qet 0.146 s vs 0.160 s, Polonez 0.040 s vs 0.038 s (median of 5). QETProject::projectWideProperties() is split out of updateDiagramsFolioData() so both fills use the same title-block context. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-4
@@ -1880,7 +1880,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
|
||||
m_data_base.blockSignals(false);
|
||||
m_data_base.setUpdateBlocked(false);
|
||||
m_data_base.updateDB();
|
||||
m_data_base.updateDB(xml_project);
|
||||
const qint64 database_ms = phase_timer.elapsed();
|
||||
|
||||
qInfo().nospace()
|
||||
@@ -2473,14 +2473,25 @@ bool QETProject::projectWasModified()
|
||||
Indique a chaque schema du projet quel est son numero de folio et combien de
|
||||
folio le projet contient.
|
||||
*/
|
||||
void QETProject::updateDiagramsFolioData()
|
||||
/**
|
||||
@brief QETProject::projectWideProperties
|
||||
@return the project's properties as every folio's title block sees them:
|
||||
the user's project properties plus the project's title, path and file name.
|
||||
*/
|
||||
DiagramContext QETProject::projectWideProperties()
|
||||
{
|
||||
int total_folio = m_diagrams_list.count();
|
||||
|
||||
DiagramContext project_wide_properties = m_project_properties;
|
||||
project_wide_properties.addValue("projecttitle", title());
|
||||
project_wide_properties.addValue("projectpath", filePath());
|
||||
project_wide_properties.addValue("projectfilename", QFileInfo(filePath()).baseName());
|
||||
return project_wide_properties;
|
||||
}
|
||||
|
||||
void QETProject::updateDiagramsFolioData()
|
||||
{
|
||||
int total_folio = m_diagrams_list.count();
|
||||
|
||||
const DiagramContext project_wide_properties = projectWideProperties();
|
||||
|
||||
for (int i = 0 ; i < total_folio ; ++ i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user