summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-02-02 01:26:42 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2023-02-02 01:26:42 +0100
commit0ab566dc4bc16de87c9a90c2fb0efbff4ec117b2 (patch)
tree868cbdd64a101e8cb3954410704f94eb73ceeb9c
parentlint (diff)
downloadnheko-0ab566dc4bc16de87c9a90c2fb0efbff4ec117b2.tar.xz
lint and avoid copy
-rw-r--r--src/ChatPage.cpp2
-rw-r--r--src/Config.h82
-rw-r--r--src/notifications/ManagerLinux.cpp3
3 files changed, 44 insertions, 43 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index 7e35044a..1d0edb2a 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -1652,7 +1652,7 @@ ChatPage::isRoomActive(const QString &room_id) void ChatPage::removeAllNotifications() { -#if defined (Q_OS_LINUX) +#if defined(Q_OS_LINUX) notificationsManager->closeAllNotifications(); #endif } diff --git a/src/Config.h b/src/Config.h
index 24c763db..dcac02fe 100644 --- a/src/Config.h +++ b/src/Config.h
@@ -25,23 +25,22 @@ constexpr auto LABEL_MEDIUM_SIZE_RATIO = 1.3; namespace strings { const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>"); -const QRegularExpression - url_regex( - // match an unquoted URL - []() { - const auto general_unicode = QStringLiteral( - R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))"); - const auto protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))"); - const auto unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])"); - const auto pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))"); - const auto userinfo = "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc + - unreserved_subdelims_colon + "*)*)"; - const auto dec_octet = - QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))"); - const auto ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})"; - const auto h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))"); - const auto ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")"; - // clang-format off +const QRegularExpression url_regex( + // match an unquoted URL + []() { + const auto general_unicode = QStringLiteral( + R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))"); + const auto protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))"); + const auto unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])"); + const auto pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))"); + const auto userinfo = + "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc + unreserved_subdelims_colon + "*)*)"; + const auto dec_octet = + QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))"); + const auto ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})"; + const auto h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))"); + const auto ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")"; + // clang-format off const auto ipv6_addr = "(?:" "(?:" + h16 + ":){6}" + ls32 + "|" "::(?:" + h16 + ":){5}" + ls32 @@ -53,30 +52,31 @@ const QRegularExpression + "|" "(?:" + h16 + "(?::" + h16 + "){0,5})?::" + h16 + "|" "(?:" + h16 + "(?::" + h16 + "){0,6})?::" ")"; - // clang-format on - const auto ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)"; - const auto ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))"; - const auto host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")"; - const auto host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)"; - const auto hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))"; - const auto host = "(?:" + hostname + "|" + ip_literal + ")"; - const auto path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" + - general_unicode + ")*))"; - const auto query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc + - R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)"; - const auto &fragment = query; - return - R"((?<!["'\w])(?>()" - + protocol + "://" - + "(?:" + userinfo + "@)?" - + host + "(?::[0-9]+)?" - + path + "?" - R"((?:\?)" + query + ")?" - R"((?:#)" + fragment + ")?" - "(?<![.!?,;:'])" - R"())(?!["']))"; - }(), - QRegularExpression::UseUnicodePropertiesOption); + // clang-format on + const auto ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)"; + const auto ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))"; + const auto host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")"; + const auto host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)"; + const auto hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))"; + const auto host = "(?:" + hostname + "|" + ip_literal + ")"; + const auto path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" + + general_unicode + ")*))"; + const auto query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc + + R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)"; + const auto &fragment = query; + return R"((?<!["'\w])(?>()" + protocol + "://" + "(?:" + userinfo + "@)?" + host + + "(?::[0-9]+)?" + path + + "?" + R"((?:\?)" + + query + + ")?" + R"((?:#)" + + fragment + + ")?" + "(?<![.!?,;:'])" + R"())(?!["']))"; + }(), + QRegularExpression::UseUnicodePropertiesOption); // A matrix link to be converted back to markdown static const QRegularExpression matrixToLink(QStringLiteral(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)")); diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp
index c694d88f..45d5591c 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp
@@ -275,7 +275,8 @@ NotificationsManager::notificationClosed(uint id, uint reason) void NotificationsManager::closeAllNotifications() { - for (auto id : notificationIds.keys()) { + const auto ids = notificationIds.keys(); + for (const auto &id : ids) { closeNotification(id); notificationIds.remove(id); }