From 72b613f348d80901dbd3ddf710a927d648666871 Mon Sep 17 00:00:00 2001 From: blacksun Date: Wed, 10 Aug 2016 05:23:48 +0000 Subject: [PATCH] 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 --- .../elementscollectionmodel.cpp | 31 +++++++++++++++++-- .../elementscollectionmodel.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index 3f5c5b554..62ea88568 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -224,15 +224,22 @@ bool ElementsCollectionModel::dropMimeData(const QMimeData *data, Qt::DropAction */ void ElementsCollectionModel::loadCollections(bool common_collection, bool custom_collection, QList projects) { + QList list; + if (common_collection) addCommonCollection(false); if (custom_collection) addCustomCollection(false); - foreach (QETProject *project, projects) - addProject(project, false); + if (common_collection || custom_collection) + list.append(items()); + + + foreach (QETProject *project, projects) { + addProject(project, false); + list.append(projectItems(project)); + } - QList list = items(); QFuture futur = QtConcurrent::map(list, setUpData); emit loadingMaxValue(futur.progressMaximum()); while (futur.isRunning()) { @@ -419,6 +426,24 @@ QList ElementsCollectionModel::items() const return list; } +/** + * @brief ElementsCollectionModel::projectItems + * @param project + * @return return all items for project @project. the list can be empty + */ +QList ElementsCollectionModel::projectItems(QETProject *project) const +{ + QList 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 * Hide element in this model, only directory is managed diff --git a/sources/ElementsCollection/elementscollectionmodel.h b/sources/ElementsCollection/elementscollectionmodel.h index b707b4284..86a747710 100644 --- a/sources/ElementsCollection/elementscollectionmodel.h +++ b/sources/ElementsCollection/elementscollectionmodel.h @@ -54,6 +54,7 @@ class ElementsCollectionModel : public QStandardItemModel QList items() const; + QList projectItems(QETProject *project) const; void hideElement(); bool isHideElement() {return m_hide_element;} QModelIndex indexFromLocation(const ElementsLocation &location);