[qet] qet/qet: [4980] Fix behavior :

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


Revision: 4980
Author:   blacksun
Date:     2017-06-20 21:15:39 +0200 (Tue, 20 Jun 2017)
Log Message:
-----------
Fix behavior :
In some condition, label of report element are not up to date.
In some condition, the title of tabs widget of folios are not up to date

Modified Paths:
--------------
    trunk/dev_doc/enum_type_of_QGraphicsItem
    trunk/sources/projectview.cpp
    trunk/sources/qetgraphicsitem/reportelement.cpp

Modified: trunk/dev_doc/enum_type_of_QGraphicsItem
===================================================================
--- trunk/dev_doc/enum_type_of_QGraphicsItem	2017-06-14 13:32:52 UTC (rev 4979)
+++ trunk/dev_doc/enum_type_of_QGraphicsItem	2017-06-20 19:15:39 UTC (rev 4980)
@@ -21,3 +21,6 @@
 part text       + 1107
 part text field + 1108
 part rectangle  + 1109
+
+###QetGraphicsHandlerItem###
+QetGraphicsHandlerItem = 1200

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2017-06-14 13:32:52 UTC (rev 4979)
+++ trunk/sources/projectview.cpp	2017-06-20 19:15:39 UTC (rev 4980)
@@ -393,7 +393,7 @@
 	m_diagram_view_list << diagram_view;
 
 	rebuildDiagramsMap();
-	updateTabTitle(diagram_view);
+	updateAllTabsTitle();
 	
 	connect(diagram_view, SIGNAL(showDiagram(Diagram*)), this, SLOT(showDiagram(Diagram*)));
 	connect(diagram_view, SIGNAL(titleChanged(DiagramView *, const QString &)), this, SLOT(updateTabTitle(DiagramView *)));
@@ -406,18 +406,21 @@
 }
 
 /**
-	Enleve un schema du ProjectView
-	@param diagram_view Schema a enlever
-*/
-void ProjectView::removeDiagram(DiagramView *diagram_view) {
-	if (!diagram_view) return;
-	if (m_project -> isReadOnly()) return;
+ * @brief ProjectView::removeDiagram
+ * Remove a diagram (folio) of the project
+ * @param diagram_view : diagram view to remove
+ */
+void ProjectView::removeDiagram(DiagramView *diagram_view)
+{
+	if (!diagram_view)
+        return;
+	if (m_project -> isReadOnly())
+        return;
+	if (!m_diagram_ids.values().contains(diagram_view))
+        return;
 
-	// verifie que le schema est bien present dans le projet
-	if (!m_diagram_ids.values().contains(diagram_view)) return;
 
-
-	//Ask confirmation to user.
+        //Ask confirmation to user.
 	int answer = QET::QetMessageBox::question(
 		this,
 		tr("Supprimer le folio ?", "message box title"),
@@ -429,21 +432,20 @@
 		return;
 	}
 
-	// enleve le DiagramView des onglets
-	int diagram_tab_id = m_diagram_ids.key(diagram_view);
-	m_tab -> removeTab(diagram_tab_id);
+        //Remove the diagram view of the tabs widget
+	int index_to_remove = m_diagram_ids.key(diagram_view);
+	m_tab->removeTab(index_to_remove);
 	m_diagram_view_list.removeAll(diagram_view);
 	rebuildDiagramsMap();
-
-	// supprime le DiagramView, puis le Diagram
+    
 	m_project -> removeDiagram(diagram_view -> diagram());
 	delete diagram_view;
 
-	// signale le retrait du schema
 	emit(diagramRemoved(diagram_view));
 
-	// rend definitif le retrait du schema
+        //Make definitve the withdrawal
 	m_project -> write();
+    updateAllTabsTitle();
 }
 
 /**
@@ -899,27 +901,27 @@
  */
 void ProjectView::updateTabTitle(DiagramView *diagram_view)
 {
-	int diagram_tab_id = m_diagram_ids.key(diagram_view, -1);
-	
-	if (diagram_tab_id != -1)
-	{
-		QSettings settings;
-		QString title;
-		Diagram *diagram = diagram_view->diagram();
-		
-		if (settings.value("genericpanel/folio", false).toBool())
-		{
-			QString formula = diagram->border_and_titleblock.folio();
-			autonum::sequentialNumbers seq;
-			title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
-		}
-		else
-			title = QString::number(diagram->folioIndex() + 1);
-		
-		title += " - ";
-		title += diagram->title();
-		m_tab->setTabText(diagram_tab_id ,title);
-	}
+    int diagram_tab_id = m_diagram_ids.key(diagram_view, -1);
+    
+    if (diagram_tab_id != -1)
+    {
+        QSettings settings;
+        QString title;
+        Diagram *diagram = diagram_view->diagram();
+        
+        if (settings.value("genericpanel/folio", false).toBool())
+        {
+            QString formula = diagram->border_and_titleblock.folio();
+            autonum::sequentialNumbers seq;
+            title = autonum::AssignVariables::formulaToLabel(formula, seq, diagram);
+        }
+        else
+            title = QString::number(diagram->folioIndex() + 1);
+        
+        title += " - ";
+        title += diagram->title();
+        m_tab->setTabText(diagram_tab_id ,title);
+    }
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2017-06-14 13:32:52 UTC (rev 4979)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2017-06-20 19:15:39 UTC (rev 4980)
@@ -91,6 +91,7 @@
 		m_formula = diagram()->project()->defaultReportProperties();
 		setConnectionForFormula(m_formula);
 		connect(diagram()->project(), &QETProject::reportPropertiesChanged, this, &ReportElement::reportPropertiesChange);
+        connect(diagram()->project(), &QETProject::diagramRemoved, this, &ReportElement::updateLabel);
 		
 		if (elmt->terminals().size())
 		{
@@ -124,6 +125,7 @@
 	{
 		removeConnectionForFormula(m_formula);
 		disconnect(diagram()->project(), &QETProject::reportPropertiesChanged, this, &ReportElement::reportPropertiesChange);
+        disconnect(diagram()->project(), &QETProject::diagramRemoved, this, &ReportElement::updateLabel);
 		
 		if (elmt->terminals().size())
 		{


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