Added Forum reply with plaintext quote (by anmo)

This commit is contained in:
defnax 2015-11-19 12:05:52 +01:00
parent e3d12b8194
commit 5404cda302
6 changed files with 127 additions and 5 deletions

View file

@ -24,6 +24,7 @@
#include <QtXml>
#include <QBuffer>
#include <QMessageBox>
#include <QTextDocumentFragment>
#include <qmath.h>
#include "HandleRichText.h"
@ -997,3 +998,15 @@ QString RsHtml::plainText(const std::string &text)
return Qt::escape(QString::fromUtf8(text.c_str()));
#endif
}
QString RsHtml::makeQuotedText(RSTextBrowser *browser)
{
QString text = browser->textCursor().selection().toPlainText();
if(text.length() == 0)
{
text = browser->toPlainText();
}
QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
text = sl.join("\n>");
return QString(">") + text;
}

View file

@ -19,6 +19,8 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <gui/common/RSTextBrowser.h>
/**
* This file provides helper functions and functors for translating data from/to
* rich text format and HTML. Its main goal is to facilitate decoding of chat
@ -72,6 +74,8 @@ public:
static QString plainText(const QString &text);
static QString plainText(const std::string &text);
static QString makeQuotedText(RSTextBrowser* browser);
protected:
void embedHtml(QTextDocument *textDocument, QDomDocument &doc, QDomElement &currentElement, EmbedInHtml& embedInfos, ulong flag);
void replaceAnchorWithImg(QDomDocument& doc, QDomElement &element, QTextDocument *textDocument, const RetroShareLink &link);