From 0269c97e7a5c1d76612543bf09000febda9777af Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 14 Sep 2024 19:00:16 +0500 Subject: [PATCH] UI: ConnBlockListModel: QT_TR_NOOP inside class --- src/ui/model/connblocklistmodel.cpp | 45 ++++++++++++++--------------- src/ui/model/connblocklistmodel.h | 3 ++ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/ui/model/connblocklistmodel.cpp b/src/ui/model/connblocklistmodel.cpp index 354a2554..ee18ddce 100644 --- a/src/ui/model/connblocklistmodel.cpp +++ b/src/ui/model/connblocklistmodel.cpp @@ -36,28 +36,6 @@ QString formatIpPort(const ip_addr_t &ip, quint16 port, bool isIPv6, bool resolv return address + ':' + QString::number(port); } -QString reasonText(const ConnRow &connRow) -{ - static const char *const blockReasonTexts[] = { - QT_TR_NOOP("Blocked Internet address"), - QT_TR_NOOP("Old connection closed on startup"), - QT_TR_NOOP("Programs logic"), - QT_TR_NOOP("App. Group logic"), - QT_TR_NOOP("Filter Mode logic"), - QT_TR_NOOP("Restrict access to LAN only"), - QT_TR_NOOP("Restrict access by Zone"), - QT_TR_NOOP("Limit of Ask to Connect"), - }; - - if (connRow.blockReason >= FORT_BLOCK_REASON_IP_INET - && connRow.blockReason <= FORT_BLOCK_REASON_ASK_LIMIT) { - const int index = connRow.blockReason - FORT_BLOCK_REASON_IP_INET; - return ConnBlockListModel::tr(blockReasonTexts[index]); - } - - return ConnBlockListModel::tr("Unknown"); -} - QString reasonIconPath(const ConnRow &connRow) { static const char *const blockReasonIcons[] = { @@ -122,7 +100,7 @@ QVariant dataDisplayDirection(const ConnRow &connRow, bool /*resolveAddress*/, i QVariant dataDisplayReason(const ConnRow &connRow, bool /*resolveAddress*/, int role) { if (role == Qt::ToolTipRole) { - return reasonText(connRow) + return ConnBlockListModel::blockReasonText(FortBlockReason(connRow.blockReason)) + (connRow.inherited ? " (" + ConnBlockListModel::tr("Inherited") + ")" : QString()); } @@ -460,3 +438,24 @@ void ConnBlockListModel::insertConnRows(qint64 idMax, int endRow, int count) invalidateRowCache(); endInsertRows(); } + +QString ConnBlockListModel::blockReasonText(FortBlockReason reason) +{ + static const char *const blockReasonTexts[] = { + QT_TR_NOOP("Blocked Internet address"), + QT_TR_NOOP("Old connection closed on startup"), + QT_TR_NOOP("Programs logic"), + QT_TR_NOOP("App. Group logic"), + QT_TR_NOOP("Filter Mode logic"), + QT_TR_NOOP("Restrict access to LAN only"), + QT_TR_NOOP("Restrict access by Zone"), + QT_TR_NOOP("Limit of Ask to Connect"), + }; + + if (reason >= FORT_BLOCK_REASON_IP_INET && reason <= FORT_BLOCK_REASON_ASK_LIMIT) { + const int index = reason - FORT_BLOCK_REASON_IP_INET; + return tr(blockReasonTexts[index]); + } + + return tr("Unknown"); +} diff --git a/src/ui/model/connblocklistmodel.h b/src/ui/model/connblocklistmodel.h index a7b0c755..6ae12f91 100644 --- a/src/ui/model/connblocklistmodel.h +++ b/src/ui/model/connblocklistmodel.h @@ -4,6 +4,7 @@ #include #include +#include #include class AppInfoCache; @@ -61,6 +62,8 @@ public: const ConnRow &connRowAt(int row) const; + static QString blockReasonText(FortBlockReason reason); + protected slots: void updateConnIdRange();