diff --git a/qelectrotech.pro b/qelectrotech.pro index 98b2f72c4..640c25085 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -116,7 +116,7 @@ RESOURCES += qelectrotech.qrc TRANSLATIONS += lang/qet_en.ts lang/qet_es.ts lang/qet_fr.ts lang/qet_ru.ts lang/qet_pt.ts lang/qet_cs.ts lang/qet_pl.ts lang/qet_de.ts lang/qet_ro.ts lang/qet_it.ts lang/qet_el.ts lang/qet_nl.ts lang/qet_be.ts # Modules Qt utilises par l'application -QT += xml svg network sql widgets printsupport +QT += xml svg network sql widgets printsupport concurrent # UI DESIGNER FILES AND GENERATION SOURCES FILES FORMS += $$files(sources/richtext/*.ui) \ diff --git a/sources/ElementsCollection/elementcollectionitem.cpp b/sources/ElementsCollection/elementcollectionitem.cpp index 9f0bfbd22..a12ac6df7 100644 --- a/sources/ElementsCollection/elementcollectionitem.cpp +++ b/sources/ElementsCollection/elementcollectionitem.cpp @@ -208,3 +208,8 @@ QList ElementCollectionItem::items() const return list; } + +void setUpData(ElementCollectionItem *eci) +{ + eci->setUpData(); +} diff --git a/sources/ElementsCollection/elementcollectionitem.h b/sources/ElementsCollection/elementcollectionitem.h index 2726acb60..49477e255 100644 --- a/sources/ElementsCollection/elementcollectionitem.h +++ b/sources/ElementsCollection/elementcollectionitem.h @@ -56,4 +56,6 @@ class ElementCollectionItem : public QStandardItem QList items() const; }; +void setUpData(ElementCollectionItem *eci); + #endif // ELEMENTCOLLECTIONITEM2_H diff --git a/sources/ElementsCollection/elementscollectionwidget.cpp b/sources/ElementsCollection/elementscollectionwidget.cpp index f61eda389..e42e1178f 100644 --- a/sources/ElementsCollection/elementscollectionwidget.cpp +++ b/sources/ElementsCollection/elementscollectionwidget.cpp @@ -35,6 +35,7 @@ #include #include #include +#include /** * @brief ElementsCollectionWidget::ElementsCollectionWidget @@ -447,12 +448,11 @@ void ElementsCollectionWidget::reload() new_model->addProject(project, false); QList list = new_model->items(); - m_progress_bar->setMaximum(list.size()); - m_progress_bar->setValue(0); - foreach (ElementCollectionItem *item, new_model->items()) - { - item->setUpData(); - m_progress_bar->setValue(m_progress_bar->value() + 1); + QFuture futur = QtConcurrent::map(list, setUpData); + m_progress_bar->setMinimum(futur.progressMinimum()); + m_progress_bar->setMaximum(futur.progressMaximum()); + while (futur.isRunning()) { + m_progress_bar->setValue(futur.progressValue()); } m_tree_view->setModel(new_model); diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp index d5e637380..dfe213cce 100644 --- a/sources/ElementsCollection/elementslocation.cpp +++ b/sources/ElementsCollection/elementslocation.cpp @@ -654,21 +654,21 @@ QIcon ElementsLocation::icon() const */ QString ElementsLocation::name() const { - if (!m_project) - { - ElementsCollectionCache *cache = QETApp::collectionCache(); - ElementsLocation loc(*this); //Make a copy of this to keep this method const - if (cache->fetchElement(loc)) - return cache->name(); - else - return QString(); - } - else - { +// if (!m_project) +// { +// ElementsCollectionCache *cache = QETApp::collectionCache(); +// ElementsLocation loc(*this); //Make a copy of this to keep this method const +// if (cache->fetchElement(loc)) +// return cache->name(); +// else +// return QString(); +// } +// else +// { NamesList nl; nl.fromXml(xml()); return nl.name(fileName()); - } +// } } /** diff --git a/sources/elementdialog.cpp b/sources/elementdialog.cpp index 50f1222a9..73865b24f 100644 --- a/sources/elementdialog.cpp +++ b/sources/elementdialog.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "elementdialog.h" #include "qetapp.h" @@ -86,11 +87,15 @@ void ElementDialog::setUpWidget() m_tree_view = new QTreeView(this); m_model = new ElementsCollectionModel(m_tree_view); - if (m_mode == OpenElement) {m_model->addCommonCollection();} - m_model->addCustomCollection(); - foreach (QETProject *project, QETApp::registeredProjects()) { - m_model->addProject(project); - } + if (m_mode == OpenElement) + m_model->addCommonCollection(false); + m_model->addCustomCollection(false); + + foreach (QETProject *project, QETApp::registeredProjects()) + m_model->addProject(project, false); + + QList list = m_model->items(); + QtConcurrent::blockingMap(list, setUpData); m_tree_view->setModel(m_model); m_tree_view->setHeaderHidden(true);