[qet] [4599] Copy/Paste now works with Element Label Variables

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


Revision: 4599
Author:   dfochi
Date:     2016-07-31 03:30:42 +0200 (Sun, 31 Jul 2016)
Log Message:
-----------
Copy/Paste now works with Element Label Variables

Modified Paths:
--------------
    trunk/sources/diagram.h
    trunk/sources/diagramcommands.cpp
    trunk/sources/diagramview.cpp
    trunk/sources/qetgraphicsitem/customelement.cpp
    trunk/sources/qetgraphicsitem/element.cpp

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2016-07-30 13:36:24 UTC (rev 4598)
+++ trunk/sources/diagram.h	2016-07-31 01:30:42 UTC (rev 4599)
@@ -87,6 +87,7 @@
 		QHash <QString, QStringList> m_elmt_unitfolio_max;
 		QHash <QString, QStringList> m_elmt_tenfolio_max;
 		QHash <QString, QStringList> m_elmt_hundredfolio_max;
+		bool item_paste;
 
 	private:
 		QGraphicsLineItem *conductor_setter_;

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2016-07-30 13:36:24 UTC (rev 4598)
+++ trunk/sources/diagramcommands.cpp	2016-07-31 01:30:42 UTC (rev 4599)
@@ -212,8 +212,11 @@
 		}
 	}
 	else {
-		foreach (QGraphicsItem *item, content.items(filter))
+		foreach (QGraphicsItem *item, content.items(filter)) {
+			diagram->item_paste = true;
 			diagram->addItem(item);
+			diagram->item_paste = false;
+		}
 	}
 
 	foreach (QGraphicsItem *qgi, content.items())

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2016-07-30 13:36:24 UTC (rev 4598)
+++ trunk/sources/diagramview.cpp	2016-07-31 01:30:42 UTC (rev 4599)
@@ -82,6 +82,7 @@
 	setSelectionMode();
 	adjustSceneRect();
 	updateWindowTitle();
+	scene->loadElmtFolioSeq();
 
 	context_menu = new QMenu(this);
 	paste_here = new QAction(QET::Icons::EditPaste, tr("Coller ici", "context menu action"), this);
@@ -432,6 +433,7 @@
 
 	// objet pour recuperer le contenu ajoute au schema par le coller
 	DiagramContent content_pasted;
+	this->diagram()->item_paste = true;
 	scene -> fromXml(document_xml, pos, false, &content_pasted);
 
 	// si quelque chose a effectivement ete ajoute au schema, on cree un objet d'annulation
@@ -440,6 +442,7 @@
 		scene -> undoStack().push(new PasteDiagramCommand(scene, content_pasted));
 		adjustSceneRect();
 	}
+	this->diagram()->item_paste = false;
 }
 
 /**

Modified: trunk/sources/qetgraphicsitem/customelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/customelement.cpp	2016-07-30 13:36:24 UTC (rev 4598)
+++ trunk/sources/qetgraphicsitem/customelement.cpp	2016-07-31 01:30:42 UTC (rev 4599)
@@ -336,10 +336,13 @@
 				rxml.readNext();
 		}
 	}
-	//apply formula to specific label
+	//apply formula to specific label - This condition specify elements which have different labels e.g KM
+	//that are already specified in the element label (inside .elmt file). This method is not called if elements
+	//are being loaded at first time or being pasted
 	else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) &&
 			 (!location().project()->elementAutoNumFormula().isEmpty()) &&
-			 (this->linkType()!=Element::Slave) && (this->linkType()!=Element::Terminale)) {
+			 (this->linkType()!=Element::Slave) && (this->linkType()!=Element::Terminale) &&
+			 !this->diagram()->item_paste) {
 		QString formula = location().project()->elementAutoNumFormula();
 		DiagramContext &dc = this->rElementInformations();
 		QString prefix = this->taggedText("label")->toPlainText();

Modified: trunk/sources/qetgraphicsitem/element.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/element.cpp	2016-07-30 13:36:24 UTC (rev 4598)
+++ trunk/sources/qetgraphicsitem/element.cpp	2016-07-31 01:30:42 UTC (rev 4599)
@@ -759,8 +759,6 @@
 	label.replace("%id", QString::number(elmt->diagram()->folioIndex()+1));
 	label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal()));
 	label.replace("%prefix", elmt->getPrefix());
-	if (label.contains("%prefix"))
-		label.replace("%prefix",this->getPrefix());
 	label = assignSeq(label);
 	return label;
 }


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