mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01: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:
@@ -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());
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user