From d22df0b353c278187dfb3d6eb92ed7a81d0dcaac Mon Sep 17 00:00:00 2001 From: scorpio810 Date: Fri, 22 Mar 2013 23:17:39 +0000 Subject: [PATCH] Add a new property to automatically detect HTML markup and display rich text in a text field . git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2066 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/diagramcommands.cpp | 4 ++-- sources/diagramtextitem.cpp | 6 +++--- sources/independenttextitem.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sources/diagramcommands.cpp b/sources/diagramcommands.cpp index c0818823c..e8d8df4df 100644 --- a/sources/diagramcommands.cpp +++ b/sources/diagramcommands.cpp @@ -557,7 +557,7 @@ ChangeDiagramTextCommand::~ChangeDiagramTextCommand() { /// annule la modification de texte void ChangeDiagramTextCommand::undo() { - text_item -> setPlainText(text_before); + text_item -> setHtml(text_before); } /// refait la modification de texte @@ -565,7 +565,7 @@ void ChangeDiagramTextCommand::redo() { if (first_redo) { first_redo = false; } else { - text_item -> setPlainText(text_after); + text_item -> setHtml(text_after); } } diff --git a/sources/diagramtextitem.cpp b/sources/diagramtextitem.cpp index e1a8fe612..bce824339 100644 --- a/sources/diagramtextitem.cpp +++ b/sources/diagramtextitem.cpp @@ -202,7 +202,7 @@ void DiagramTextItem::focusInEvent(QFocusEvent *e) { setFlag(QGraphicsItem::ItemIsMovable, false); // memorise le texte avant que l'utilisateur n'y touche - previous_text_ = toPlainText(); + previous_text_ = toHtml(); // cela permettra de determiner si l'utilisateur a modifie le texte a la fin de l'edition } @@ -215,8 +215,8 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *e) { // signale la modification du texte si besoin if (toPlainText() != previous_text_) { - emit(diagramTextChanged(this, previous_text_, toPlainText())); - previous_text_ = toPlainText(); + emit(diagramTextChanged(this, previous_text_, toHtml())); + previous_text_ = toHtml(); } // deselectionne le texte diff --git a/sources/independenttextitem.cpp b/sources/independenttextitem.cpp index b7ee936a6..36b2f87ca 100644 --- a/sources/independenttextitem.cpp +++ b/sources/independenttextitem.cpp @@ -51,7 +51,7 @@ IndependentTextItem::~IndependentTextItem() { */ void IndependentTextItem::fromXml(const QDomElement &e) { setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble()); - setPlainText(e.attribute("text")); + setHtml(e.attribute("text")); setRotationAngle(e.attribute("rotation").toDouble()); } @@ -63,7 +63,7 @@ QDomElement IndependentTextItem::toXml(QDomDocument &document) const { QDomElement result = document.createElement("input"); result.setAttribute("x", QString("%1").arg(pos().x())); result.setAttribute("y", QString("%1").arg(pos().y())); - result.setAttribute("text", toPlainText()); + result.setAttribute("text", toHtml()); if (rotationAngle()) { result.setAttribute("rotation", QString("%1").arg(rotationAngle())); }