make util strip util functions non-static and move definition to cpp file

This commit is contained in:
targetakhil 2021-04-18 12:03:25 +05:30
parent 2dfa40e017
commit 5a5aba662e
2 changed files with 22 additions and 16 deletions

View File

@ -52,6 +52,24 @@ createDescriptionInfo(const Event &event, const QString &localUser, const QStrin
ts};
}
void
utils::stripReplyFromBody(QString &body)
{
QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption);
while (body.startsWith(">"))
body.remove(plainQuote);
if (body.startsWith("\n"))
body.remove(0, 1);
}
void
utils::stripReplyFromFormattedBody(QString &formatted_body)
{
formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>",
QRegularExpression::DotMatchesEverythingOption));
formatted_body.replace("@room", "@\u2060aroom");
}
RelatedInfo
utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_)
{

View File

@ -42,24 +42,12 @@ namespace utils {
using TimelineEvent = mtx::events::collections::TimelineEvents;
//! Helper function to remove reply fallback from body
static void
stripReplyFromBody(QString &body)
{
QRegularExpression plainQuote("^>.*?$\n?", QRegularExpression::MultilineOption);
while (body.startsWith(">"))
body.remove(plainQuote);
if (body.startsWith("\n"))
body.remove(0, 1);
}
void
stripReplyFromBody(QString &body);
//! Helper function to remove reply fallback from formatted body
static void
stripReplyFromFormattedBody(QString &formatted_body)
{
formatted_body.remove(QRegularExpression("<mx-reply>.*</mx-reply>",
QRegularExpression::DotMatchesEverythingOption));
formatted_body.replace("@room", "@\u2060aroom");
}
void
stripReplyFromFormattedBody(QString &formatted_body);
RelatedInfo
stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_);