[qet] [3875] Fix bug: scene rect was wrong when border propertie is same in code and config.

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


Revision: 3875
Author:   blacksun
Date:     2015-03-30 17:58:16 +0200 (Mon, 30 Mar 2015)
Log Message:
-----------
Fix bug: scene rect was wrong when border propertie is same in code and config.

Modified Paths:
--------------
    trunk/sources/bordertitleblock.cpp
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h

Modified: trunk/sources/bordertitleblock.cpp
===================================================================
--- trunk/sources/bordertitleblock.cpp	2015-03-30 14:51:04 UTC (rev 3874)
+++ trunk/sources/bordertitleblock.cpp	2015-03-30 15:58:16 UTC (rev 3875)
@@ -199,7 +199,6 @@
 	@param xml_elmt the XML element values will be read from
 */
 void BorderTitleBlock::borderFromXml(const QDomElement &xml_elmt) {
-	QRectF old_rect = diagram_rect_;
 	bool ok;
 	// columns count
 	int cols_count = xml_elmt.attribute("cols").toInt(&ok);
@@ -229,11 +228,6 @@
 	displayRows(xml_elmt.attribute("displayrows") != "false");
 
 	updateRectangles();
-
-		//We emit signal even if diagram_rect not change
-		//For calcul the scene rect when diagram load the first time the border.
-	if (old_rect == diagram_rect_)
-		emit(borderChanged(old_rect, old_rect));
 }
 
 /**

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2015-03-30 14:51:04 UTC (rev 3874)
+++ trunk/sources/diagram.cpp	2015-03-30 15:58:16 UTC (rev 3875)
@@ -74,11 +74,8 @@
 
 	connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
 	connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)),    this, SLOT(titleChanged(const QString &)));
-	connect(&border_and_titleblock, &BorderTitleBlock::borderChanged, [this]() {
-		QRectF old_rect = this->sceneRect();
-		this->setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(this->itemsBoundingRect()));
-		this->update(old_rect.united(this->sceneRect()));
-	});
+	connect(&border_and_titleblock, SIGNAL(borderChanged(QRectF,QRectF)), this, SLOT(adjustSceneRect()));
+	adjustSceneRect();
 }
 
 /**
@@ -805,7 +802,7 @@
 		content_ptr -> images			= added_images.toSet();
 		content_ptr -> shapes			= added_shapes.toSet();
 	}
-	
+	adjustSceneRect();
 	return(true);
 }
 
@@ -1187,6 +1184,17 @@
 }
 
 /**
+ * @brief Diagram::adjustSceneRect
+ * Recalcul and adjust the size of the scene
+ */
+void Diagram::adjustSceneRect()
+{
+	QRectF old_rect = sceneRect();
+	setSceneRect(border_and_titleblock.borderAndTitleBlockRect().united(itemsBoundingRect()));
+	update(old_rect.united(sceneRect()));
+}
+
+/**
 	Cette methode permet d'appliquer de nouvelles options de rendu tout en
 	accedant aux proprietes de rendu en cours.
 	@param new_properties Nouvelles options de rendu a appliquer

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2015-03-30 14:51:04 UTC (rev 3874)
+++ trunk/sources/diagram.h	2015-03-30 15:58:16 UTC (rev 3875)
@@ -208,16 +208,17 @@
 	QGIManager &qgiManager();
 	
 	public slots:
-	void titleChanged(const QString &);
-	void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
-	void titleBlockTemplateChanged(const QString &);
-	void titleBlockTemplateRemoved(const QString &, const QString & = QString());
-	void setTitleBlockTemplate(const QString &);
+		void adjustSceneRect ();
+		void titleChanged(const QString &);
+		void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
+		void titleBlockTemplateChanged(const QString &);
+		void titleBlockTemplateRemoved(const QString &, const QString & = QString());
+		void setTitleBlockTemplate(const QString &);
 	
-	// methods related to graphics items selection
-	void selectAll();
-	void deselectAll();
-	void invertSelection();
+		// methods related to graphics items selection
+		void selectAll();
+		void deselectAll();
+		void invertSelection();
 	
 	signals:
 		void showDiagram (Diagram *);


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