[qet] [964] Suppression de l' attribut public previous_text de la classe DiagramTextItem

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


Revision: 964
Author:   xavier
Date:     2010-04-24 00:39:59 +0200 (Sat, 24 Apr 2010)
Log Message:
-----------
Suppression de l'attribut public previous_text de la classe DiagramTextItem

Modified Paths:
--------------
    branches/0.3/sources/conductor.cpp
    branches/0.3/sources/conductortextitem.cpp
    branches/0.3/sources/diagramcommands.cpp
    branches/0.3/sources/diagramtextitem.cpp
    branches/0.3/sources/diagramtextitem.h
    branches/0.3/sources/elementtextitem.cpp
    branches/0.3/sources/independenttextitem.cpp

Modified: branches/0.3/sources/conductor.cpp
===================================================================
--- branches/0.3/sources/conductor.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/conductor.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -1093,7 +1093,6 @@
 	ConductorProfile old_profile(conductor_profiles[current_path_type]);
 	conductor_profiles[current_path_type].fromConductor(this);
 	Diagram *dia = diagram();
-	qDebug () << Q_FUNC_INFO << dia;
 	if (undo && dia) {
 		dia -> undoStack().push(new ChangeConductorCommand(this, old_profile, conductor_profiles[current_path_type], current_path_type));
 	}
@@ -1153,7 +1152,6 @@
 */
 void Conductor::setText(const QString &t) {
 	text_item -> setPlainText(t);
-	text_item -> previous_text = t;
 }
 
 /// @param p les proprietes de ce conducteur

Modified: branches/0.3/sources/conductortextitem.cpp
===================================================================
--- branches/0.3/sources/conductortextitem.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/conductortextitem.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -53,7 +53,6 @@
 void ConductorTextItem::fromXml(const QDomElement &e) {
 	setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
 	setPlainText(e.attribute("text"));
-	previous_text = e.attribute("text");
 	setRotationAngle(e.attribute("rotation").toDouble());
 }
 

Modified: branches/0.3/sources/diagramcommands.cpp
===================================================================
--- branches/0.3/sources/diagramcommands.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/diagramcommands.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -394,15 +394,14 @@
 /// annule la modification de texte
 void ChangeDiagramTextCommand::undo() {
 	text_item -> setPlainText(text_before);
-	text_item -> previous_text = text_before;
 }
 
 /// refait la modification de texte
 void ChangeDiagramTextCommand::redo() {
-	if (first_redo) first_redo = false;
-	else {
+	if (first_redo) {
+		first_redo = false;
+	} else {
 		text_item -> setPlainText(text_after);
-		text_item -> previous_text = text_after;
 	}
 }
 

Modified: branches/0.3/sources/diagramtextitem.cpp
===================================================================
--- branches/0.3/sources/diagramtextitem.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/diagramtextitem.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -27,8 +27,8 @@
 */
 DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
 	QGraphicsTextItem(parent, parent_diagram),
-	previous_text(),
 	parent_diagram_(parent_diagram),
+	previous_text_(),
 	rotation_angle_(0.0)
 {
 	setDefaultTextColor(Qt::black);
@@ -45,8 +45,8 @@
 */
 DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
 	QGraphicsTextItem(text, parent, parent_diagram),
-	previous_text(text),
 	parent_diagram_(parent_diagram),
+	previous_text_(text),
 	rotation_angle_(0.0)
 {
 	setDefaultTextColor(Qt::black);
@@ -110,14 +110,26 @@
 }
 
 /**
+	Gere la prise de focus du champ de texte
+*/
+void DiagramTextItem::focusInEvent(QFocusEvent *e) {
+	QGraphicsTextItem::focusInEvent(e);
+	
+	// memorise le texte avant que l'utilisateur n'y touche
+	previous_text_ = toPlainText();
+	// cela permettra de determiner si l'utilisateur a modifie le texte a la fin de l'edition
+}
+
+/**
 	Gere la perte de focus du champ de texte
 */
 void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
 	QGraphicsTextItem::focusOutEvent(e);
+	
 	// signale la modification du texte si besoin
-	if (toPlainText() != previous_text) {
-		emit(diagramTextChanged(this, previous_text, toPlainText()));
-		previous_text = toPlainText();
+	if (toPlainText() != previous_text_) {
+		emit(diagramTextChanged(this, previous_text_, toPlainText()));
+		previous_text_ = toPlainText();
 	}
 	
 	// deselectionne le texte

Modified: branches/0.3/sources/diagramtextitem.h
===================================================================
--- branches/0.3/sources/diagramtextitem.h	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/diagramtextitem.h	2010-04-23 22:39:59 UTC (rev 964)
@@ -35,8 +35,6 @@
 	// attributs
 	public:
 	enum { Type = UserType + 1004 };
-	/// Texte precedent
-	QString previous_text;
 	
 	// methodes
 	public:
@@ -57,6 +55,7 @@
 	
 	protected:
 	virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
+	virtual void focusInEvent(QFocusEvent *);
 	virtual void focusOutEvent(QFocusEvent *);
 	virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
 	virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
@@ -79,6 +78,8 @@
 	private:
 	/// Schema auquel ce texte est rattache
 	Diagram *parent_diagram_;
+	/// Texte precedent
+	QString previous_text_;
 	/// angle de rotation du champ de texte
 	qreal rotation_angle_;
 };

Modified: branches/0.3/sources/elementtextitem.cpp
===================================================================
--- branches/0.3/sources/elementtextitem.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/elementtextitem.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -118,7 +118,6 @@
 		qFuzzyCompare(qreal(e.attribute("y").toDouble()), _pos.y())
 	) {
 		setPlainText(e.attribute("text"));
-		previous_text = e.attribute("text");
 		qreal xml_rotation_angle;
 		if (QET::attributeIsAReal(e, "userrotation", &xml_rotation_angle)) {
 			setRotationAngle(xml_rotation_angle);

Modified: branches/0.3/sources/independenttextitem.cpp
===================================================================
--- branches/0.3/sources/independenttextitem.cpp	2010-04-20 14:48:01 UTC (rev 963)
+++ branches/0.3/sources/independenttextitem.cpp	2010-04-23 22:39:59 UTC (rev 964)
@@ -50,7 +50,6 @@
 void IndependentTextItem::fromXml(const QDomElement &e) {
 	setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
 	setPlainText(e.attribute("text"));
-	previous_text = e.attribute("text");
 	setRotationAngle(e.attribute("rotation").toDouble());
 }
 


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