[qet] [4616] When add a new project, load only items of project, instead of reload every items owned by the model

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4616
Author:   blacksun
Date:     2016-08-10 07:23:48 +0200 (Wed, 10 Aug 2016)
Log Message:
-----------
When add a new project, load only items of project, instead of reload every items owned by the model

Modified Paths:
--------------
    trunk/sources/ElementsCollection/elementscollectionmodel.cpp
    trunk/sources/ElementsCollection/elementscollectionmodel.h

Modified: trunk/sources/ElementsCollection/elementscollectionmodel.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionmodel.cpp	2016-08-09 20:00:07 UTC (rev 4615)
+++ trunk/sources/ElementsCollection/elementscollectionmodel.cpp	2016-08-10 05:23:48 UTC (rev 4616)
@@ -224,15 +224,22 @@
  */
 void ElementsCollectionModel::loadCollections(bool common_collection, bool custom_collection, QList<QETProject *> projects)
 {
+	QList <ElementCollectionItem *> list;
+
 	if (common_collection)
 		addCommonCollection(false);
 	if (custom_collection)
 		addCustomCollection(false);
 
-	foreach (QETProject *project, projects)
+	if (common_collection || custom_collection)
+		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);
 	emit loadingMaxValue(futur.progressMaximum());
 	while (futur.isRunning()) {
@@ -420,6 +427,24 @@
 }
 
 /**
+ * @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
  * Hide element in this model, only directory is managed
  */

Modified: trunk/sources/ElementsCollection/elementscollectionmodel.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionmodel.h	2016-08-09 20:00:07 UTC (rev 4615)
+++ trunk/sources/ElementsCollection/elementscollectionmodel.h	2016-08-10 05:23:48 UTC (rev 4616)
@@ -54,6 +54,7 @@
 
 
 		QList <ElementCollectionItem *> items() const;
+		QList <ElementCollectionItem *> projectItems(QETProject *project) const;
 		void hideElement();
 		bool isHideElement() {return m_hide_element;}
 		QModelIndex indexFromLocation(const ElementsLocation &location);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/