diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-11-11 10:13:25 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-12-23 12:07:23 +0100 |
commit | e0734571912736356839fde75fd10993b0df81d5 (patch) | |
tree | d8507706ef7131954cacf74993a4c31fca225381 /src/qt/guiutil.cpp | |
parent | c75abc9f7e84dd16c9f748802fd82ab2c49ec558 (diff) |
Move HtmlEscape (escape for qt rich text controls) to qt gui utilities
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r-- | src/qt/guiutil.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 158b84a285..f72fe1ef4b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -11,6 +11,7 @@ #include <QFont> #include <QLineEdit> #include <QUrl> +#include <QTextDocument> // For Qt::escape QString GUIUtil::dateTimeStr(qint64 nTime) { @@ -72,3 +73,18 @@ bool GUIUtil::parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out) } return true; } + +QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine) +{ + QString escaped = Qt::escape(str); + if(fMultiLine) + { + escaped = escaped.replace("\n", "<br>\n"); + } + return escaped; +} + +QString GUIUtil::HtmlEscape(const std::string& str, bool fMultiLine) +{ + return HtmlEscape(QString::fromStdString(str), fMultiLine); +} |