aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-11-11 10:13:25 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2011-12-23 12:07:23 +0100
commite0734571912736356839fde75fd10993b0df81d5 (patch)
treed8507706ef7131954cacf74993a4c31fca225381 /src/qt/guiutil.cpp
parentc75abc9f7e84dd16c9f748802fd82ab2c49ec558 (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.cpp16
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);
+}