Suppression de l'attribut public previous_text de la classe DiagramTextItem

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@964 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2010-04-23 22:39:59 +00:00
parent 582232874a
commit 1ea20a4ec4
7 changed files with 23 additions and 16 deletions

View File

@@ -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

View File

@@ -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());
}

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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_;
};

View File

@@ -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);

View File

@@ -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());
}