forked from qt-creator/qt-creator
Debugger: Avoid Gui dependency of dumper autotest
Change-Id: Ie51554216ad7b132839c2779c2f647ad6222db5f Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
#include "watchutils.h"
|
||||
#include "debuggerprotocol.h"
|
||||
|
||||
#include <QTextDocument> // Qt::escape() in Qt 4
|
||||
#include <QDebug>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@@ -338,11 +337,36 @@ QString WatchData::toString() const
|
||||
return res + QLatin1Char('}');
|
||||
}
|
||||
|
||||
static QString htmlEscape(const QString &plain)
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
return Qt::escape(plain);
|
||||
#else
|
||||
// Copied from Qt to avoid GUI dependency
|
||||
// (Qt::escape has been moved in Qt 5)
|
||||
QString rich;
|
||||
rich.reserve(int(plain.length() * qreal(1.1)));
|
||||
for (int i = 0; i < plain.length(); ++i) {
|
||||
if (plain.at(i) == QLatin1Char('<'))
|
||||
rich += QLatin1String("<");
|
||||
else if (plain.at(i) == QLatin1Char('>'))
|
||||
rich += QLatin1String(">");
|
||||
else if (plain.at(i) == QLatin1Char('&'))
|
||||
rich += QLatin1String("&");
|
||||
else if (plain.at(i) == QLatin1Char('"'))
|
||||
rich += QLatin1String(""");
|
||||
else
|
||||
rich += plain.at(i);
|
||||
}
|
||||
return rich;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Format a tooltip fow with aligned colon.
|
||||
static void formatToolTipRow(QTextStream &str,
|
||||
const QString &category, const QString &value)
|
||||
{
|
||||
QString val = Qt::escape(value);
|
||||
QString val = htmlEscape(value);
|
||||
val.replace(QLatin1Char('\n'), QLatin1String("<br>"));
|
||||
str << "<tr><td>" << category << "</td><td> : </td><td>"
|
||||
<< val << "</td></tr>";
|
||||
|
||||
Reference in New Issue
Block a user