1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Text: toHtmlChars

This commit is contained in:
krepa098 2014-12-31 09:59:35 +01:00
parent 3190530686
commit 7a4af239b0
2 changed files with 12 additions and 0 deletions

View File

@ -286,3 +286,14 @@ void Text::detectAnchors()
offset += htmledUrl.length(); offset += htmledUrl.length();
} }
} }
QString Text::toHtmlChars(const QString &str)
{
static QList<QPair<QString, QString>> replaceList = {{"&","&amp;"}, {">","&gt;"}, {"<","&lt;"}};
QString res = str;
for (auto &it : replaceList)
res = res.replace(it.first,it.second);
return res;
}

View File

@ -62,6 +62,7 @@ protected:
int cursorFromPos(QPointF scenePos) const; int cursorFromPos(QPointF scenePos) const;
void detectAnchors(); void detectAnchors();
QString toHtmlChars(const QString& str);
private: private:
CustomTextDocument* doc = nullptr; CustomTextDocument* doc = nullptr;