From f2805afa0afa19718584e5da273e16f66650ec71 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 18 Nov 2024 01:36:39 +0000 Subject: [PATCH] cleanup: Use raw strings to simplify regexes. clang-tidy: modernize-raw-string-literal. --- src/model/message.cpp | 2 +- src/widget/form/settings/aboutform.cpp | 3 +-- src/widget/form/tabcompleter.cpp | 4 ++-- src/widget/tool/croppinglabel.cpp | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/model/message.cpp b/src/model/message.cpp index 3875b437be..74047174ef 100644 --- a/src/model/message.cpp +++ b/src/model/message.cpp @@ -44,7 +44,7 @@ QStringList splitMessage(const QString& message, uint64_t maxLength) void MessageProcessor::SharedParams::onUserNameSet(const QString& username) { QString sanename = username; - sanename.remove(QRegularExpression("[\\t\\n\\v\\f\\r\\x0000]")); + sanename.remove(QRegularExpression(R"([\t\n\v\f\r\x0000])")); nameMention = QRegularExpression("\\b" + QRegularExpression::escape(username) + "\\b", QRegularExpression::CaseInsensitiveOption); sanitizedNameMention = QRegularExpression("\\b" + QRegularExpression::escape(sanename) + "\\b", diff --git a/src/widget/form/settings/aboutform.cpp b/src/widget/form/settings/aboutform.cpp index 692f8ab762..eb116b7f74 100644 --- a/src/widget/form/settings/aboutform.cpp +++ b/src/widget/form/settings/aboutform.cpp @@ -205,8 +205,7 @@ void AboutForm::onUnstableVersion() */ QString AboutForm::createLink(QString path, QString text) const { - return QString::fromUtf8( - "%3") + return QString::fromUtf8(R"(%3)") .arg(path, style.getColor(Style::ColorPalette::Link).name(), text); } diff --git a/src/widget/form/tabcompleter.cpp b/src/widget/form/tabcompleter.cpp index 97b3c48a91..445230a03b 100644 --- a/src/widget/form/tabcompleter.cpp +++ b/src/widget/form/tabcompleter.cpp @@ -50,9 +50,9 @@ void TabCompleter::buildCompletionList() // section QString tabAbbrev = msgEdit->toPlainText() .left(msgEdit->textCursor().position()) - .section(QRegularExpression("[^\\w\\d\\$:@--_\\[\\]{}|`^.\\\\]"), -1, -1); + .section(QRegularExpression(R"([^\w\d\$:@--_\[\]{}|`^.\\])"), -1, -1); // that section is then used as the completion regex - QRegularExpression regex(QString("^[-_\\[\\]{}|`^.\\\\]*").append(QRegularExpression::escape(tabAbbrev)), + QRegularExpression regex(QString(R"(^[-_\[\]{}|`^.\\]*)").append(QRegularExpression::escape(tabAbbrev)), QRegularExpression::CaseInsensitiveOption); const QString ownNick = group->getSelfName(); diff --git a/src/widget/tool/croppinglabel.cpp b/src/widget/tool/croppinglabel.cpp index 625081d800..a9881725e0 100644 --- a/src/widget/tool/croppinglabel.cpp +++ b/src/widget/tool/croppinglabel.cpp @@ -164,8 +164,7 @@ void CroppingLabel::minimizeMaximumWidth() void CroppingLabel::editingFinished() { hideTextEdit(); - QString newText = - textEdit->text().trimmed().remove(QRegularExpression("[\\t\\n\\v\\f\\r\\x0000]")); + QString newText = textEdit->text().trimmed().remove(QRegularExpression(R"([\t\n\v\f\r\x0000])")); if (origText != newText) emit editFinished(textEdit->text());