From 80a20b41a35a26afc31f98cde7d85e72869f956e Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 18 Jan 2012 23:00:50 +0000 Subject: [PATCH] Fixed message reply and forward. The new lines were removed falsely. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4815 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/chat/HandleRichText.cpp | 13 +++++++++++++ retroshare-gui/src/gui/chat/HandleRichText.h | 3 ++- retroshare-gui/src/gui/msgs/MessageComposer.cpp | 4 ++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/chat/HandleRichText.cpp b/retroshare-gui/src/gui/chat/HandleRichText.cpp index 2304f92c7..eed0f5583 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.cpp +++ b/retroshare-gui/src/gui/chat/HandleRichText.cpp @@ -269,4 +269,17 @@ void optimizeHtml(QTextEdit *textEdit, QString &text) std::cerr << "Optimized text to " << text.length() << " bytes , instead of " << textEdit->toHtml().length() << std::endl; } +QString toHtml(QString text, bool realHtml) +{ + // replace "\n" from the optimized html with "
" + text.replace("\n", "
"); + if (!realHtml) { + return text; + } + + QTextDocument doc; + doc.setHtml(text); + return doc.toHtml(); +} + } // namespace RsHtml diff --git a/retroshare-gui/src/gui/chat/HandleRichText.h b/retroshare-gui/src/gui/chat/HandleRichText.h index 174e6a4c3..dfe9ce6b2 100644 --- a/retroshare-gui/src/gui/chat/HandleRichText.h +++ b/retroshare-gui/src/gui/chat/HandleRichText.h @@ -113,7 +113,8 @@ extern EmbedInHtmlImg defEmbedImg; QString formatText(const QString &text, unsigned int flag); bool findAnchors(const QString &text, QStringList& urls); -void optimizeHtml(QTextEdit *textEdit, QString &text); +void optimizeHtml(QTextEdit *textEdit, QString &text); +QString toHtml(QString text, bool realHtml = true); } // namespace RsHtml diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 1a867104b..1a63ff7dc 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -1018,7 +1018,7 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all) msgComposer->insertTitleText(QString::fromStdWString(msgInfo.title), REPLY); QTextDocument doc ; - doc.setHtml(QString::fromStdWString(msgInfo.msg)); + doc.setHtml(RsHtml::toHtml(QString::fromStdWString(msgInfo.msg), false)); msgComposer->insertPastedText(doc.toPlainText()); msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false); @@ -1062,7 +1062,7 @@ MessageComposer *MessageComposer::forwardMsg(const std::string &msgId) msgComposer->insertTitleText(QString::fromStdWString(msgInfo.title), FORWARD); QTextDocument doc ; - doc.setHtml(QString::fromStdWString(msgInfo.msg)) ; + doc.setHtml(RsHtml::toHtml(QString::fromStdWString(msgInfo.msg), false)); msgComposer->insertForwardPastedText(doc.toPlainText());