mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
When add a new project, load only items of project, instead of reload every items owned by the model
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4616 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -224,15 +224,22 @@ bool ElementsCollectionModel::dropMimeData(const QMimeData *data, Qt::DropAction
|
|||||||
*/
|
*/
|
||||||
void ElementsCollectionModel::loadCollections(bool common_collection, bool custom_collection, QList<QETProject *> projects)
|
void ElementsCollectionModel::loadCollections(bool common_collection, bool custom_collection, QList<QETProject *> projects)
|
||||||
{
|
{
|
||||||
|
QList <ElementCollectionItem *> list;
|
||||||
|
|
||||||
if (common_collection)
|
if (common_collection)
|
||||||
addCommonCollection(false);
|
addCommonCollection(false);
|
||||||
if (custom_collection)
|
if (custom_collection)
|
||||||
addCustomCollection(false);
|
addCustomCollection(false);
|
||||||
|
|
||||||
foreach (QETProject *project, projects)
|
if (common_collection || custom_collection)
|
||||||
addProject(project, false);
|
list.append(items());
|
||||||
|
|
||||||
|
|
||||||
|
foreach (QETProject *project, projects) {
|
||||||
|
addProject(project, false);
|
||||||
|
list.append(projectItems(project));
|
||||||
|
}
|
||||||
|
|
||||||
QList <ElementCollectionItem *> list = items();
|
|
||||||
QFuture<void> futur = QtConcurrent::map(list, setUpData);
|
QFuture<void> futur = QtConcurrent::map(list, setUpData);
|
||||||
emit loadingMaxValue(futur.progressMaximum());
|
emit loadingMaxValue(futur.progressMaximum());
|
||||||
while (futur.isRunning()) {
|
while (futur.isRunning()) {
|
||||||
@@ -419,6 +426,24 @@ QList <ElementCollectionItem *> ElementsCollectionModel::items() const
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementsCollectionModel::projectItems
|
||||||
|
* @param project
|
||||||
|
* @return return all items for project @project. the list can be empty
|
||||||
|
*/
|
||||||
|
QList<ElementCollectionItem *> ElementsCollectionModel::projectItems(QETProject *project) const
|
||||||
|
{
|
||||||
|
QList <ElementCollectionItem *> list;
|
||||||
|
|
||||||
|
if (m_project_list.contains(project)) {
|
||||||
|
ElementCollectionItem *eci = m_project_hash.value(project);
|
||||||
|
list.append(eci);
|
||||||
|
list.append(eci->items());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementsCollectionModel::hideElement
|
* @brief ElementsCollectionModel::hideElement
|
||||||
* Hide element in this model, only directory is managed
|
* Hide element in this model, only directory is managed
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class ElementsCollectionModel : public QStandardItemModel
|
|||||||
|
|
||||||
|
|
||||||
QList <ElementCollectionItem *> items() const;
|
QList <ElementCollectionItem *> items() const;
|
||||||
|
QList <ElementCollectionItem *> projectItems(QETProject *project) const;
|
||||||
void hideElement();
|
void hideElement();
|
||||||
bool isHideElement() {return m_hide_element;}
|
bool isHideElement() {return m_hide_element;}
|
||||||
QModelIndex indexFromLocation(const ElementsLocation &location);
|
QModelIndex indexFromLocation(const ElementsLocation &location);
|
||||||
|
|||||||
Reference in New Issue
Block a user