From 0aea48bdaa7cfc50619c80c19ce5d318c5970ce4 Mon Sep 17 00:00:00 2001 From: joshua Date: Fri, 14 May 2021 13:38:59 +0200 Subject: [PATCH] Open project is a litle more faster In the methods readDiagramsXml we call addDiagram for each diagrams loaded from xml, inside the addDiagram method we call the method updateDiagramsFolioData() and to finish this method operate a loop for each existing diagram. Then when we load a project from xml of 10 folios, loop inside updateDiagramsFolioData() is called 55 time. 50 folios, loop inside updateDiagramsFolioData() is called 1275 time. 100 folios, loop inside updateDiagramsFolioData() is called 5050 time. Now instead of call addDiagram, we add diagram directly inside the methods readDiagramsXml and call the method updateDiagramsFolioData() only once when all diagrams are loaded. --- sources/qetproject.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index c485ec41c..748b7bfbc 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -1398,15 +1398,13 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project) QDomElement diagram_xml_element = diagram_nodes .at(i) .toElement(); - Diagram *diagram = new Diagram(this); + auto diagram = new Diagram(this); + m_diagrams_list << diagram; - int diagram_order = -1; - if (!QET::attributeIsAnInteger(diagram_xml_element, - QStringLiteral("order"), - &diagram_order)) - diagram_order = 500000; - - addDiagram(diagram, diagram_order-1); + connect(&diagram->border_and_titleblock, &BorderTitleBlock::needFolioData, + this, &QETProject::updateDiagramsFolioData); + connect(diagram, &Diagram::usedTitleBlockTemplateChanged, + this, &QETProject::usedTitleBlockTemplateChanged); diagram->initFromXml(diagram_xml_element); if(dlgWaiting) @@ -1414,6 +1412,8 @@ void QETProject::readDiagramsXml(QDomDocument &xml_project) } } + updateDiagramsFolioData(); + //Initialise links between elements in this project //and refresh the text of conductor if(dlgWaiting)