From 4c59c335331f8fee7c2eb0e2700d3bd07a92255d Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sat, 26 Apr 2025 09:22:13 +0300 Subject: [PATCH] Apply suggestions --- src/base/bittorrent/filesearcher.cpp | 5 ++++- src/base/bittorrent/filesearcher.h | 4 +++- src/base/bittorrent/sessionimpl.cpp | 3 +++ src/base/bittorrent/sessionimpl.h | 7 +++++-- src/base/bittorrent/torrent.h | 3 ++- src/base/bittorrent/torrentcontenthandler.h | 3 ++- src/base/bittorrent/torrentimpl.cpp | 2 ++ src/gui/addnewtorrentdialog.cpp | 1 + src/gui/properties/peerlistwidget.cpp | 3 ++- src/gui/properties/propertieswidget.cpp | 3 ++- src/gui/torrentcontentmodel.cpp | 3 ++- src/gui/trackerlist/trackerlistmodel.cpp | 3 ++- src/webui/api/synccontroller.cpp | 5 +++-- src/webui/api/torrentscontroller.cpp | 9 +++++---- 14 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/base/bittorrent/filesearcher.cpp b/src/base/bittorrent/filesearcher.cpp index ea0f3146d..9b1a1f9cc 100644 --- a/src/base/bittorrent/filesearcher.cpp +++ b/src/base/bittorrent/filesearcher.cpp @@ -27,6 +27,9 @@ */ #include "filesearcher.h" + +#include + #include "base/bittorrent/common.h" namespace @@ -73,6 +76,6 @@ void FileSearcher::search(const PathList &originalFileNames, const Path &savePat findInDir(usedPath, adjustedFileNames, forceAppendExt); } - promise.addResult(FileSearchResult {usedPath, adjustedFileNames}); + promise.addResult(FileSearchResult {.savePath = usedPath, .fileNames = adjustedFileNames}); promise.finish(); } diff --git a/src/base/bittorrent/filesearcher.h b/src/base/bittorrent/filesearcher.h index 11e5b4849..cfd7ada73 100644 --- a/src/base/bittorrent/filesearcher.h +++ b/src/base/bittorrent/filesearcher.h @@ -29,10 +29,11 @@ #pragma once #include -#include #include "base/path.h" +template class QPromise; + struct FileSearchResult { Path savePath; @@ -41,6 +42,7 @@ struct FileSearchResult class FileSearcher final : public QObject { + Q_OBJECT Q_DISABLE_COPY_MOVE(FileSearcher) public: diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 34cb0e618..b642b4b2f 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +99,7 @@ #include "dbresumedatastorage.h" #include "downloadpriority.h" #include "extensiondata.h" +#include "filesearcher.h" #include "filterparserthread.h" #include "loadtorrentparams.h" #include "lttypecast.h" diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index 3dd8ad0e4..e878cf4a6 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -54,7 +53,6 @@ #include "addtorrentparams.h" #include "cachestatus.h" #include "categoryoptions.h" -#include "filesearcher.h" #include "session.h" #include "sessionstatus.h" #include "torrentinfo.h" @@ -63,11 +61,16 @@ class QString; class QTimer; class QUrl; +template class QFuture; + class BandwidthScheduler; +class FileSearcher; class FilterParserThread; class FreeDiskSpaceChecker; class NativeSessionExtension; +struct FileSearchResult; + namespace BitTorrent { enum class MoveStorageMode; diff --git a/src/base/bittorrent/torrent.h b/src/base/bittorrent/torrent.h index 88902b7ce..fc817b86c 100644 --- a/src/base/bittorrent/torrent.h +++ b/src/base/bittorrent/torrent.h @@ -31,7 +31,6 @@ #include #include -#include #include #include @@ -46,6 +45,8 @@ class QByteArray; class QDateTime; class QUrl; +template class QFuture; + namespace BitTorrent { enum class DownloadPriority; diff --git a/src/base/bittorrent/torrentcontenthandler.h b/src/base/bittorrent/torrentcontenthandler.h index fe2c6a805..350db753e 100644 --- a/src/base/bittorrent/torrentcontenthandler.h +++ b/src/base/bittorrent/torrentcontenthandler.h @@ -28,13 +28,14 @@ #pragma once -#include #include #include "base/pathfwd.h" #include "abstractfilestorage.h" #include "downloadpriority.h" +template class QFuture; + namespace BitTorrent { class TorrentContentHandler : public QObject, public AbstractFileStorage diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 7febb65b3..a670db151 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ #include "common.h" #include "downloadpriority.h" #include "extensiondata.h" +#include "filesearcher.h" #include "loadtorrentparams.h" #include "ltqbitarray.h" #include "lttypecast.h" diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 104e3b59d..8954a1c4d 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index cd39a6b7a..a6c44d106 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2023 Vladimir Golovnev + * Copyright (C) 2023-2025 Vladimir Golovnev * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index aab81c6a1..303043a80 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2022-2024 Vladimir Golovnev + * Copyright (C) 2022-2025 Vladimir Golovnev * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index cdbf681ab..32e44c16f 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2022-2024 Vladimir Golovnev + * Copyright (C) 2022-2025 Vladimir Golovnev * Copyright (C) 2006-2012 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/src/gui/trackerlist/trackerlistmodel.cpp b/src/gui/trackerlist/trackerlistmodel.cpp index 1dd3baed6..b13b067b6 100644 --- a/src/gui/trackerlist/trackerlistmodel.cpp +++ b/src/gui/trackerlist/trackerlistmodel.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2023-2024 Vladimir Golovnev + * Copyright (C) 2023-2025 Vladimir Golovnev * Copyright (C) 2006 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index bfe8dd8e6..574a833ed 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2018-2024 Vladimir Golovnev + * Copyright (C) 2018-2025 Vladimir Golovnev * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,6 +28,7 @@ #include "synccontroller.h" +#include #include #include #include @@ -745,7 +746,7 @@ void SyncController::torrentPeersAction() QVariantMap data; QVariantHash peers; - const QList peersList = torrent->fetchPeerInfo().result(); + const QList peersList = torrent->fetchPeerInfo().takeResult(); bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries(); diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 8dd609544..c877fd5db 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2018-2023 Vladimir Golovnev + * Copyright (C) 2018-2025 Vladimir Golovnev * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -180,7 +181,7 @@ namespace QJsonArray getStickyTrackers(const BitTorrent::Torrent *const torrent) { int seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0; - const QList peersList = torrent->fetchPeerInfo().result(); + const QList peersList = torrent->fetchPeerInfo().takeResult(); for (const BitTorrent::PeerInfo &peer : peersList) { if (peer.isConnecting()) @@ -729,7 +730,7 @@ void TorrentsController::filesAction() { const QList priorities = torrent->filePriorities(); const QList fp = torrent->filesProgress(); - const QList fileAvailability = torrent->fetchAvailableFileFractions().result(); + const QList fileAvailability = torrent->fetchAvailableFileFractions().takeResult(); const BitTorrent::TorrentInfo info = torrent->info(); for (const int index : asConst(fileIndexes)) { @@ -798,7 +799,7 @@ void TorrentsController::pieceStatesAction() for (int i = 0; i < states.size(); ++i) pieceStates.append(static_cast(states[i]) * 2); - const QBitArray dlstates = torrent->fetchDownloadingPieces().result(); + const QBitArray dlstates = torrent->fetchDownloadingPieces().takeResult(); for (int i = 0; i < states.size(); ++i) { if (dlstates[i])