diff --git a/sources/conductor.cpp b/sources/conductor.cpp index 4f2d71693..664ae8ce7 100644 --- a/sources/conductor.cpp +++ b/sources/conductor.cpp @@ -1093,7 +1093,6 @@ void Conductor::saveProfile(bool undo) { 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 @@ QString Conductor::text() const { */ void Conductor::setText(const QString &t) { text_item -> setPlainText(t); - text_item -> previous_text = t; } /// @param p les proprietes de ce conducteur diff --git a/sources/conductortextitem.cpp b/sources/conductortextitem.cpp index 141beac9d..6d9b4a419 100644 --- a/sources/conductortextitem.cpp +++ b/sources/conductortextitem.cpp @@ -53,7 +53,6 @@ Conductor *ConductorTextItem::parentConductor() const { 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()); } diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index af3915d7a..76e250899 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -394,15 +394,14 @@ ChangeDiagramTextCommand::~ChangeDiagramTextCommand() { /// 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; } } diff --git a/sources/diagramtextitem.cpp b/sources/diagramtextitem.cpp index b6cac420f..4be308548 100644 --- a/sources/diagramtextitem.cpp +++ b/sources/diagramtextitem.cpp @@ -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(QGraphicsItem *parent, Diagram *parent_diagram) */ 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); @@ -109,15 +109,27 @@ QVariant DiagramTextItem::itemChange(GraphicsItemChange change, const QVariant & return(QGraphicsTextItem::itemChange(change, value)); } +/** + 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 diff --git a/sources/diagramtextitem.h b/sources/diagramtextitem.h index 12f6d4580..217977fed 100644 --- a/sources/diagramtextitem.h +++ b/sources/diagramtextitem.h @@ -35,8 +35,6 @@ class DiagramTextItem : public QGraphicsTextItem { // attributs public: enum { Type = UserType + 1004 }; - /// Texte precedent - QString previous_text; // methodes public: @@ -57,6 +55,7 @@ class DiagramTextItem : public QGraphicsTextItem { 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 @@ class DiagramTextItem : public QGraphicsTextItem { 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_; }; diff --git a/sources/elementtextitem.cpp b/sources/elementtextitem.cpp index 71a4da013..2564ea748 100644 --- a/sources/elementtextitem.cpp +++ b/sources/elementtextitem.cpp @@ -118,7 +118,6 @@ void ElementTextItem::fromXml(const QDomElement &e) { 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); diff --git a/sources/independenttextitem.cpp b/sources/independenttextitem.cpp index 1f77a63cd..c99168ccc 100644 --- a/sources/independenttextitem.cpp +++ b/sources/independenttextitem.cpp @@ -50,7 +50,6 @@ IndependentTextItem::~IndependentTextItem() { 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()); }