[qet] [3314] Diagram folio list is now always at the beginnig of the project ( at creation and at load)

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


Revision: 3314
Author:   blacksun
Date:     2014-09-19 12:22:57 +0200 (Fri, 19 Sep 2014)
Log Message:
-----------
Diagram folio list is now always at the beginnig of the project (at creation and at load)

Modified Paths:
--------------
    trunk/sources/projectview.cpp
    trunk/sources/projectview.h

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2014-09-18 18:12:05 UTC (rev 3313)
+++ trunk/sources/projectview.cpp	2014-09-19 10:22:57 UTC (rev 3314)
@@ -316,13 +316,14 @@
  */
 void ProjectView::addNewDiagramFolioList() {
 	if (project_ -> isReadOnly()) return;
-
-	QList <Diagram *> list = project_ -> addNewDiagramFolioList();
-	int size = list.size();
-	for (int i = 0; i < size; i++) {
-		DiagramView *new_diagram_view = new DiagramView(list.takeLast());
-		addDiagram(new_diagram_view, true);
+	int i = 0; //< Each new diagram is added  to the end of the project.
+			   //< We use @i to move the folio list at the beginning of the project
+	foreach (Diagram *d, project_ -> addNewDiagramFolioList()) {
+		DiagramView *new_diagram_view = new DiagramView(d);
+		addDiagram(new_diagram_view);
 		showDiagram(new_diagram_view);
+		tabs_->moveTab(diagrams().size()-1, i);
+		i++;
 	}
 }
 
@@ -337,7 +338,7 @@
  * @param front: true add page at front
  *				 false add page at back
  */
-void ProjectView::addDiagram(DiagramView *diagram, bool front) {
+void ProjectView::addDiagram(DiagramView *diagram) {
 	if (!diagram) return;
 
 	// check diagram isn't present in the project
@@ -358,10 +359,6 @@
 	
 	// signal diagram was added
 	emit(diagramAdded(diagram));
-	// move tab to front if wanted
-	if (front) {
-		tabs_->moveTab(tabs_->count()-1, 0);
-	}
 }
 
 /**
@@ -769,9 +766,13 @@
 	layout_ -> addWidget(tabs_);
 }
 
+
 /**
-	Charge les schemas du projet
-*/
+ * @brief ProjectView::loadDiagrams
+ * Load diagrams of project.
+ * We create a diagram view for each diagram,
+ * and add it to the project view.
+ */
 void ProjectView::loadDiagrams() {
 	if (!project_) return;
 	
@@ -781,11 +782,18 @@
 		DiagramView *sv = new DiagramView(diagram);
 		addDiagram(sv);
 	}
+
+	// If project have the folios list, move it at the beginning of the project
+	if (project_ -> getFolioSheetsQuantity()) {
+		for (int i = 0; i < project_->getFolioSheetsQuantity(); i++)
+		tabs_ -> moveTab(diagrams().size()-1, 0);
+	}
 }
 
 /**
-	Met a jour le titre du ProjectView
-*/
+ * @brief ProjectView::updateWindowTitle
+ * Update the project view title
+ */
 void ProjectView::updateWindowTitle() {
 	QString title;
 	if (project_) {

Modified: trunk/sources/projectview.h
===================================================================
--- trunk/sources/projectview.h	2014-09-18 18:12:05 UTC (rev 3313)
+++ trunk/sources/projectview.h	2014-09-19 10:22:57 UTC (rev 3314)
@@ -61,7 +61,7 @@
 	public slots:
 	void addNewDiagram();
 	void addNewDiagramFolioList();
-	void addDiagram(DiagramView *, bool front=false);
+	void addDiagram(DiagramView *);
 	void removeDiagram(DiagramView *);
 	void removeDiagram(Diagram *);
 	void showDiagram(DiagramView *);


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