|
|
@ -159,12 +159,7 @@ QString Utils::String::fromStdString(const std::string &str) |
|
|
|
|
|
|
|
|
|
|
|
std::string Utils::String::toStdString(const QString &str) |
|
|
|
std::string Utils::String::toStdString(const QString &str) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef QBT_USES_QT5 |
|
|
|
|
|
|
|
return str.toStdString(); |
|
|
|
return str.toStdString(); |
|
|
|
#else |
|
|
|
|
|
|
|
QByteArray utf8 = str.toUtf8(); |
|
|
|
|
|
|
|
return std::string(utf8.constData(), utf8.length()); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// to send numbers instead of strings with suffixes
|
|
|
|
// to send numbers instead of strings with suffixes
|
|
|
@ -196,26 +191,5 @@ bool Utils::String::slowEquals(const QByteArray &a, const QByteArray &b) |
|
|
|
|
|
|
|
|
|
|
|
QString Utils::String::toHtmlEscaped(const QString &str) |
|
|
|
QString Utils::String::toHtmlEscaped(const QString &str) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef QBT_USES_QT5 |
|
|
|
|
|
|
|
return str.toHtmlEscaped(); |
|
|
|
return str.toHtmlEscaped(); |
|
|
|
#else |
|
|
|
|
|
|
|
// code from Qt
|
|
|
|
|
|
|
|
QString rich; |
|
|
|
|
|
|
|
const int len = str.length(); |
|
|
|
|
|
|
|
rich.reserve(int(len * 1.1)); |
|
|
|
|
|
|
|
for (int i = 0; i < len; ++i) { |
|
|
|
|
|
|
|
if (str.at(i) == QLatin1Char('<')) |
|
|
|
|
|
|
|
rich += QLatin1String("<"); |
|
|
|
|
|
|
|
else if (str.at(i) == QLatin1Char('>')) |
|
|
|
|
|
|
|
rich += QLatin1String(">"); |
|
|
|
|
|
|
|
else if (str.at(i) == QLatin1Char('&')) |
|
|
|
|
|
|
|
rich += QLatin1String("&"); |
|
|
|
|
|
|
|
else if (str.at(i) == QLatin1Char('"')) |
|
|
|
|
|
|
|
rich += QLatin1String("""); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
rich += str.at(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
rich.squeeze(); |
|
|
|
|
|
|
|
return rich; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|