[qet] [2424] Fix merge

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


Revision: 2424
Author:   scorpio810
Date:     2013-08-13 10:32:25 +0200 (Tue, 13 Aug 2013)
Log Message:
-----------
Fix merge

Modified Paths:
--------------
    branches/0.4/sources/editor/elementscene.cpp
    branches/0.4/sources/editor/elementscene.h
    branches/0.4/sources/editor/qetelementeditor.cpp

Modified: branches/0.4/sources/editor/elementscene.cpp
===================================================================
--- branches/0.4/sources/editor/elementscene.cpp	2013-08-13 08:07:16 UTC (rev 2423)
+++ branches/0.4/sources/editor/elementscene.cpp	2013-08-13 08:32:25 UTC (rev 2424)
@@ -386,16 +386,27 @@
 	@return un document XML decrivant l'element
 */
 const QDomDocument ElementScene::toXml(bool all_parts) const {
+	//define the size of the element by the upper multiple of 10
+	QRectF size= elementSceneGeometricRect();
+	int upwidth = ((qRound(size.width())/10)*10)+10;
+	if ((qRound(size.width())%10) > 6) upwidth+=10;
+
+	int upheight = ((qRound(size.height())/10)*10)+10;
+	if ((qRound(size.height())%10) > 6) upheight+=10;
+
+	//the margin between the real size of the element and the rectangle that delimits
+	int xmargin = qRound(upwidth - size.width());
+	int ymargin = qRound(upheight - size.height());
+
 	// document XML
 	QDomDocument xml_document;
-	
 	// racine du document XML
 	QDomElement root = xml_document.createElement("definition");
 	root.setAttribute("type",        "element");
-	root.setAttribute("width",       QString("%1").arg(_width  * 10));
-	root.setAttribute("height",      QString("%1").arg(_height * 10));
-	root.setAttribute("hotspot_x",   QString("%1").arg(_hotspot.x()));
-	root.setAttribute("hotspot_y",   QString("%1").arg(_hotspot.y()));
+	root.setAttribute("width",       QString("%1").arg(upwidth));
+	root.setAttribute("height",      QString("%1").arg(upheight));
+	root.setAttribute("hotspot_x",   QString("%1").arg(-(qRound(size.x() - (xmargin/2)))));
+	root.setAttribute("hotspot_y",   QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
 	root.setAttribute("orientation", ori.toString());
 	root.setAttribute("version", QET::version);
 	if (internal_connections) root.setAttribute("ic", "true");
@@ -486,6 +497,23 @@
 }
 
 /**
+	@return the minimum, margin-less rectangle the element can fit into, in scene
+	coordinates. It is different from itemsBoundingRect() because it is not supposed
+	to imply any margin.
+*/
+QRectF ElementScene::elementSceneGeometricRect() const{
+	QRectF esgr;
+	foreach (QGraphicsItem *qgi, items()) {
+		if (qgi -> type() == ElementPrimitiveDecorator::Type) continue;
+		if (qgi -> type() == QGraphicsRectItem::Type) continue;
+		if (CustomElementPart *cep = dynamic_cast <CustomElementPart*> (qgi)) {
+			esgr |= cep -> sceneGeometricRect();
+		}
+	}
+	return (esgr);
+}
+
+/**
 	@return true si l'element comporte au moins une borne, false s'il n'en a
 	aucune.
 */
@@ -895,11 +923,13 @@
 void ElementScene::reset() {
 	// supprime les objets d'annulation
 	undoStack().clear();
+
 	// enleve les elements de la scene
-	foreach (QGraphicsItem *qgi, items()) {
+	foreach (QGraphicsItem *qgi, items()) {	
 		removeItem(qgi);
 		qgiManager().release(qgi);
 	}
+	decorator_ = 0;
 }
 
 /**

Modified: branches/0.4/sources/editor/elementscene.h
===================================================================
--- branches/0.4/sources/editor/elementscene.h	2013-08-13 08:07:16 UTC (rev 2423)
+++ branches/0.4/sources/editor/elementscene.h	2013-08-13 08:32:25 UTC (rev 2424)
@@ -129,6 +129,7 @@
 	virtual QList<QGraphicsItem *> zItems(ItemOptions options = ItemOptions(SortByZValue | IncludeTerminals | SelectedOrNot)) const;
 	virtual ElementContent selectedContent() const;
 	virtual void getPasteArea(const QRectF &);
+	QRectF elementSceneGeometricRect () const;
 	bool containsTerminals() const;
 	QUndoStack &undoStack();
 	QGIManager &qgiManager();

Modified: branches/0.4/sources/editor/qetelementeditor.cpp
===================================================================
--- branches/0.4/sources/editor/qetelementeditor.cpp	2013-08-13 08:07:16 UTC (rev 2423)
+++ branches/0.4/sources/editor/qetelementeditor.cpp	2013-08-13 08:32:25 UTC (rev 2424)
@@ -443,10 +443,7 @@
 	paste_in_area   -> setEnabled(clipboard_elmt);
 	
 	// actions dependant de l'etat de la pile d'annulation
-	save            -> setEnabled(!read_only && !ce_scene -> undoStack().isClean() && ce_scene -> borderContainsEveryParts());
-	save_as         -> setEnabled(ce_scene -> borderContainsEveryParts());
-	save_as_file    -> setEnabled(ce_scene -> borderContainsEveryParts());
-	//if (!ce_scene -> borderContainsEveryParts()) checkElement();
+	save            -> setEnabled(!read_only && !ce_scene -> undoStack().isClean());
 	undo            -> setEnabled(!read_only && ce_scene -> undoStack().canUndo());
 	redo            -> setEnabled(!read_only && ce_scene -> undoStack().canRedo());
 }
@@ -1031,10 +1028,6 @@
 */
 bool QETElementEditor::canClose() {
 	if (ce_scene -> undoStack().isClean()) return(true);
-	//verification avant d'enregistrer le fichier
-	if (!ce_scene -> borderContainsEveryParts()) checkElement();
-	// si le symbole deborde, echec de la fermeture
-	if (!ce_scene -> borderContainsEveryParts()) return(false);
 	// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
 	QMessageBox::StandardButton answer = QET::MessageBox::question(
 		this,


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