From fd9ab47041bc0f1265badf41bf54bd0f8ea7f652 Mon Sep 17 00:00:00 2001 From: joshua Date: Fri, 14 May 2021 15:47:10 +0200 Subject: [PATCH] Load project from xml is a little more faster Like previous commit, in the method loadDiadrams() we call the method diagramAdded(), in this method we call rebuildDiagramsMap() updateAllTabsTitle() and these methods operate a loop for each existing DiagramView. Now loadDiagrams don't call diagramAdded (which must be used only when user add a diagram during the use of QElectroTech) but make operations itself and when all DiagramView are added, call rebuildDiagramsMap() updateAllTabsTitle() only once. --- sources/projectview.cpp | 29 +++++++++++++++++++---------- sources/projectview.h | 6 +++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/sources/projectview.cpp b/sources/projectview.cpp index f5420dbfa..7edbb67e7 100644 --- a/sources/projectview.cpp +++ b/sources/projectview.cpp @@ -810,30 +810,39 @@ void ProjectView::loadDiagrams() setDisplayFallbackWidget(m_project -> diagrams().isEmpty()); - DialogWaiting *dialog = nullptr; - if(DialogWaiting::hasInstance()) + auto dialog = DialogWaiting::instance(); + if(dialog) { - dialog = DialogWaiting::instance(); dialog->setTitle( tr("

" "Ouverture du projet en cours...
" "Création des onglets de folio :" "

")); } - for(Diagram *diagram : m_project->diagrams()) + + for(auto diagram : m_project->diagrams()) { if(dialog) { dialog->setDetail(diagram->title()); dialog->setProgressBar(dialog->progressBarValue()+1); } - diagramAdded(diagram); + + auto dv = new DiagramView(diagram); + dv->setFrameStyle(QFrame::Plain | QFrame::NoFrame); + + auto index = m_project->folioIndex(diagram); + m_tab->insertTab(index, dv, QET::Icons::Diagram, dv->title()); + m_diagram_view_list.insert(index, dv); + + connect(dv, &DiagramView::showDiagram, this, QOverload::of(&ProjectView::showDiagram)); + connect(dv, &DiagramView::titleChanged, this, &ProjectView::updateTabTitle); + connect(dv, &DiagramView::findElementRequired, this, &ProjectView::findElementRequired); + connect(&dv->diagram()->border_and_titleblock , &BorderTitleBlock::titleBlockFolioChanged, [this, dv]() {this->updateTabTitle(dv);}); } - if (DiagramView *dv = currentDiagram()) - { - dv->diagram()->loadElmtFolioSeq(); - dv->diagram()->loadCndFolioSeq(); - } + rebuildDiagramsMap(); + updateAllTabsTitle(); + m_tab->setCurrentWidget(firstDiagram()); } diff --git a/sources/projectview.h b/sources/projectview.h index ba037761b..01f312e2a 100644 --- a/sources/projectview.h +++ b/sources/projectview.h @@ -87,10 +87,14 @@ class ProjectView : public QWidget private: ProjectView(const ProjectView &); + //Method related to construction of this class + void setProject(QETProject *project); + + + // methods public: QETProject *project(); - void setProject(QETProject *); QList diagram_views() const; DiagramView *currentDiagram() const; void closeEvent(QCloseEvent *) override;