mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Use multithreading for loading the element collection
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4542 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
e6c2ed8d5f
commit
2ec0278213
@ -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) \
|
||||
|
@ -208,3 +208,8 @@ QList<ElementCollectionItem *> ElementCollectionItem::items() const
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void setUpData(ElementCollectionItem *eci)
|
||||
{
|
||||
eci->setUpData();
|
||||
}
|
||||
|
@ -56,4 +56,6 @@ class ElementCollectionItem : public QStandardItem
|
||||
QList<ElementCollectionItem *> items() const;
|
||||
};
|
||||
|
||||
void setUpData(ElementCollectionItem *eci);
|
||||
|
||||
#endif // ELEMENTCOLLECTIONITEM2_H
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QTimer>
|
||||
#include <QtConcurrent>
|
||||
|
||||
/**
|
||||
* @brief ElementsCollectionWidget::ElementsCollectionWidget
|
||||
@ -447,12 +448,11 @@ void ElementsCollectionWidget::reload()
|
||||
new_model->addProject(project, false);
|
||||
|
||||
QList <ElementCollectionItem *> 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<void> 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);
|
||||
|
@ -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());
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QTreeView>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QtConcurrent>
|
||||
|
||||
#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 <ElementCollectionItem *> list = m_model->items();
|
||||
QtConcurrent::blockingMap(list, setUpData);
|
||||
|
||||
m_tree_view->setModel(m_model);
|
||||
m_tree_view->setHeaderHidden(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user