From 66795d533a7eb9bfcab2b74042f53b1e5c352173 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Oct 2022 00:09:43 +0800 Subject: [PATCH 1/5] Show 'N/A' when there is no hash This is to follow 'General' tab which show 'N/A' when there is no hash. --- src/gui/transferlistmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 96ef1c44a..05a3b2118 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -374,6 +374,13 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons : m_statusStrings[state]; }; + const auto hashString = [hideValues](const auto &hash) -> QString + { + if (hideValues && !hash.isValid()) + return {}; + return hash.isValid() ? hash.toString() : tr("N/A"); + }; + switch (column) { case TR_NAME: @@ -441,9 +448,9 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons case TR_TOTAL_SIZE: return unitString(torrent->totalSize()); case TR_INFOHASH_V1: - return torrent->infoHash().v1().toString(); + return hashString(torrent->infoHash().v1()); case TR_INFOHASH_V2: - return torrent->infoHash().v2().toString(); + return hashString(torrent->infoHash().v2()); } return {}; From aa022400f7f3a17e12751bb458afbe1bf22c9875 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Oct 2022 00:12:35 +0800 Subject: [PATCH 2/5] Use Path internal representation for internal value in model The internal value is used for sorting comparisons and not displayed to the user, so make a shortcut. --- src/gui/transferlistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 05a3b2118..d2d41e6dd 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -511,7 +511,7 @@ QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, co case TR_DOWNLOAD_PATH: return torrent->downloadPath().data(); case TR_SAVE_PATH: - return torrent->savePath().toString(); + return torrent->savePath().data(); case TR_COMPLETED: return torrent->completedSize(); case TR_RATIO_LIMIT: From d3936c07c7cd0e78103670af10789465ee0cbcc3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Oct 2022 00:16:00 +0800 Subject: [PATCH 3/5] Capitalize header title This is the only one not properly capitalized. --- src/gui/transferlistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index d2d41e6dd..e03d4f7a8 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -224,7 +224,7 @@ QVariant TransferListModel::headerData(const int section, const Qt::Orientation case TR_AMOUNT_UPLOADED_SESSION: return tr("Session Upload", "Amount of data uploaded since program open (e.g. in MB)"); case TR_AMOUNT_LEFT: return tr("Remaining", "Amount of data left to download (e.g. in MB)"); case TR_TIME_ELAPSED: return tr("Time Active", "Time (duration) the torrent is active (not paused)"); - case TR_SAVE_PATH: return tr("Save path", "Torrent save path"); + case TR_SAVE_PATH: return tr("Save Path", "Torrent save path"); case TR_DOWNLOAD_PATH: return tr("Incomplete Save Path", "Torrent incomplete save path"); case TR_COMPLETED: return tr("Completed", "Amount of data completed (e.g. in MB)"); case TR_RATIO_LIMIT: return tr("Ratio Limit", "Upload share ratio limit"); From 0279b80b46797e1f465c2d9f1a68237a280b6212 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 6 Oct 2022 02:36:48 +0800 Subject: [PATCH 4/5] Don't use hardcoded URL scheme list This is to avoid the list being outdated. --- src/gui/downloadfromurldialog.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/downloadfromurldialog.cpp b/src/gui/downloadfromurldialog.cpp index 56b8123a2..ca3f8eaa1 100644 --- a/src/gui/downloadfromurldialog.cpp +++ b/src/gui/downloadfromurldialog.cpp @@ -38,6 +38,7 @@ #include #include +#include "base/net/downloadmanager.h" #include "ui_downloadfromurldialog.h" #include "utils.h" @@ -47,16 +48,13 @@ namespace { bool isDownloadable(const QString &str) { - return (str.startsWith(u"http://", Qt::CaseInsensitive) - || str.startsWith(u"https://", Qt::CaseInsensitive) - || str.startsWith(u"ftp://", Qt::CaseInsensitive) + return (Net::DownloadManager::hasSupportedScheme(str) || str.startsWith(u"magnet:", Qt::CaseInsensitive) - || ((str.size() == 40) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v1 hex-encoded SHA-1 info-hash #ifdef QBT_USES_LIBTORRENT2 || ((str.size() == 64) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v2 hex-encoded SHA-256 info-hash #endif + || ((str.size() == 40) && !str.contains(QRegularExpression(u"[^0-9A-Fa-f]"_qs))) // v1 hex-encoded SHA-1 info-hash || ((str.size() == 32) && !str.contains(QRegularExpression(u"[^2-7A-Za-z]"_qs)))); // v1 Base32 encoded SHA-1 info-hash - } } From 7eb97348ded29a5bdb10fe18e4a964ed8d899c59 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 9 Oct 2022 15:24:30 +0800 Subject: [PATCH 5/5] GHA CI: add missing Qt module --- .github/workflows/coverity-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml index a83d9494e..180d49c29 100644 --- a/.github/workflows/coverity-scan.yml +++ b/.github/workflows/coverity-scan.yml @@ -25,7 +25,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: version: "6.4.0" - archives: qtbase qtsvg qttools + archives: icu qtbase qtsvg qttools - name: Install libtorrent run: |