[qet] [3393] Past command: reset some info about the pasted element (label, comment, and text of report)

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


Revision: 3393
Author:   blacksun
Date:     2014-10-23 10:05:53 +0200 (Thu, 23 Oct 2014)
Log Message:
-----------
Past command: reset some info about the pasted element (label, comment, and text of report)

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

Modified: trunk/sources/diagramcommands.cpp
===================================================================
--- trunk/sources/diagramcommands.cpp	2014-10-22 11:26:07 UTC (rev 3392)
+++ trunk/sources/diagramcommands.cpp	2014-10-23 08:05:53 UTC (rev 3393)
@@ -196,14 +196,33 @@
 	foreach(QGraphicsItem *qgi, content.items(DiagramContent::Images | DiagramContent::Shapes)) diagram -> removeItem(qgi);
 }
 
-/// refait le coller
+/**
+ * @brief PasteDiagramCommand::redo
+ */
 void PasteDiagramCommand::redo() {
 	diagram -> showMe();
+
 	if (first_redo) {
 		first_redo = false;
-		//this is the first paste, we make new uuid for each element
-		//because old uuid are the uuid of the copied element
-		foreach(Element *e, content.elements) e->newUuid();
+
+		//this is the first paste, we do some actions for the new element
+		foreach(Element *e, content.elements) {
+			//make new uuid, because old uuid are the uuid of the copied element
+			e -> newUuid();
+
+			//Reset the text of report element
+			if (e -> linkType() & Element::AllReport) {
+				if (e->texts().size())
+					e->texts().first()->setPlainText("/");
+			} else {
+				//Reset the information about the label and the comment
+				e -> rElementInformations().addValue("label", "");
+				e -> rElementInformations().addValue("comment", "");
+
+				//Reset the text field tagged "label
+				e -> taggedText("label") -> setPlainText("_");
+			}
+		}
 	}
 	else {
 		// paste the elements

Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h	2014-10-22 11:26:07 UTC (rev 3392)
+++ trunk/sources/qetgraphicsitem/element.h	2014-10-23 08:05:53 UTC (rev 3393)
@@ -113,27 +113,28 @@
 	virtual int linkType() const {return link_type_;} // @return the linkable type
 	void newUuid() {uuid_ = QUuid::createUuid();} 	//create new uuid for this element
 
-		//ATTRIBUTES related to linked element
-		protected:
-	QList <Element *> connected_elements;
-	QList <QUuid> tmp_uuids_link;
-	QUuid uuid_;
-	kind link_type_;
+	//ATTRIBUTES related to linked element
+	protected:
+		QList <Element *> connected_elements;
+		QList <QUuid> tmp_uuids_link;
+		QUuid uuid_;
+		kind link_type_;
 
-		signals:
-	void elementInfoChange(DiagramContext);
+	signals:
+		void elementInfoChange(DiagramContext);
 
-		//METHODS related to information
-		public:
-	DiagramContext elementInformations()const {return element_informations_;}
-	virtual void setElementInformations(DiagramContext dc);
-	DiagramContext kindInformations() const {return kind_informations_;}	//@kind_information_ is used to store more information
-																			//about the herited class like contactelement for know
-																			// kind of contact (simple tempo) or number of contact show by the element.
+	//METHODS related to information
+	public:
+		DiagramContext  elementInformations    ()const              {return element_informations_;}
+		DiagramContext& rElementInformations   ()                   {return element_informations_;}
+		virtual void    setElementInformations (DiagramContext dc);
+		DiagramContext  kindInformations       () const             {return kind_informations_;}	//@kind_information_ is used to store more information
+																									//about the herited class like contactelement for know
+																									// kind of contact (simple tempo) or number of contact show by the element.
 
-		//ATTRIBUTES
-		protected:
-	DiagramContext element_informations_, kind_informations_;
+	//ATTRIBUTES
+	protected:
+		DiagramContext element_informations_, kind_informations_;
 
 	/**
 		Draw this element


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