Browse Source

Merge pull request #14166 from glassez/cleanup-class-names

Remove redundant suffix from TorrentHandle class name
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
15f1fdddd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/app/application.cpp
  2. 8
      src/app/application.h
  3. 8
      src/base/CMakeLists.txt
  4. 8
      src/base/base.pri
  5. 6
      src/base/bittorrent/addtorrentparams.h
  6. 6
      src/base/bittorrent/peerinfo.cpp
  7. 6
      src/base/bittorrent/peerinfo.h
  8. 180
      src/base/bittorrent/session.cpp
  9. 116
      src/base/bittorrent/session.h
  10. 24
      src/base/bittorrent/torrent.cpp
  11. 4
      src/base/bittorrent/torrent.h
  12. 350
      src/base/bittorrent/torrentimpl.cpp
  13. 16
      src/base/bittorrent/torrentimpl.h
  14. 14
      src/base/torrentfilter.cpp
  15. 12
      src/base/torrentfilter.h
  16. 6
      src/gui/addnewtorrentdialog.cpp
  17. 12
      src/gui/categoryfiltermodel.cpp
  18. 8
      src/gui/categoryfiltermodel.h
  19. 18
      src/gui/mainwindow.cpp
  20. 12
      src/gui/mainwindow.h
  21. 4
      src/gui/previewselectdialog.cpp
  22. 6
      src/gui/previewselectdialog.h
  23. 8
      src/gui/properties/peerlistwidget.cpp
  24. 6
      src/gui/properties/peerlistwidget.h
  25. 4
      src/gui/properties/piecesbar.cpp
  26. 6
      src/gui/properties/piecesbar.h
  27. 14
      src/gui/properties/propertieswidget.cpp
  28. 14
      src/gui/properties/propertieswidget.h
  29. 4
      src/gui/properties/proplistdelegate.cpp
  30. 22
      src/gui/properties/trackerlistwidget.cpp
  31. 4
      src/gui/properties/trackerlistwidget.h
  32. 6
      src/gui/properties/trackersadditiondialog.cpp
  33. 8
      src/gui/properties/trackersadditiondialog.h
  34. 2
      src/gui/statsdialog.cpp
  35. 12
      src/gui/tagfiltermodel.cpp
  36. 10
      src/gui/tagfiltermodel.h
  37. 2
      src/gui/torrentcontenttreeview.cpp
  38. 2
      src/gui/torrentcontenttreeview.h
  39. 4
      src/gui/torrentcreatordialog.cpp
  40. 24
      src/gui/torrentoptionsdialog.cpp
  41. 4
      src/gui/torrentoptionsdialog.h
  42. 26
      src/gui/transferlistfilterswidget.cpp
  43. 26
      src/gui/transferlistfilterswidget.h
  44. 26
      src/gui/transferlistmodel.cpp
  45. 20
      src/gui/transferlistmodel.h
  46. 4
      src/gui/transferlistsortmodel.cpp
  47. 96
      src/gui/transferlistwidget.cpp
  48. 10
      src/gui/transferlistwidget.h
  49. 6
      src/webui/api/serialize/serialize_torrent.cpp
  50. 4
      src/webui/api/serialize/serialize_torrent.h
  51. 6
      src/webui/api/synccontroller.cpp
  52. 84
      src/webui/api/torrentscontroller.cpp

8
src/app/application.cpp

@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/exceptions.h"
#include "base/iconprovider.h"
#include "base/logger.h"
@ -311,7 +311,7 @@ void Application::processMessage(const QString &message) @@ -311,7 +311,7 @@ void Application::processMessage(const QString &message)
m_paramsQueue.append(params);
}
void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) const
void Application::runExternalProgram(const BitTorrent::Torrent *torrent) const
{
QString program = Preferences::instance()->getAutoRunProgram().trimmed();
program.replace("%N", torrent->name());
@ -405,7 +405,7 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c @@ -405,7 +405,7 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c
#endif
}
void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent)
void Application::sendNotificationEmail(const BitTorrent::Torrent *torrent)
{
// Prepare mail content
const QString content = tr("Torrent name: %1").arg(torrent->name()) + '\n'
@ -424,7 +424,7 @@ void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent @@ -424,7 +424,7 @@ void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent
content);
}
void Application::torrentFinished(BitTorrent::TorrentHandle *const torrent)
void Application::torrentFinished(BitTorrent::Torrent *const torrent)
{
Preferences *const pref = Preferences::instance();

8
src/app/application.h

@ -59,7 +59,7 @@ class FileLogger; @@ -59,7 +59,7 @@ class FileLogger;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
namespace RSS
@ -112,7 +112,7 @@ protected: @@ -112,7 +112,7 @@ protected:
private slots:
void processMessage(const QString &message);
void torrentFinished(BitTorrent::TorrentHandle *const torrent);
void torrentFinished(BitTorrent::Torrent *const torrent);
void allTorrentsFinished();
void cleanup();
#if (!defined(DISABLE_GUI) && defined(Q_OS_WIN))
@ -142,6 +142,6 @@ private: @@ -142,6 +142,6 @@ private:
void initializeTranslation();
void processParams(const QStringList &params);
void runExternalProgram(const BitTorrent::TorrentHandle *torrent) const;
void sendNotificationEmail(const BitTorrent::TorrentHandle *torrent);
void runExternalProgram(const BitTorrent::Torrent *torrent) const;
void sendNotificationEmail(const BitTorrent::Torrent *torrent);
};

8
src/base/CMakeLists.txt

@ -25,10 +25,10 @@ add_library(qbt_base STATIC @@ -25,10 +25,10 @@ add_library(qbt_base STATIC
bittorrent/sessionstatus.h
bittorrent/speedmonitor.h
bittorrent/statistics.h
bittorrent/torrent.h
bittorrent/torrentcontentlayout.h
bittorrent/torrentcreatorthread.h
bittorrent/torrenthandle.h
bittorrent/torrenthandleimpl.h
bittorrent/torrentimpl.h
bittorrent/torrentinfo.h
bittorrent/tracker.h
bittorrent/trackerentry.h
@ -107,9 +107,9 @@ add_library(qbt_base STATIC @@ -107,9 +107,9 @@ add_library(qbt_base STATIC
bittorrent/session.cpp
bittorrent/speedmonitor.cpp
bittorrent/statistics.cpp
bittorrent/torrent.cpp
bittorrent/torrentcreatorthread.cpp
bittorrent/torrenthandle.cpp
bittorrent/torrenthandleimpl.cpp
bittorrent/torrentimpl.cpp
bittorrent/torrentinfo.cpp
bittorrent/tracker.cpp
bittorrent/trackerentry.cpp

8
src/base/base.pri

@ -24,10 +24,10 @@ HEADERS += \ @@ -24,10 +24,10 @@ HEADERS += \
$$PWD/bittorrent/sessionstatus.h \
$$PWD/bittorrent/speedmonitor.h \
$$PWD/bittorrent/statistics.h \
$$PWD/bittorrent/torrent.h \
$$PWD/bittorrent/torrentcontentlayout.h \
$$PWD/bittorrent/torrentcreatorthread.h \
$$PWD/bittorrent/torrenthandle.h \
$$PWD/bittorrent/torrenthandleimpl.h \
$$PWD/bittorrent/torrentimpl.h \
$$PWD/bittorrent/torrentinfo.h \
$$PWD/bittorrent/tracker.h \
$$PWD/bittorrent/trackerentry.h \
@ -107,9 +107,9 @@ SOURCES += \ @@ -107,9 +107,9 @@ SOURCES += \
$$PWD/bittorrent/session.cpp \
$$PWD/bittorrent/speedmonitor.cpp \
$$PWD/bittorrent/statistics.cpp \
$$PWD/bittorrent/torrent.cpp \
$$PWD/bittorrent/torrentcreatorthread.cpp \
$$PWD/bittorrent/torrenthandle.cpp \
$$PWD/bittorrent/torrenthandleimpl.cpp \
$$PWD/bittorrent/torrentimpl.cpp \
$$PWD/bittorrent/torrentinfo.cpp \
$$PWD/bittorrent/tracker.cpp \
$$PWD/bittorrent/trackerentry.cpp \

6
src/base/bittorrent/addtorrentparams.h

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
#include <QString>
#include <QVector>
#include "torrenthandle.h"
#include "torrent.h"
#include "torrentcontentlayout.h"
namespace BitTorrent
@ -58,7 +58,7 @@ namespace BitTorrent @@ -58,7 +58,7 @@ namespace BitTorrent
std::optional<bool> useAutoTMM;
int uploadLimit = -1;
int downloadLimit = -1;
int seedingTimeLimit = TorrentHandle::USE_GLOBAL_SEEDING_TIME;
qreal ratioLimit = TorrentHandle::USE_GLOBAL_RATIO;
int seedingTimeLimit = Torrent::USE_GLOBAL_SEEDING_TIME;
qreal ratioLimit = Torrent::USE_GLOBAL_RATIO;
};
}

6
src/base/bittorrent/peerinfo.cpp

@ -30,14 +30,14 @@ @@ -30,14 +30,14 @@
#include <QBitArray>
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/net/geoipmanager.h"
#include "base/unicodestrings.h"
#include "peeraddress.h"
using namespace BitTorrent;
PeerInfo::PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo)
PeerInfo::PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo)
: m_nativeInfo(nativeInfo)
{
calcRelevance(torrent);
@ -226,7 +226,7 @@ QString PeerInfo::connectionType() const @@ -226,7 +226,7 @@ QString PeerInfo::connectionType() const
: QLatin1String {"Web"};
}
void PeerInfo::calcRelevance(const TorrentHandle *torrent)
void PeerInfo::calcRelevance(const Torrent *torrent)
{
const QBitArray allPieces = torrent->pieces();
const QBitArray peerPieces = pieces();

6
src/base/bittorrent/peerinfo.h

@ -36,7 +36,7 @@ class QBitArray; @@ -36,7 +36,7 @@ class QBitArray;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
struct PeerAddress;
class PeerInfo
@ -45,7 +45,7 @@ namespace BitTorrent @@ -45,7 +45,7 @@ namespace BitTorrent
public:
PeerInfo() = default;
PeerInfo(const TorrentHandle *torrent, const lt::peer_info &nativeInfo);
PeerInfo(const Torrent *torrent, const lt::peer_info &nativeInfo);
bool fromDHT() const;
bool fromPeX() const;
@ -92,7 +92,7 @@ namespace BitTorrent @@ -92,7 +92,7 @@ namespace BitTorrent
int downloadingPieceIndex() const;
private:
void calcRelevance(const TorrentHandle *torrent);
void calcRelevance(const Torrent *torrent);
void determineFlags();
lt::peer_info m_nativeInfo = {};

180
src/base/bittorrent/session.cpp

@ -96,7 +96,7 @@ @@ -96,7 +96,7 @@
#include "portforwarderimpl.h"
#include "resumedatasavingmanager.h"
#include "statistics.h"
#include "torrenthandleimpl.h"
#include "torrentimpl.h"
#include "tracker.h"
#include "trackerentry.h"
@ -578,7 +578,7 @@ void Session::setTempPathEnabled(const bool enabled) @@ -578,7 +578,7 @@ void Session::setTempPathEnabled(const bool enabled)
if (enabled != isTempPathEnabled())
{
m_isTempPathEnabled = enabled;
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->handleTempPathChanged();
}
}
@ -595,7 +595,7 @@ void Session::setAppendExtensionEnabled(const bool enabled) @@ -595,7 +595,7 @@ void Session::setAppendExtensionEnabled(const bool enabled)
m_isAppendExtensionEnabled = enabled;
// append or remove .!qB extension for incomplete files
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->handleAppendExtensionToggled();
}
}
@ -748,13 +748,13 @@ bool Session::editCategory(const QString &name, const QString &savePath) @@ -748,13 +748,13 @@ bool Session::editCategory(const QString &name, const QString &savePath)
m_storedCategories = map_cast(m_categories);
if (isDisableAutoTMMWhenCategorySavePathChanged())
{
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
if (torrent->category() == name)
torrent->setAutoTMMEnabled(false);
}
else
{
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
if (torrent->category() == name)
torrent->handleCategorySavePathChanged();
}
@ -764,7 +764,7 @@ bool Session::editCategory(const QString &name, const QString &savePath) @@ -764,7 +764,7 @@ bool Session::editCategory(const QString &name, const QString &savePath)
bool Session::removeCategory(const QString &name)
{
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
if (torrent->belongsToCategory(name))
torrent->setCategory("");
@ -858,7 +858,7 @@ bool Session::removeTag(const QString &tag) @@ -858,7 +858,7 @@ bool Session::removeTag(const QString &tag)
{
if (m_tags.remove(tag))
{
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->removeTag(tag);
m_storedTags = m_tags.values();
emit tagRemoved(tag);
@ -1618,16 +1618,16 @@ void Session::processShareLimits() @@ -1618,16 +1618,16 @@ void Session::processShareLimits()
// We shouldn't iterate over `m_torrents` in the loop below
// since `deleteTorrent()` modifies it indirectly
const QHash<InfoHash, TorrentHandleImpl *> torrents {m_torrents};
for (TorrentHandleImpl *const torrent : torrents)
const QHash<InfoHash, TorrentImpl *> torrents {m_torrents};
for (TorrentImpl *const torrent : torrents)
{
if (torrent->isSeed() && !torrent->isForced())
{
if (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT)
if (torrent->ratioLimit() != Torrent::NO_RATIO_LIMIT)
{
const qreal ratio = torrent->realRatio();
qreal ratioLimit = torrent->ratioLimit();
if (ratioLimit == TorrentHandle::USE_GLOBAL_RATIO)
if (ratioLimit == Torrent::USE_GLOBAL_RATIO)
// If Global Max Ratio is really set...
ratioLimit = globalMaxRatio();
@ -1635,7 +1635,7 @@ void Session::processShareLimits() @@ -1635,7 +1635,7 @@ void Session::processShareLimits()
{
qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit);
if ((ratio <= TorrentHandle::MAX_RATIO) && (ratio >= ratioLimit))
if ((ratio <= Torrent::MAX_RATIO) && (ratio >= ratioLimit))
{
if (m_maxRatioAction == Remove)
{
@ -1645,7 +1645,7 @@ void Session::processShareLimits() @@ -1645,7 +1645,7 @@ void Session::processShareLimits()
else if (m_maxRatioAction == DeleteFiles)
{
LogMsg(tr("'%1' reached the maximum ratio you set. Removed torrent and its files.").arg(torrent->name()));
deleteTorrent(torrent->hash(), TorrentAndFiles);
deleteTorrent(torrent->hash(), DeleteTorrentAndFiles);
}
else if ((m_maxRatioAction == Pause) && !torrent->isPaused())
{
@ -1662,11 +1662,11 @@ void Session::processShareLimits() @@ -1662,11 +1662,11 @@ void Session::processShareLimits()
}
}
if (torrent->seedingTimeLimit() != TorrentHandle::NO_SEEDING_TIME_LIMIT)
if (torrent->seedingTimeLimit() != Torrent::NO_SEEDING_TIME_LIMIT)
{
const qlonglong seedingTimeInMinutes = torrent->seedingTime() / 60;
int seedingTimeLimit = torrent->seedingTimeLimit();
if (seedingTimeLimit == TorrentHandle::USE_GLOBAL_SEEDING_TIME)
if (seedingTimeLimit == Torrent::USE_GLOBAL_SEEDING_TIME)
{
// If Global Seeding Time Limit is really set...
seedingTimeLimit = globalMaxSeedingMinutes();
@ -1674,7 +1674,7 @@ void Session::processShareLimits() @@ -1674,7 +1674,7 @@ void Session::processShareLimits()
if (seedingTimeLimit >= 0)
{
if ((seedingTimeInMinutes <= TorrentHandle::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit))
if ((seedingTimeInMinutes <= Torrent::MAX_SEEDING_TIME) && (seedingTimeInMinutes >= seedingTimeLimit))
{
if (m_maxRatioAction == Remove)
{
@ -1684,7 +1684,7 @@ void Session::processShareLimits() @@ -1684,7 +1684,7 @@ void Session::processShareLimits()
else if (m_maxRatioAction == DeleteFiles)
{
LogMsg(tr("'%1' reached the maximum seeding time you set. Removed torrent and its files.").arg(torrent->name()));
deleteTorrent(torrent->hash(), TorrentAndFiles);
deleteTorrent(torrent->hash(), DeleteTorrentAndFiles);
}
else if ((m_maxRatioAction == Pause) && !torrent->isPaused())
{
@ -1723,7 +1723,7 @@ void Session::handleDownloadFinished(const Net::DownloadResult &result) @@ -1723,7 +1723,7 @@ void Session::handleDownloadFinished(const Net::DownloadResult &result)
void Session::fileSearchFinished(const InfoHash &id, const QString &savePath, const QStringList &fileNames)
{
TorrentHandleImpl *torrent = m_torrents.value(id);
TorrentImpl *torrent = m_torrents.value(id);
if (torrent)
{
torrent->fileSearchFinished(savePath, fileNames);
@ -1747,14 +1747,14 @@ void Session::fileSearchFinished(const InfoHash &id, const QString &savePath, co @@ -1747,14 +1747,14 @@ void Session::fileSearchFinished(const InfoHash &id, const QString &savePath, co
}
// Return the torrent handle, given its hash
TorrentHandle *Session::findTorrent(const InfoHash &hash) const
Torrent *Session::findTorrent(const InfoHash &hash) const
{
return m_torrents.value(hash);
}
bool Session::hasActiveTorrents() const
{
return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentHandleImpl *torrent)
return std::any_of(m_torrents.begin(), m_torrents.end(), [](TorrentImpl *torrent)
{
return TorrentFilter::ActiveTorrent.match(torrent);
});
@ -1762,7 +1762,7 @@ bool Session::hasActiveTorrents() const @@ -1762,7 +1762,7 @@ bool Session::hasActiveTorrents() const
bool Session::hasUnfinishedTorrents() const
{
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandleImpl *torrent)
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent)
{
return (!torrent->isSeed() && !torrent->isPaused());
});
@ -1770,7 +1770,7 @@ bool Session::hasUnfinishedTorrents() const @@ -1770,7 +1770,7 @@ bool Session::hasUnfinishedTorrents() const
bool Session::hasRunningSeed() const
{
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentHandleImpl *torrent)
return std::any_of(m_torrents.begin(), m_torrents.end(), [](const TorrentImpl *torrent)
{
return (torrent->isSeed() && !torrent->isPaused());
});
@ -1799,14 +1799,14 @@ void Session::banIP(const QString &ip) @@ -1799,14 +1799,14 @@ void Session::banIP(const QString &ip)
// and from the disk, if the corresponding deleteOption is chosen
bool Session::deleteTorrent(const InfoHash &hash, const DeleteOption deleteOption)
{
TorrentHandleImpl *const torrent = m_torrents.take(hash);
TorrentImpl *const torrent = m_torrents.take(hash);
if (!torrent) return false;
qDebug("Deleting torrent with hash: %s", qUtf8Printable(torrent->hash()));
emit torrentAboutToBeRemoved(torrent);
// Remove it from session
if (deleteOption == Torrent)
if (deleteOption == DeleteTorrent)
{
m_removingTorrents[torrent->hash()] = {torrent->name(), "", deleteOption};
@ -1887,7 +1887,7 @@ bool Session::cancelDownloadMetadata(const InfoHash &hash) @@ -1887,7 +1887,7 @@ bool Session::cancelDownloadMetadata(const InfoHash &hash)
void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
{
using ElementType = std::pair<int, TorrentHandleImpl *>;
using ElementType = std::pair<int, TorrentImpl *>;
std::priority_queue<ElementType
, std::vector<ElementType>
, std::greater<ElementType>> torrentQueue;
@ -1895,7 +1895,7 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1895,7 +1895,7 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes)
{
TorrentHandleImpl *const torrent = m_torrents.value(infoHash);
TorrentImpl *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
@ -1903,7 +1903,7 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1903,7 +1903,7 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Increase torrents queue position (starting with the one in the highest queue position)
while (!torrentQueue.empty())
{
const TorrentHandleImpl *torrent = torrentQueue.top().second;
const TorrentImpl *torrent = torrentQueue.top().second;
torrentQueuePositionUp(torrent->nativeHandle());
torrentQueue.pop();
}
@ -1913,13 +1913,13 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1913,13 +1913,13 @@ void Session::increaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
{
using ElementType = std::pair<int, TorrentHandleImpl *>;
using ElementType = std::pair<int, TorrentImpl *>;
std::priority_queue<ElementType> torrentQueue;
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes)
{
TorrentHandleImpl *const torrent = m_torrents.value(infoHash);
TorrentImpl *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
@ -1927,7 +1927,7 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1927,7 +1927,7 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Decrease torrents queue position (starting with the one in the lowest queue position)
while (!torrentQueue.empty())
{
const TorrentHandleImpl *torrent = torrentQueue.top().second;
const TorrentImpl *torrent = torrentQueue.top().second;
torrentQueuePositionDown(torrent->nativeHandle());
torrentQueue.pop();
}
@ -1940,13 +1940,13 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1940,13 +1940,13 @@ void Session::decreaseTorrentsQueuePos(const QVector<InfoHash> &hashes)
void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
{
using ElementType = std::pair<int, TorrentHandleImpl *>;
using ElementType = std::pair<int, TorrentImpl *>;
std::priority_queue<ElementType> torrentQueue;
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes)
{
TorrentHandleImpl *const torrent = m_torrents.value(infoHash);
TorrentImpl *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
@ -1954,7 +1954,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1954,7 +1954,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Top torrents queue position (starting with the one in the lowest queue position)
while (!torrentQueue.empty())
{
const TorrentHandleImpl *torrent = torrentQueue.top().second;
const TorrentImpl *torrent = torrentQueue.top().second;
torrentQueuePositionTop(torrent->nativeHandle());
torrentQueue.pop();
}
@ -1964,7 +1964,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1964,7 +1964,7 @@ void Session::topTorrentsQueuePos(const QVector<InfoHash> &hashes)
void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
{
using ElementType = std::pair<int, TorrentHandleImpl *>;
using ElementType = std::pair<int, TorrentImpl *>;
std::priority_queue<ElementType
, std::vector<ElementType>
, std::greater<ElementType>> torrentQueue;
@ -1972,7 +1972,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1972,7 +1972,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Sort torrents by queue position
for (const InfoHash &infoHash : hashes)
{
TorrentHandleImpl *const torrent = m_torrents.value(infoHash);
TorrentImpl *const torrent = m_torrents.value(infoHash);
if (torrent && !torrent->isSeed())
torrentQueue.emplace(torrent->queuePosition(), torrent);
}
@ -1980,7 +1980,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1980,7 +1980,7 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
// Bottom torrents queue position (starting with the one in the highest queue position)
while (!torrentQueue.empty())
{
const TorrentHandleImpl *torrent = torrentQueue.top().second;
const TorrentImpl *torrent = torrentQueue.top().second;
torrentQueuePositionBottom(torrent->nativeHandle());
torrentQueue.pop();
}
@ -1991,17 +1991,17 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes) @@ -1991,17 +1991,17 @@ void Session::bottomTorrentsQueuePos(const QVector<InfoHash> &hashes)
saveTorrentsQueue();
}
void Session::handleTorrentSaveResumeDataRequested(const TorrentHandleImpl *torrent)
void Session::handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent)
{
qDebug("Saving resume data is requested for torrent '%s'...", qUtf8Printable(torrent->name()));
++m_numResumeData;
}
QVector<TorrentHandle *> Session::torrents() const
QVector<Torrent *> Session::torrents() const
{
QVector<TorrentHandle *> result;
QVector<Torrent *> result;
result.reserve(m_torrents.size());
for (TorrentHandleImpl *torrent : asConst(m_torrents))
for (TorrentImpl *torrent : asConst(m_torrents))
result << torrent;
return result;
@ -2099,7 +2099,7 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source @@ -2099,7 +2099,7 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
if (m_loadingTorrents.contains(hash))
return false;
TorrentHandleImpl *const torrent = m_torrents.value(hash);
TorrentImpl *const torrent = m_torrents.value(hash);
if (torrent)
{ // a duplicate torrent is added
if (torrent->isPrivate() || (hasMetadata && metadata.isPrivate()))
@ -2293,7 +2293,7 @@ bool Session::downloadMetadata(const MagnetUri &magnetUri) @@ -2293,7 +2293,7 @@ bool Session::downloadMetadata(const MagnetUri &magnetUri)
return true;
}
void Session::exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolder folder)
void Session::exportTorrentFile(const Torrent *torrent, TorrentExportFolder folder)
{
Q_ASSERT(((folder == TorrentExportFolder::Regular) && !torrentExportDirectory().isEmpty()) ||
((folder == TorrentExportFolder::Finished) && !finishedTorrentExportDirectory().isEmpty()));
@ -2321,7 +2321,7 @@ void Session::exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolde @@ -2321,7 +2321,7 @@ void Session::exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolde
void Session::generateResumeData()
{
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
{
if (!torrent->isValid()) continue;
@ -2367,7 +2367,7 @@ void Session::saveTorrentsQueue() @@ -2367,7 +2367,7 @@ void Session::saveTorrentsQueue()
{
// store hash in textual representation
QMap<int, QString> queue; // Use QMap since it should be ordered by key
for (const TorrentHandleImpl *torrent : asConst(m_torrents))
for (const TorrentImpl *torrent : asConst(m_torrents))
{
// We require actual (non-cached) queue position here!
const int queuePos = static_cast<LTUnderlyingType<lt::queue_position_t>>(torrent->nativeHandle().queue_position());
@ -2409,10 +2409,10 @@ void Session::setDefaultSavePath(QString path) @@ -2409,10 +2409,10 @@ void Session::setDefaultSavePath(QString path)
m_defaultSavePath = path;
if (isDisableAutoTMMWhenDefaultSavePathChanged())
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->setAutoTMMEnabled(false);
else
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->handleCategorySavePathChanged();
}
@ -2423,7 +2423,7 @@ void Session::setTempPath(QString path) @@ -2423,7 +2423,7 @@ void Session::setTempPath(QString path)
m_tempPath = path;
for (TorrentHandleImpl *const torrent : asConst(m_torrents))
for (TorrentImpl *const torrent : asConst(m_torrents))
torrent->handleTempPathChanged();
}
@ -3751,8 +3751,8 @@ bool Session::isKnownTorrent(const InfoHash &hash) const @@ -3751,8 +3751,8 @@ bool Session::isKnownTorrent(const InfoHash &hash) const
void Session::updateSeedingLimitTimer()
{
if ((globalMaxRatio() == TorrentHandle::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit()
&& (globalMaxSeedingMinutes() == TorrentHandle::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit())
if ((globalMaxRatio() == Torrent::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit()
&& (globalMaxSeedingMinutes() == Torrent::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit())
{
if (m_seedingLimitTimer->isActive())
m_seedingLimitTimer->stop();
@ -3763,48 +3763,48 @@ void Session::updateSeedingLimitTimer() @@ -3763,48 +3763,48 @@ void Session::updateSeedingLimitTimer()
}
}
void Session::handleTorrentShareLimitChanged(TorrentHandleImpl *const torrent)
void Session::handleTorrentShareLimitChanged(TorrentImpl *const torrent)
{
torrent->saveResumeData();
updateSeedingLimitTimer();
}
void Session::handleTorrentNameChanged(TorrentHandleImpl *const torrent)
void Session::handleTorrentNameChanged(TorrentImpl *const torrent)
{
torrent->saveResumeData();
}
void Session::handleTorrentSavePathChanged(TorrentHandleImpl *const torrent)
void Session::handleTorrentSavePathChanged(TorrentImpl *const torrent)
{
torrent->saveResumeData();
emit torrentSavePathChanged(torrent);
}
void Session::handleTorrentCategoryChanged(TorrentHandleImpl *const torrent, const QString &oldCategory)
void Session::handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory)
{
torrent->saveResumeData();
emit torrentCategoryChanged(torrent, oldCategory);
}
void Session::handleTorrentTagAdded(TorrentHandleImpl *const torrent, const QString &tag)
void Session::handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag)
{
torrent->saveResumeData();
emit torrentTagAdded(torrent, tag);
}
void Session::handleTorrentTagRemoved(TorrentHandleImpl *const torrent, const QString &tag)
void Session::handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag)
{
torrent->saveResumeData();
emit torrentTagRemoved(torrent, tag);
}
void Session::handleTorrentSavingModeChanged(TorrentHandleImpl *const torrent)
void Session::handleTorrentSavingModeChanged(TorrentImpl *const torrent)
{
torrent->saveResumeData();
emit torrentSavingModeChanged(torrent);
}
void Session::handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const QVector<TrackerEntry> &newTrackers)
void Session::handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector<TrackerEntry> &newTrackers)
{
torrent->saveResumeData();
@ -3816,7 +3816,7 @@ void Session::handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const @@ -3816,7 +3816,7 @@ void Session::handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const
emit trackersChanged(torrent);
}
void Session::handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers)
void Session::handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers)
{
torrent->saveResumeData();
@ -3828,27 +3828,27 @@ void Session::handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, con @@ -3828,27 +3828,27 @@ void Session::handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, con
emit trackersChanged(torrent);
}
void Session::handleTorrentTrackersChanged(TorrentHandleImpl *const torrent)
void Session::handleTorrentTrackersChanged(TorrentImpl *const torrent)
{
torrent->saveResumeData();
emit trackersChanged(torrent);
}
void Session::handleTorrentUrlSeedsAdded(TorrentHandleImpl *const torrent, const QVector<QUrl> &newUrlSeeds)
void Session::handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector<QUrl> &newUrlSeeds)
{
torrent->saveResumeData();
for (const QUrl &newUrlSeed : newUrlSeeds)
LogMsg(tr("URL seed '%1' was added to torrent '%2'").arg(newUrlSeed.toString(), torrent->name()));
}
void Session::handleTorrentUrlSeedsRemoved(TorrentHandleImpl *const torrent, const QVector<QUrl> &urlSeeds)
void Session::handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector<QUrl> &urlSeeds)
{
torrent->saveResumeData();
for (const QUrl &urlSeed : urlSeeds)
LogMsg(tr("URL seed '%1' was removed from torrent '%2'").arg(urlSeed.toString(), torrent->name()));
}
void Session::handleTorrentMetadataReceived(TorrentHandleImpl *const torrent)
void Session::handleTorrentMetadataReceived(TorrentImpl *const torrent)
{
// Save metadata
const QDir resumeDataDir {m_resumeFolderPath};
@ -3869,24 +3869,24 @@ void Session::handleTorrentMetadataReceived(TorrentHandleImpl *const torrent) @@ -3869,24 +3869,24 @@ void Session::handleTorrentMetadataReceived(TorrentHandleImpl *const torrent)
emit torrentMetadataReceived(torrent);
}
void Session::handleTorrentPaused(TorrentHandleImpl *const torrent)
void Session::handleTorrentPaused(TorrentImpl *const torrent)
{
torrent->saveResumeData();
emit torrentPaused(torrent);
}
void Session::handleTorrentResumed(TorrentHandleImpl *const torrent)
void Session::handleTorrentResumed(TorrentImpl *const torrent)
{
torrent->saveResumeData();
emit torrentResumed(torrent);
}
void Session::handleTorrentChecked(TorrentHandleImpl *const torrent)
void Session::handleTorrentChecked(TorrentImpl *const torrent)
{
emit torrentFinishedChecking(torrent);
}
void Session::handleTorrentFinished(TorrentHandleImpl *const torrent)
void Session::handleTorrentFinished(TorrentImpl *const torrent)
{
if (!torrent->hasError() && !torrent->hasMissingFiles())
torrent->saveResumeData();
@ -3925,7 +3925,7 @@ void Session::handleTorrentFinished(TorrentHandleImpl *const torrent) @@ -3925,7 +3925,7 @@ void Session::handleTorrentFinished(TorrentHandleImpl *const torrent)
emit allTorrentsFinished();
}
void Session::handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, const std::shared_ptr<lt::entry> &data)
void Session::handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr<lt::entry> &data)
{
--m_numResumeData;
@ -3942,17 +3942,17 @@ void Session::handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, con @@ -3942,17 +3942,17 @@ void Session::handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, con
#endif
}
void Session::handleTorrentTrackerReply(TorrentHandleImpl *const torrent, const QString &trackerUrl)
void Session::handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl)
{
emit trackerSuccess(torrent, trackerUrl);
}
void Session::handleTorrentTrackerError(TorrentHandleImpl *const torrent, const QString &trackerUrl)
void Session::handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl)
{
emit trackerError(torrent, trackerUrl);
}
bool Session::addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString &newPath, const MoveStorageMode mode)
bool Session::addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, const MoveStorageMode mode)
{
Q_ASSERT(torrent);
@ -4009,7 +4009,7 @@ bool Session::addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString @@ -4009,7 +4009,7 @@ bool Session::addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString
void Session::moveTorrentStorage(const MoveStorageJob &job) const
{
const InfoHash infoHash = job.torrentHandle.info_hash();
const TorrentHandleImpl *torrent = m_torrents.value(infoHash);
const TorrentImpl *torrent = m_torrents.value(infoHash);
const QString torrentName = (torrent ? torrent->name() : QString {infoHash});
LogMsg(tr("Moving \"%1\" to \"%2\"...").arg(torrentName, job.path));
@ -4032,7 +4032,7 @@ void Session::handleMoveTorrentStorageJobFinished() @@ -4032,7 +4032,7 @@ void Session::handleMoveTorrentStorageJobFinished()
const bool torrentHasOutstandingJob = (iter != m_moveStorageQueue.cend());
TorrentHandleImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash());
TorrentImpl *torrent = m_torrents.value(finishedJob.torrentHandle.info_hash());
if (torrent)
{
torrent->handleMoveStorageJobFinished(torrentHasOutstandingJob);
@ -4042,19 +4042,19 @@ void Session::handleMoveTorrentStorageJobFinished() @@ -4042,19 +4042,19 @@ void Session::handleMoveTorrentStorageJobFinished()
// Last job is completed for torrent that being removing, so actually remove it
const lt::torrent_handle nativeHandle {finishedJob.torrentHandle};
const RemovingTorrentData &removingTorrentData = m_removingTorrents[nativeHandle.info_hash()];
if (removingTorrentData.deleteOption == Torrent)
if (removingTorrentData.deleteOption == DeleteTorrent)
m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_partfile);
}
}
void Session::handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl)
void Session::handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl)
{
emit trackerWarning(torrent, trackerUrl);
}
bool Session::hasPerTorrentRatioLimit() const
{
return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentHandleImpl *torrent)
return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent)
{
return (torrent->ratioLimit() >= 0);
});
@ -4062,7 +4062,7 @@ bool Session::hasPerTorrentRatioLimit() const @@ -4062,7 +4062,7 @@ bool Session::hasPerTorrentRatioLimit() const
bool Session::hasPerTorrentSeedingTimeLimit() const
{
return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentHandleImpl *torrent)
return std::any_of(m_torrents.cbegin(), m_torrents.cend(), [](const TorrentImpl *torrent)
{
return (torrent->seedingTimeLimit() >= 0);
});
@ -4143,7 +4143,7 @@ void Session::disableIPFilter() @@ -4143,7 +4143,7 @@ void Session::disableIPFilter()
void Session::recursiveTorrentDownload(const InfoHash &hash)
{
TorrentHandleImpl *const torrent = m_torrents.value(hash);
TorrentImpl *const torrent = m_torrents.value(hash);
if (!torrent) return;
for (int i = 0; i < torrent->filesCount(); ++i)
@ -4189,7 +4189,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m @@ -4189,7 +4189,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m
Utils::Fs::toUniformPath(fromLTString(root.dict_find_string_value("qBt-savePath"))));
torrentParams.hasSeedStatus = root.dict_find_int_value("qBt-seedStatus");
torrentParams.firstLastPiecePriority = root.dict_find_int_value("qBt-firstLastPiecePriority");
torrentParams.seedingTimeLimit = root.dict_find_int_value("qBt-seedingTimeLimit", TorrentHandle::USE_GLOBAL_SEEDING_TIME);
torrentParams.seedingTimeLimit = root.dict_find_int_value("qBt-seedingTimeLimit", Torrent::USE_GLOBAL_SEEDING_TIME);
// TODO: The following code is deprecated. Replace with the commented one after several releases in 4.4.x.
// === BEGIN DEPRECATED CODE === //
@ -4212,7 +4212,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m @@ -4212,7 +4212,7 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m
const lt::string_view ratioLimitString = root.dict_find_string_value("qBt-ratioLimit");
if (ratioLimitString.empty())
torrentParams.ratioLimit = root.dict_find_int_value("qBt-ratioLimit", TorrentHandle::USE_GLOBAL_RATIO * 1000) / 1000.0;
torrentParams.ratioLimit = root.dict_find_int_value("qBt-ratioLimit", Torrent::USE_GLOBAL_RATIO * 1000) / 1000.0;
else
torrentParams.ratioLimit = fromLTString(ratioLimitString).toDouble();
@ -4546,7 +4546,7 @@ void Session::handleAlert(const lt::alert *a) @@ -4546,7 +4546,7 @@ void Session::handleAlert(const lt::alert *a)
void Session::dispatchTorrentAlert(const lt::alert *a)
{
TorrentHandleImpl *const torrent = m_torrents.value(static_cast<const lt::torrent_alert*>(a)->handle.info_hash());
TorrentImpl *const torrent = m_torrents.value(static_cast<const lt::torrent_alert*>(a)->handle.info_hash());
if (torrent)
{
torrent->handleAlert(a);
@ -4561,13 +4561,13 @@ void Session::dispatchTorrentAlert(const lt::alert *a) @@ -4561,13 +4561,13 @@ void Session::dispatchTorrentAlert(const lt::alert *a)
}
}
void Session::createTorrentHandle(const lt::torrent_handle &nativeHandle)
void Session::createTorrent(const lt::torrent_handle &nativeHandle)
{
Q_ASSERT(m_loadingTorrents.contains(nativeHandle.info_hash()));
const LoadTorrentParams params = m_loadingTorrents.take(nativeHandle.info_hash());
auto *const torrent = new TorrentHandleImpl {this, m_nativeSession, nativeHandle, params};
auto *const torrent = new TorrentImpl {this, m_nativeSession, nativeHandle, params};
m_torrents.insert(torrent->hash(), torrent);
const bool hasMetadata = torrent->hasMetadata();
@ -4635,7 +4635,7 @@ void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p) @@ -4635,7 +4635,7 @@ void Session::handleAddTorrentAlert(const lt::add_torrent_alert *p)
}
else if (m_loadingTorrents.contains(p->handle.info_hash()))
{
createTorrentHandle(p->handle);
createTorrent(p->handle);
}
}
@ -4646,7 +4646,7 @@ void Session::handleTorrentRemovedAlert(const lt::torrent_removed_alert *p) @@ -4646,7 +4646,7 @@ void Session::handleTorrentRemovedAlert(const lt::torrent_removed_alert *p)
const auto removingTorrentDataIter = m_removingTorrents.find(infoHash);
if (removingTorrentDataIter != m_removingTorrents.end())
{
if (removingTorrentDataIter->deleteOption == Torrent)
if (removingTorrentDataIter->deleteOption == DeleteTorrent)
{
LogMsg(tr("'%1' was removed from the transfer list.", "'xxx.avi' was removed...").arg(removingTorrentDataIter->name));
m_removingTorrents.erase(removingTorrentDataIter);
@ -4712,7 +4712,7 @@ void Session::handleMetadataReceivedAlert(const lt::metadata_received_alert *p) @@ -4712,7 +4712,7 @@ void Session::handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
void Session::handleFileErrorAlert(const lt::file_error_alert *p)
{
TorrentHandleImpl *const torrent = m_torrents.value(p->handle.info_hash());
TorrentImpl *const torrent = m_torrents.value(p->handle.info_hash());
if (!torrent)
return;
@ -4782,7 +4782,7 @@ void Session::handlePeerBanAlert(const lt::peer_ban_alert *p) @@ -4782,7 +4782,7 @@ void Session::handlePeerBanAlert(const lt::peer_ban_alert *p)
void Session::handleUrlSeedAlert(const lt::url_seed_alert *p)
{
const TorrentHandleImpl *torrent = m_torrents.value(p->handle.info_hash());
const TorrentImpl *torrent = m_torrents.value(p->handle.info_hash());
if (!torrent)
return;
@ -4920,7 +4920,7 @@ void Session::handleStorageMovedAlert(const lt::storage_moved_alert *p) @@ -4920,7 +4920,7 @@ void Session::handleStorageMovedAlert(const lt::storage_moved_alert *p)
Q_ASSERT(newPath == currentJob.path);
const InfoHash infoHash = currentJob.torrentHandle.info_hash();
TorrentHandleImpl *torrent = m_torrents.value(infoHash);
TorrentImpl *torrent = m_torrents.value(infoHash);
const QString torrentName = (torrent ? torrent->name() : QString {infoHash});
LogMsg(tr("\"%1\" is successfully moved to \"%2\".").arg(torrentName, newPath));
@ -4935,7 +4935,7 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert @@ -4935,7 +4935,7 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert
Q_ASSERT(currentJob.torrentHandle == p->handle);
const InfoHash infoHash = currentJob.torrentHandle.info_hash();
TorrentHandleImpl *torrent = m_torrents.value(infoHash);
TorrentImpl *torrent = m_torrents.value(infoHash);
const QString torrentName = (torrent ? torrent->name() : QString {infoHash});
const QString currentLocation = QString::fromStdString(p->handle.status(lt::torrent_handle::query_save_path).save_path);
const QString errorMessage = QString::fromStdString(p->message());
@ -4947,12 +4947,12 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert @@ -4947,12 +4947,12 @@ void Session::handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert
void Session::handleStateUpdateAlert(const lt::state_update_alert *p)
{
QVector<TorrentHandle *> updatedTorrents;
QVector<Torrent *> updatedTorrents;
updatedTorrents.reserve(p->status.size());
for (const lt::torrent_status &status : p->status)
{
TorrentHandleImpl *const torrent = m_torrents.value(status.info_hash);
TorrentImpl *const torrent = m_torrents.value(status.info_hash);
if (!torrent)
continue;

116
src/base/bittorrent/session.h

@ -85,8 +85,8 @@ enum MaxRatioAction @@ -85,8 +85,8 @@ enum MaxRatioAction
enum DeleteOption
{
Torrent,
TorrentAndFiles
DeleteTorrent,
DeleteTorrentAndFiles
};
enum TorrentExportFolder
@ -104,8 +104,8 @@ namespace BitTorrent @@ -104,8 +104,8 @@ namespace BitTorrent
{
class InfoHash;
class MagnetUri;
class TorrentHandle;
class TorrentHandleImpl;
class Torrent;
class TorrentImpl;
class Tracker;
class TrackerEntry;
struct LoadTorrentParams;
@ -440,8 +440,8 @@ namespace BitTorrent @@ -440,8 +440,8 @@ namespace BitTorrent
#endif
void startUpTorrents();
TorrentHandle *findTorrent(const InfoHash &hash) const;
QVector<TorrentHandle *> torrents() const;
Torrent *findTorrent(const InfoHash &hash) const;
QVector<Torrent *> torrents() const;
bool hasActiveTorrents() const;
bool hasUnfinishedTorrents() const;
bool hasRunningSeed() const;
@ -460,7 +460,7 @@ namespace BitTorrent @@ -460,7 +460,7 @@ namespace BitTorrent
bool addTorrent(const QString &source, const AddTorrentParams &params = AddTorrentParams());
bool addTorrent(const MagnetUri &magnetUri, const AddTorrentParams &params = AddTorrentParams());
bool addTorrent(const TorrentInfo &torrentInfo, const AddTorrentParams &params = AddTorrentParams());
bool deleteTorrent(const InfoHash &hash, DeleteOption deleteOption = Torrent);
bool deleteTorrent(const InfoHash &hash, DeleteOption deleteOption = DeleteTorrent);
bool downloadMetadata(const MagnetUri &magnetUri);
bool cancelDownloadMetadata(const InfoHash &hash);
@ -470,31 +470,31 @@ namespace BitTorrent @@ -470,31 +470,31 @@ namespace BitTorrent
void topTorrentsQueuePos(const QVector<InfoHash> &hashes);
void bottomTorrentsQueuePos(const QVector<InfoHash> &hashes);
// TorrentHandle interface
void handleTorrentSaveResumeDataRequested(const TorrentHandleImpl *torrent);
void handleTorrentShareLimitChanged(TorrentHandleImpl *const torrent);
void handleTorrentNameChanged(TorrentHandleImpl *const torrent);
void handleTorrentSavePathChanged(TorrentHandleImpl *const torrent);
void handleTorrentCategoryChanged(TorrentHandleImpl *const torrent, const QString &oldCategory);
void handleTorrentTagAdded(TorrentHandleImpl *const torrent, const QString &tag);
void handleTorrentTagRemoved(TorrentHandleImpl *const torrent, const QString &tag);
void handleTorrentSavingModeChanged(TorrentHandleImpl *const torrent);
void handleTorrentMetadataReceived(TorrentHandleImpl *const torrent);
void handleTorrentPaused(TorrentHandleImpl *const torrent);
void handleTorrentResumed(TorrentHandleImpl *const torrent);
void handleTorrentChecked(TorrentHandleImpl *const torrent);
void handleTorrentFinished(TorrentHandleImpl *const torrent);
void handleTorrentTrackersAdded(TorrentHandleImpl *const torrent, const QVector<TrackerEntry> &newTrackers);
void handleTorrentTrackersRemoved(TorrentHandleImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers);
void handleTorrentTrackersChanged(TorrentHandleImpl *const torrent);
void handleTorrentUrlSeedsAdded(TorrentHandleImpl *const torrent, const QVector<QUrl> &newUrlSeeds);
void handleTorrentUrlSeedsRemoved(TorrentHandleImpl *const torrent, const QVector<QUrl> &urlSeeds);
void handleTorrentResumeDataReady(TorrentHandleImpl *const torrent, const std::shared_ptr<lt::entry> &data);
void handleTorrentTrackerReply(TorrentHandleImpl *const torrent, const QString &trackerUrl);
void handleTorrentTrackerWarning(TorrentHandleImpl *const torrent, const QString &trackerUrl);
void handleTorrentTrackerError(TorrentHandleImpl *const torrent, const QString &trackerUrl);
bool addMoveTorrentStorageJob(TorrentHandleImpl *torrent, const QString &newPath, MoveStorageMode mode);
// Torrent interface
void handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent);
void handleTorrentShareLimitChanged(TorrentImpl *const torrent);
void handleTorrentNameChanged(TorrentImpl *const torrent);
void handleTorrentSavePathChanged(TorrentImpl *const torrent);
void handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory);
void handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag);
void handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag);
void handleTorrentSavingModeChanged(TorrentImpl *const torrent);
void handleTorrentMetadataReceived(TorrentImpl *const torrent);
void handleTorrentPaused(TorrentImpl *const torrent);
void handleTorrentResumed(TorrentImpl *const torrent);
void handleTorrentChecked(TorrentImpl *const torrent);
void handleTorrentFinished(TorrentImpl *const torrent);
void handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector<TrackerEntry> &newTrackers);
void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers);
void handleTorrentTrackersChanged(TorrentImpl *const torrent);
void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector<QUrl> &newUrlSeeds);
void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector<QUrl> &urlSeeds);
void handleTorrentResumeDataReady(TorrentImpl *const torrent, const std::shared_ptr<lt::entry> &data);
void handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl);
void handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl);
void handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl);
bool addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, MoveStorageMode mode);
void findIncompleteFiles(const TorrentInfo &torrentInfo, const QString &savePath) const;
@ -504,37 +504,37 @@ namespace BitTorrent @@ -504,37 +504,37 @@ namespace BitTorrent
void categoryRemoved(const QString &categoryName);
void downloadFromUrlFailed(const QString &url, const QString &reason);
void downloadFromUrlFinished(const QString &url);
void fullDiskError(TorrentHandle *torrent, const QString &msg);
void fullDiskError(Torrent *torrent, const QString &msg);
void IPFilterParsed(bool error, int ruleCount);
void loadTorrentFailed(const QString &error);
void metadataDownloaded(const TorrentInfo &info);
void recursiveTorrentDownloadPossible(TorrentHandle *torrent);
void recursiveTorrentDownloadPossible(Torrent *torrent);
void speedLimitModeChanged(bool alternative);
void statsUpdated();
void subcategoriesSupportChanged();
void tagAdded(const QString &tag);
void tagRemoved(const QString &tag);
void torrentAboutToBeRemoved(TorrentHandle *torrent);
void torrentAdded(TorrentHandle *torrent);
void torrentCategoryChanged(TorrentHandle *torrent, const QString &oldCategory);
void torrentFinished(TorrentHandle *torrent);
void torrentFinishedChecking(TorrentHandle *torrent);
void torrentLoaded(TorrentHandle *torrent);
void torrentMetadataReceived(TorrentHandle *torrent);
void torrentPaused(TorrentHandle *torrent);
void torrentResumed(TorrentHandle *torrent);
void torrentSavePathChanged(TorrentHandle *torrent);
void torrentSavingModeChanged(TorrentHandle *torrent);
void torrentsUpdated(const QVector<TorrentHandle *> &torrents);
void torrentTagAdded(TorrentHandle *torrent, const QString &tag);
void torrentTagRemoved(TorrentHandle *torrent, const QString &tag);
void trackerError(TorrentHandle *torrent, const QString &tracker);
void trackerlessStateChanged(TorrentHandle *torrent, bool trackerless);
void trackersAdded(TorrentHandle *torrent, const QVector<TrackerEntry> &trackers);
void trackersChanged(TorrentHandle *torrent);
void trackersRemoved(TorrentHandle *torrent, const QVector<TrackerEntry> &trackers);
void trackerSuccess(TorrentHandle *torrent, const QString &tracker);
void trackerWarning(TorrentHandle *torrent, const QString &tracker);
void torrentAboutToBeRemoved(Torrent *torrent);
void torrentAdded(Torrent *torrent);
void torrentCategoryChanged(Torrent *torrent, const QString &oldCategory);
void torrentFinished(Torrent *torrent);
void torrentFinishedChecking(Torrent *torrent);
void torrentLoaded(Torrent *torrent);
void torrentMetadataReceived(Torrent *torrent);
void torrentPaused(Torrent *torrent);
void torrentResumed(Torrent *torrent);
void torrentSavePathChanged(Torrent *torrent);
void torrentSavingModeChanged(Torrent *torrent);
void torrentsUpdated(const QVector<Torrent *> &torrents);
void torrentTagAdded(Torrent *torrent, const QString &tag);
void torrentTagRemoved(Torrent *torrent, const QString &tag);
void trackerError(Torrent *torrent, const QString &tracker);
void trackerlessStateChanged(Torrent *torrent, bool trackerless);
void trackersAdded(Torrent *torrent, const QVector<TrackerEntry> &trackers);
void trackersChanged(Torrent *torrent);
void trackersRemoved(Torrent *torrent, const QVector<TrackerEntry> &trackers);
void trackerSuccess(Torrent *torrent, const QString &tracker);
void trackerWarning(Torrent *torrent, const QString &tracker);
private slots:
void configureDeferred();
@ -604,7 +604,7 @@ namespace BitTorrent @@ -604,7 +604,7 @@ namespace BitTorrent
bool addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source, const AddTorrentParams &addTorrentParams);
void updateSeedingLimitTimer();
void exportTorrentFile(const TorrentHandle *torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void exportTorrentFile(const Torrent *torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
void handleAlert(const lt::alert *a);
void dispatchTorrentAlert(const lt::alert *a);
@ -629,7 +629,7 @@ namespace BitTorrent @@ -629,7 +629,7 @@ namespace BitTorrent
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
void handleSocks5Alert(const lt::socks5_alert *p) const;
void createTorrentHandle(const lt::torrent_handle &nativeHandle);
void createTorrent(const lt::torrent_handle &nativeHandle);
void saveResumeData();
void saveTorrentsQueue();
@ -771,7 +771,7 @@ namespace BitTorrent @@ -771,7 +771,7 @@ namespace BitTorrent
QSet<InfoHash> m_downloadedMetadata;
QHash<InfoHash, TorrentHandleImpl *> m_torrents;
QHash<InfoHash, TorrentImpl *> m_torrents;
QHash<InfoHash, LoadTorrentParams> m_loadingTorrents;
QHash<QString, AddTorrentParams> m_downloadedTorrents;
QHash<InfoHash, RemovingTorrentData> m_removingTorrents;

24
src/base/bittorrent/torrenthandle.cpp → src/base/bittorrent/torrent.cpp

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
* exception statement from your version.
*/
#include "torrenthandle.h"
#include "torrent.h"
#include <type_traits>
@ -40,33 +40,33 @@ namespace BitTorrent @@ -40,33 +40,33 @@ namespace BitTorrent
return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed);
}
// TorrentHandle
// Torrent
const qreal TorrentHandle::USE_GLOBAL_RATIO = -2.;
const qreal TorrentHandle::NO_RATIO_LIMIT = -1.;
const qreal Torrent::USE_GLOBAL_RATIO = -2.;
const qreal Torrent::NO_RATIO_LIMIT = -1.;
const int TorrentHandle::USE_GLOBAL_SEEDING_TIME = -2;
const int TorrentHandle::NO_SEEDING_TIME_LIMIT = -1;
const int Torrent::USE_GLOBAL_SEEDING_TIME = -2;
const int Torrent::NO_SEEDING_TIME_LIMIT = -1;
const qreal TorrentHandle::MAX_RATIO = 9999.;
const int TorrentHandle::MAX_SEEDING_TIME = 525600;
const qreal Torrent::MAX_RATIO = 9999.;
const int Torrent::MAX_SEEDING_TIME = 525600;
bool TorrentHandle::isResumed() const
bool Torrent::isResumed() const
{
return !isPaused();
}
qlonglong TorrentHandle::remainingSize() const
qlonglong Torrent::remainingSize() const
{
return wantedSize() - completedSize();
}
void TorrentHandle::toggleSequentialDownload()
void Torrent::toggleSequentialDownload()
{
setSequentialDownload(!isSequentialDownload());
}
void TorrentHandle::toggleFirstLastPiecePriority()
void Torrent::toggleFirstLastPiecePriority()
{
setFirstLastPiecePriority(!hasFirstLastPiecePriority());
}

4
src/base/bittorrent/torrenthandle.h → src/base/bittorrent/torrent.h

@ -91,7 +91,7 @@ namespace BitTorrent @@ -91,7 +91,7 @@ namespace BitTorrent
uint qHash(TorrentState key, uint seed);
class TorrentHandle : public AbstractFileStorage
class Torrent : public AbstractFileStorage
{
public:
static const qreal USE_GLOBAL_RATIO;
@ -103,7 +103,7 @@ namespace BitTorrent @@ -103,7 +103,7 @@ namespace BitTorrent
static const qreal MAX_RATIO;
static const int MAX_SEEDING_TIME;
virtual ~TorrentHandle() = default;
virtual ~Torrent() = default;
virtual InfoHash hash() const = 0;
virtual QString name() const = 0;

350
src/base/bittorrent/torrenthandleimpl.cpp → src/base/bittorrent/torrentimpl.cpp

File diff suppressed because it is too large Load Diff

16
src/base/bittorrent/torrenthandleimpl.h → src/base/bittorrent/torrentimpl.h

@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
#include "infohash.h"
#include "speedmonitor.h"
#include "torrenthandle.h"
#include "torrent.h"
#include "torrentinfo.h"
namespace BitTorrent
@ -69,8 +69,8 @@ namespace BitTorrent @@ -69,8 +69,8 @@ namespace BitTorrent
bool paused = false;
qreal ratioLimit = TorrentHandle::USE_GLOBAL_RATIO;
int seedingTimeLimit = TorrentHandle::USE_GLOBAL_SEEDING_TIME;
qreal ratioLimit = Torrent::USE_GLOBAL_RATIO;
int seedingTimeLimit = Torrent::USE_GLOBAL_SEEDING_TIME;
bool restored = false; // is existing torrent job?
};
@ -87,15 +87,15 @@ namespace BitTorrent @@ -87,15 +87,15 @@ namespace BitTorrent
HandleMetadata
};
class TorrentHandleImpl final : public QObject, public TorrentHandle
class TorrentImpl final : public QObject, public Torrent
{
Q_DISABLE_COPY(TorrentHandleImpl)
Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentHandleImpl)
Q_DISABLE_COPY(TorrentImpl)
Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentImpl)
public:
TorrentHandleImpl(Session *session, lt::session *nativeSession
TorrentImpl(Session *session, lt::session *nativeSession
, const lt::torrent_handle &nativeHandle, const LoadTorrentParams &params);
~TorrentHandleImpl() override;
~TorrentImpl() override;
bool isValid() const;

14
src/base/torrentfilter.cpp

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
#include "torrentfilter.h"
#include "bittorrent/infohash.h"
#include "bittorrent/torrenthandle.h"
#include "bittorrent/torrent.h"
const QString TorrentFilter::AnyCategory;
const InfoHashSet TorrentFilter::AnyHash {{}};
@ -47,7 +47,7 @@ const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::Stalle @@ -47,7 +47,7 @@ const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::Stalle
const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading);
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
using BitTorrent::TorrentHandle;
using BitTorrent::Torrent;
TorrentFilter::TorrentFilter(const Type type, const InfoHashSet &hashSet, const QString &category, const QString &tag)
: m_type(type)
@ -146,14 +146,14 @@ bool TorrentFilter::setTag(const QString &tag) @@ -146,14 +146,14 @@ bool TorrentFilter::setTag(const QString &tag)
return false;
}
bool TorrentFilter::match(const TorrentHandle *const torrent) const
bool TorrentFilter::match(const Torrent *const torrent) const
{
if (!torrent) return false;
return (matchState(torrent) && matchHash(torrent) && matchCategory(torrent) && matchTag(torrent));
}
bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) const
bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
{
switch (m_type)
{
@ -187,21 +187,21 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c @@ -187,21 +187,21 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c
}
}
bool TorrentFilter::matchHash(const BitTorrent::TorrentHandle *const torrent) const
bool TorrentFilter::matchHash(const BitTorrent::Torrent *const torrent) const
{
if (m_hashSet == AnyHash) return true;
return m_hashSet.contains(torrent->hash());
}
bool TorrentFilter::matchCategory(const BitTorrent::TorrentHandle *const torrent) const
bool TorrentFilter::matchCategory(const BitTorrent::Torrent *const torrent) const
{
if (m_category.isNull()) return true;
return (torrent->belongsToCategory(m_category));
}
bool TorrentFilter::matchTag(const BitTorrent::TorrentHandle *const torrent) const
bool TorrentFilter::matchTag(const BitTorrent::Torrent *const torrent) const
{
// Empty tag is a special value to indicate we're filtering for untagged torrents.
if (m_tag.isNull()) return true;

12
src/base/torrentfilter.h

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
using InfoHashSet = QSet<BitTorrent::InfoHash>;
@ -88,13 +88,13 @@ public: @@ -88,13 +88,13 @@ public:
bool setCategory(const QString &category);
bool setTag(const QString &tag);
bool match(const BitTorrent::TorrentHandle *torrent) const;
bool match(const BitTorrent::Torrent *torrent) const;
private:
bool matchState(const BitTorrent::TorrentHandle *torrent) const;
bool matchHash(const BitTorrent::TorrentHandle *torrent) const;
bool matchCategory(const BitTorrent::TorrentHandle *torrent) const;
bool matchTag(const BitTorrent::TorrentHandle *torrent) const;
bool matchState(const BitTorrent::Torrent *torrent) const;
bool matchHash(const BitTorrent::Torrent *torrent) const;
bool matchCategory(const BitTorrent::Torrent *torrent) const;
bool matchTag(const BitTorrent::Torrent *torrent) const;
Type m_type {All};
QString m_category;

6
src/gui/addnewtorrentdialog.cpp

@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/magneturi.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/exceptions.h"
#include "base/global.h"
#include "base/net/downloadmanager.h"
@ -275,7 +275,7 @@ bool AddNewTorrentDialog::loadTorrentImpl() @@ -275,7 +275,7 @@ bool AddNewTorrentDialog::loadTorrentImpl()
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
{
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
if (torrent)
{
if (torrent->isPrivate() || m_torrentInfo.isPrivate())
@ -316,7 +316,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) @@ -316,7 +316,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
{
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
if (torrent)
{
if (torrent->isPrivate())

12
src/gui/categoryfiltermodel.cpp

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
#include <QIcon>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "uithememanager.h"
@ -336,7 +336,7 @@ void CategoryFilterModel::categoryRemoved(const QString &categoryName) @@ -336,7 +336,7 @@ void CategoryFilterModel::categoryRemoved(const QString &categoryName)
}
}
void CategoryFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
void CategoryFilterModel::torrentAdded(BitTorrent::Torrent *const torrent)
{
CategoryModelItem *item = findItem(torrent->category());
Q_ASSERT(item);
@ -345,7 +345,7 @@ void CategoryFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) @@ -345,7 +345,7 @@ void CategoryFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
m_rootItem->childAt(0)->increaseTorrentsCount();
}
void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent)
{
CategoryModelItem *item = findItem(torrent->category());
Q_ASSERT(item);
@ -354,7 +354,7 @@ void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *con @@ -354,7 +354,7 @@ void CategoryFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *con
m_rootItem->childAt(0)->decreaseTorrentsCount();
}
void CategoryFilterModel::torrentCategoryChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldCategory)
void CategoryFilterModel::torrentCategoryChanged(BitTorrent::Torrent *const torrent, const QString &oldCategory)
{
QModelIndex i;
@ -403,7 +403,7 @@ void CategoryFilterModel::populate() @@ -403,7 +403,7 @@ void CategoryFilterModel::populate()
m_rootItem->addChild(UID_ALL, new CategoryModelItem(nullptr, tr("All"), torrents.count()));
// Uncategorized torrents
using Torrent = BitTorrent::TorrentHandle;
using Torrent = BitTorrent::Torrent;
m_rootItem->addChild(
UID_UNCATEGORIZED
, new CategoryModelItem(
@ -411,7 +411,7 @@ void CategoryFilterModel::populate() @@ -411,7 +411,7 @@ void CategoryFilterModel::populate()
, std::count_if(torrents.begin(), torrents.end()
, [](Torrent *torrent) { return torrent->category().isEmpty(); })));
using Torrent = BitTorrent::TorrentHandle;
using Torrent = BitTorrent::Torrent;
for (auto i = session->categories().cbegin(); i != session->categories().cend(); ++i)
{
const QString &category = i.key();

8
src/gui/categoryfiltermodel.h

@ -36,7 +36,7 @@ class CategoryModelItem; @@ -36,7 +36,7 @@ class CategoryModelItem;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
class CategoryFilterModel final : public QAbstractItemModel
@ -63,9 +63,9 @@ public: @@ -63,9 +63,9 @@ public:
private slots:
void categoryAdded(const QString &categoryName);
void categoryRemoved(const QString &categoryName);
void torrentAdded(BitTorrent::TorrentHandle *const torrent);
void torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent);
void torrentCategoryChanged(BitTorrent::TorrentHandle *const torrent, const QString &oldCategory);
void torrentAdded(BitTorrent::Torrent *const torrent);
void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent);
void torrentCategoryChanged(BitTorrent::Torrent *const torrent, const QString &oldCategory);
void subcategoriesSupportChanged();
private:

18
src/gui/mainwindow.cpp

@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/logger.h"
#include "base/net/downloadmanager.h"
@ -260,11 +260,11 @@ MainWindow::MainWindow(QWidget *parent) @@ -260,11 +260,11 @@ MainWindow::MainWindow(QWidget *parent)
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerlessStateChanged, m_transferListFiltersWidget, &TransferListFiltersWidget::changeTrackerless);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerSuccess
, m_transferListFiltersWidget, qOverload<const BitTorrent::TorrentHandle *, const QString &>(&TransferListFiltersWidget::trackerSuccess));
, m_transferListFiltersWidget, qOverload<const BitTorrent::Torrent *, const QString &>(&TransferListFiltersWidget::trackerSuccess));
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerError
, m_transferListFiltersWidget, qOverload<const BitTorrent::TorrentHandle *, const QString &>(&TransferListFiltersWidget::trackerError));
, m_transferListFiltersWidget, qOverload<const BitTorrent::Torrent *, const QString &>(&TransferListFiltersWidget::trackerError));
connect(BitTorrent::Session::instance(), &BitTorrent::Session::trackerWarning
, m_transferListFiltersWidget, qOverload<const BitTorrent::TorrentHandle *, const QString &>(&TransferListFiltersWidget::trackerWarning));
, m_transferListFiltersWidget, qOverload<const BitTorrent::Torrent *, const QString &>(&TransferListFiltersWidget::trackerWarning));
#ifdef Q_OS_MACOS
// Increase top spacing to avoid tab overlapping
@ -858,20 +858,20 @@ void MainWindow::addTorrentFailed(const QString &error) const @@ -858,20 +858,20 @@ void MainWindow::addTorrentFailed(const QString &error) const
}
// called when a torrent was added
void MainWindow::torrentNew(BitTorrent::TorrentHandle *const torrent) const
void MainWindow::torrentNew(BitTorrent::Torrent *const torrent) const
{
if (isTorrentAddedNotificationsEnabled())
showNotificationBaloon(tr("Torrent added"), tr("'%1' was added.", "e.g: xxx.avi was added.").arg(torrent->name()));
}
// called when a torrent has finished
void MainWindow::finishedTorrent(BitTorrent::TorrentHandle *const torrent) const
void MainWindow::finishedTorrent(BitTorrent::Torrent *const torrent) const
{
showNotificationBaloon(tr("Download completion"), tr("'%1' has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(torrent->name()));
}
// Notification when disk is full
void MainWindow::fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const
void MainWindow::fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const
{
showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error")
, tr("An I/O error occurred for torrent '%1'.\n Reason: %2"
@ -961,7 +961,7 @@ void MainWindow::displayExecutionLogTab() @@ -961,7 +961,7 @@ void MainWindow::displayExecutionLogTab()
// End of keyboard shortcuts slots
void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent)
void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent)
{
Preferences *const pref = Preferences::instance();
if (pref->recursiveDownloadDisabled()) return;
@ -1639,7 +1639,7 @@ void MainWindow::reloadSessionStats() @@ -1639,7 +1639,7 @@ void MainWindow::reloadSessionStats()
}
}
void MainWindow::reloadTorrentStats(const QVector<BitTorrent::TorrentHandle *> &torrents)
void MainWindow::reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents)
{
if (currentTabWidget() == m_transferListWidget)
{

12
src/gui/mainwindow.h

@ -58,7 +58,7 @@ class TransferListWidget; @@ -58,7 +58,7 @@ class TransferListWidget;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
namespace Net
@ -110,7 +110,7 @@ private slots: @@ -110,7 +110,7 @@ private slots:
void balloonClicked();
void writeSettings();
void readSettings();
void fullDiskError(BitTorrent::TorrentHandle *const torrent, const QString &msg) const;
void fullDiskError(BitTorrent::Torrent *const torrent, const QString &msg) const;
void handleDownloadFromUrlFailure(const QString &, const QString &) const;
void tabChanged(int newTab);
bool defineUILockPassword();
@ -127,12 +127,12 @@ private slots: @@ -127,12 +127,12 @@ private slots:
void displayExecutionLogTab();
void focusSearchFilter();
void reloadSessionStats();
void reloadTorrentStats(const QVector<BitTorrent::TorrentHandle *> &torrents);
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
void loadPreferences(bool configureSession = true);
void addTorrentFailed(const QString &error) const;
void torrentNew(BitTorrent::TorrentHandle *const torrent) const;
void finishedTorrent(BitTorrent::TorrentHandle *const torrent) const;
void askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent);
void torrentNew(BitTorrent::Torrent *const torrent) const;
void finishedTorrent(BitTorrent::Torrent *const torrent) const;
void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent);
void optionsSaved();
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
void handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser);

4
src/gui/previewselectdialog.cpp

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
#include <QTableView>
#include "base/bittorrent/common.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/preferences.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
#define SETTINGS_KEY(name) "PreviewSelectDialog/" name
PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::TorrentHandle *torrent)
PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent)
: QDialog(parent)
, m_ui(new Ui::PreviewSelectDialog)
, m_torrent(torrent)

6
src/gui/previewselectdialog.h

@ -36,7 +36,7 @@ class QStandardItemModel; @@ -36,7 +36,7 @@ class QStandardItemModel;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
namespace Ui
{
@ -60,7 +60,7 @@ public: @@ -60,7 +60,7 @@ public:
NB_COLUMNS
};
PreviewSelectDialog(QWidget *parent, const BitTorrent::TorrentHandle *torrent);
PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent);
~PreviewSelectDialog();
signals:
@ -78,7 +78,7 @@ private: @@ -78,7 +78,7 @@ private:
Ui::PreviewSelectDialog *m_ui;
QStandardItemModel *m_previewListModel;
PreviewListDelegate *m_listDelegate;
const BitTorrent::TorrentHandle *m_torrent;
const BitTorrent::Torrent *m_torrent;
bool m_headerStateInitialized = false;
// Settings

8
src/gui/properties/peerlistwidget.cpp

@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
#include "base/bittorrent/peeraddress.h"
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/logger.h"
#include "base/net/geoipmanager.h"
@ -260,7 +260,7 @@ void PeerListWidget::updatePeerCountryResolutionState() @@ -260,7 +260,7 @@ void PeerListWidget::updatePeerCountryResolutionState()
void PeerListWidget::showPeerListMenu(const QPoint &)
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
QMenu *menu = new QMenu(this);
@ -370,7 +370,7 @@ void PeerListWidget::saveSettings() const @@ -370,7 +370,7 @@ void PeerListWidget::saveSettings() const
Preferences::instance()->setPeerListState(header()->saveState());
}
void PeerListWidget::loadPeers(const BitTorrent::TorrentHandle *torrent)
void PeerListWidget::loadPeers(const BitTorrent::Torrent *torrent)
{
if (!torrent) return;
@ -406,7 +406,7 @@ void PeerListWidget::loadPeers(const BitTorrent::TorrentHandle *torrent) @@ -406,7 +406,7 @@ void PeerListWidget::loadPeers(const BitTorrent::TorrentHandle *torrent)
}
}
void PeerListWidget::updatePeer(const BitTorrent::TorrentHandle *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer)
void PeerListWidget::updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer)
{
const PeerEndpoint peerEndpoint {peer.address(), peer.connectionType()};
const QString peerIp = peerEndpoint.address.ip.toString();

6
src/gui/properties/peerlistwidget.h

@ -43,7 +43,7 @@ struct PeerEndpoint; @@ -43,7 +43,7 @@ struct PeerEndpoint;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
class PeerInfo;
}
@ -80,7 +80,7 @@ public: @@ -80,7 +80,7 @@ public:
explicit PeerListWidget(PropertiesWidget *parent);
~PeerListWidget() override;
void loadPeers(const BitTorrent::TorrentHandle *torrent);
void loadPeers(const BitTorrent::Torrent *torrent);
void updatePeerHostNameResolutionState();
void updatePeerCountryResolutionState();
void clear();
@ -96,7 +96,7 @@ private slots: @@ -96,7 +96,7 @@ private slots:
void handleResolved(const QHostAddress &ip, const QString &hostname) const;
private:
void updatePeer(const BitTorrent::TorrentHandle *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer);
void updatePeer(const BitTorrent::Torrent *torrent, const BitTorrent::PeerInfo &peer, bool &isNewPeer);
void wheelEvent(QWheelEvent *event) override;

4
src/gui/properties/piecesbar.cpp

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include <QToolTip>
#include "base/indexrange.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/utils/misc.h"
@ -119,7 +119,7 @@ PiecesBar::PiecesBar(QWidget *parent) @@ -119,7 +119,7 @@ PiecesBar::PiecesBar(QWidget *parent)
setMouseTracking(true);
}
void PiecesBar::setTorrent(const BitTorrent::TorrentHandle *torrent)
void PiecesBar::setTorrent(const BitTorrent::Torrent *torrent)
{
m_torrent = torrent;
if (!m_torrent)

6
src/gui/properties/piecesbar.h

@ -37,7 +37,7 @@ class QHelpEvent; @@ -37,7 +37,7 @@ class QHelpEvent;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
class PiecesBar : public QWidget
@ -49,7 +49,7 @@ class PiecesBar : public QWidget @@ -49,7 +49,7 @@ class PiecesBar : public QWidget
public:
explicit PiecesBar(QWidget *parent = nullptr);
void setTorrent(const BitTorrent::TorrentHandle *torrent);
void setTorrent(const BitTorrent::Torrent *torrent);
virtual void clear();
@ -87,7 +87,7 @@ private: @@ -87,7 +87,7 @@ private:
virtual bool updateImage(QImage &image) = 0;
void updatePieceColors();
const BitTorrent::TorrentHandle *m_torrent;
const BitTorrent::Torrent *m_torrent;
QImage m_image;
// buffered 256 levels gradient from bg_color to piece_color
QVector<QRgb> m_pieceColors;

14
src/gui/properties/propertieswidget.cpp

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
#include "base/bittorrent/downloadpriority.h"
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
#include "base/utils/fs.h"
@ -265,7 +265,7 @@ void PropertiesWidget::clear() @@ -265,7 +265,7 @@ void PropertiesWidget::clear()
m_propListModel->model()->clear();
}
BitTorrent::TorrentHandle *PropertiesWidget::getCurrentTorrent() const
BitTorrent::Torrent *PropertiesWidget::getCurrentTorrent() const
{
return m_torrent;
}
@ -285,25 +285,25 @@ QTreeView *PropertiesWidget::getFilesList() const @@ -285,25 +285,25 @@ QTreeView *PropertiesWidget::getFilesList() const
return m_ui->filesList;
}
void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent)
void PropertiesWidget::updateSavePath(BitTorrent::Torrent *const torrent)
{
if (torrent == m_torrent)
m_ui->labelSavePathVal->setText(Utils::Fs::toNativePath(m_torrent->savePath()));
}
void PropertiesWidget::loadTrackers(BitTorrent::TorrentHandle *const torrent)
void PropertiesWidget::loadTrackers(BitTorrent::Torrent *const torrent)
{
if (torrent == m_torrent)
m_trackerList->loadTrackers();
}
void PropertiesWidget::updateTorrentInfos(BitTorrent::TorrentHandle *const torrent)
void PropertiesWidget::updateTorrentInfos(BitTorrent::Torrent *const torrent)
{
if (torrent == m_torrent)
loadTorrentInfos(m_torrent);
}
void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent)
void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent)
{
clear();
m_torrent = torrent;
@ -437,7 +437,7 @@ void PropertiesWidget::loadDynamicData() @@ -437,7 +437,7 @@ void PropertiesWidget::loadDynamicData()
// Update ratio info
const qreal ratio = m_torrent->realRatio();
m_ui->labelShareRatioVal->setText(ratio > BitTorrent::TorrentHandle::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2));
m_ui->labelShareRatioVal->setText(ratio > BitTorrent::Torrent::MAX_RATIO ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2));
m_ui->labelSeedsVal->setText(tr("%1 (%2 total)", "%1 and %2 are numbers, e.g. 3 (10 total)")
.arg(QString::number(m_torrent->seedsCount())

14
src/gui/properties/propertieswidget.h

@ -45,7 +45,7 @@ class TrackerListWidget; @@ -45,7 +45,7 @@ class TrackerListWidget;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
namespace Ui
@ -68,24 +68,24 @@ public: @@ -68,24 +68,24 @@ public:
explicit PropertiesWidget(QWidget *parent);
~PropertiesWidget() override;
BitTorrent::TorrentHandle *getCurrentTorrent() const;
BitTorrent::Torrent *getCurrentTorrent() const;
TrackerListWidget *getTrackerList() const;
PeerListWidget *getPeerList() const;
QTreeView *getFilesList() const;
public slots:
void setVisibility(bool visible);
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
void loadTorrentInfos(BitTorrent::Torrent *const torrent);
void loadDynamicData();
void clear();
void readSettings();
void saveSettings();
void reloadPreferences();
void openItem(const QModelIndex &index) const;
void loadTrackers(BitTorrent::TorrentHandle *const torrent);
void loadTrackers(BitTorrent::Torrent *const torrent);
protected slots:
void updateTorrentInfos(BitTorrent::TorrentHandle *const torrent);
void updateTorrentInfos(BitTorrent::Torrent *const torrent);
void loadUrlSeeds();
void askWebSeed();
void deleteSelectedUrlSeeds();
@ -101,7 +101,7 @@ protected slots: @@ -101,7 +101,7 @@ protected slots:
private slots:
void configure();
void filterText(const QString &filter);
void updateSavePath(BitTorrent::TorrentHandle *const torrent);
void updateSavePath(BitTorrent::Torrent *const torrent);
private:
QPushButton *getButtonFromIndex(int index);
@ -110,7 +110,7 @@ private: @@ -110,7 +110,7 @@ private:
QString getFullPath(const QModelIndex &index) const;
Ui::PropertiesWidget *m_ui;
BitTorrent::TorrentHandle *m_torrent;
BitTorrent::Torrent *m_torrent;
SlideState m_state;
TorrentContentFilterModel *m_propListModel;
PropListDelegate *m_propListDelegate;

4
src/gui/properties/proplistdelegate.cpp

@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
#endif
#include "base/bittorrent/downloadpriority.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "gui/torrentcontentmodel.h"
#include "propertieswidget.h"
@ -111,7 +111,7 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI @@ -111,7 +111,7 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
if (m_properties)
{
const BitTorrent::TorrentHandle *torrent = m_properties->getCurrentTorrent();
const BitTorrent::Torrent *torrent = m_properties->getCurrentTorrent();
if (!torrent || !torrent->hasMetadata() || torrent->isSeed())
return nullptr;
}

22
src/gui/properties/trackerlistwidget.cpp

@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
#include "base/preferences.h"
@ -172,7 +172,7 @@ void TrackerListWidget::setRowColor(const int row, const QColor &color) @@ -172,7 +172,7 @@ void TrackerListWidget::setRowColor(const int row, const QColor &color)
void TrackerListWidget::moveSelectionUp()
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent)
{
clear();
@ -218,7 +218,7 @@ void TrackerListWidget::moveSelectionUp() @@ -218,7 +218,7 @@ void TrackerListWidget::moveSelectionUp()
void TrackerListWidget::moveSelectionDown()
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent)
{
clear();
@ -281,7 +281,7 @@ void TrackerListWidget::clear() @@ -281,7 +281,7 @@ void TrackerListWidget::clear()
m_LSDItem->setText(COL_MSG, "");
}
void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent)
void TrackerListWidget::loadStickyItems(const BitTorrent::Torrent *torrent)
{
const QString working {tr("Working")};
const QString disabled {tr("Disabled")};
@ -361,7 +361,7 @@ void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent @@ -361,7 +361,7 @@ void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent
void TrackerListWidget::loadTrackers()
{
// Load trackers from torrent handle
const BitTorrent::TorrentHandle *torrent = m_properties->getCurrentTorrent();
const BitTorrent::Torrent *torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
loadStickyItems(torrent);
@ -438,7 +438,7 @@ void TrackerListWidget::loadTrackers() @@ -438,7 +438,7 @@ void TrackerListWidget::loadTrackers()
// Ask the user for new trackers and add them to the torrent
void TrackerListWidget::askForTrackers()
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
QVector<BitTorrent::TrackerEntry> trackers;
@ -466,7 +466,7 @@ void TrackerListWidget::copyTrackerUrl() @@ -466,7 +466,7 @@ void TrackerListWidget::copyTrackerUrl()
void TrackerListWidget::deleteSelectedTrackers()
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent)
{
clear();
@ -504,7 +504,7 @@ void TrackerListWidget::deleteSelectedTrackers() @@ -504,7 +504,7 @@ void TrackerListWidget::deleteSelectedTrackers()
void TrackerListWidget::editSelectedTracker()
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
const QVector<QTreeWidgetItem *> selectedTrackerItems = getSelectedTrackerItems();
@ -555,7 +555,7 @@ void TrackerListWidget::reannounceSelected() @@ -555,7 +555,7 @@ void TrackerListWidget::reannounceSelected()
const QList<QTreeWidgetItem *> selItems = selectedItems();
if (selItems.isEmpty()) return;
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
const QVector<BitTorrent::TrackerEntry> trackers = torrent->trackers();
@ -585,7 +585,7 @@ void TrackerListWidget::reannounceSelected() @@ -585,7 +585,7 @@ void TrackerListWidget::reannounceSelected()
void TrackerListWidget::showTrackerListMenu(const QPoint &)
{
BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent();
BitTorrent::Torrent *const torrent = m_properties->getCurrentTorrent();
if (!torrent) return;
QMenu *menu = new QMenu(this);
@ -617,7 +617,7 @@ void TrackerListWidget::showTrackerListMenu(const QPoint &) @@ -617,7 +617,7 @@ void TrackerListWidget::showTrackerListMenu(const QPoint &)
const QAction *reannounceAllAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers"));
connect(reannounceAllAct, &QAction::triggered, this, [this]()
{
BitTorrent::TorrentHandle *h = m_properties->getCurrentTorrent();
BitTorrent::Torrent *h = m_properties->getCurrentTorrent();
h->forceReannounce();
h->forceDHTAnnounce();
});

4
src/gui/properties/trackerlistwidget.h

@ -35,7 +35,7 @@ class PropertiesWidget; @@ -35,7 +35,7 @@ class PropertiesWidget;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
class TrackerListWidget : public QTreeWidget
@ -70,7 +70,7 @@ public slots: @@ -70,7 +70,7 @@ public slots:
void moveSelectionDown();
void clear();
void loadStickyItems(const BitTorrent::TorrentHandle *torrent);
void loadStickyItems(const BitTorrent::Torrent *torrent);
void loadTrackers();
void askForTrackers();
void copyTrackerUrl();

6
src/gui/properties/trackersadditiondialog.cpp

@ -32,14 +32,14 @@ @@ -32,14 +32,14 @@
#include <QMessageBox>
#include <QStringList>
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
#include "base/net/downloadmanager.h"
#include "gui/uithememanager.h"
#include "ui_trackersadditiondialog.h"
TrackersAdditionDialog::TrackersAdditionDialog(QWidget *parent, BitTorrent::TorrentHandle *const torrent)
TrackersAdditionDialog::TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent)
: QDialog(parent)
, m_ui(new Ui::TrackersAdditionDialog())
, m_torrent(torrent)
@ -129,7 +129,7 @@ void TrackersAdditionDialog::torrentListDownloadFinished(const Net::DownloadResu @@ -129,7 +129,7 @@ void TrackersAdditionDialog::torrentListDownloadFinished(const Net::DownloadResu
QMessageBox::information(this, tr("No change"), tr("No additional trackers were found."), QMessageBox::Ok);
}
QStringList TrackersAdditionDialog::askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent)
QStringList TrackersAdditionDialog::askForTrackers(QWidget *parent, BitTorrent::Torrent *const torrent)
{
QStringList trackers;
TrackersAdditionDialog dlg(parent, torrent);

8
src/gui/properties/trackersadditiondialog.h

@ -35,7 +35,7 @@ class QString; @@ -35,7 +35,7 @@ class QString;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
namespace Net
@ -53,11 +53,11 @@ class TrackersAdditionDialog : public QDialog @@ -53,11 +53,11 @@ class TrackersAdditionDialog : public QDialog
Q_OBJECT
public:
TrackersAdditionDialog(QWidget *parent, BitTorrent::TorrentHandle *const torrent);
TrackersAdditionDialog(QWidget *parent, BitTorrent::Torrent *const torrent);
~TrackersAdditionDialog();
QStringList newTrackers() const;
static QStringList askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent);
static QStringList askForTrackers(QWidget *parent, BitTorrent::Torrent *const torrent);
public slots:
void on_uTorrentListButton_clicked();
@ -65,5 +65,5 @@ public slots: @@ -65,5 +65,5 @@ public slots:
private:
Ui::TrackersAdditionDialog *m_ui;
BitTorrent::TorrentHandle *const m_torrent;
BitTorrent::Torrent *const m_torrent;
};

2
src/gui/statsdialog.cpp

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#include "base/bittorrent/cachestatus.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"

12
src/gui/tagfiltermodel.cpp

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
#include <QVector>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "uithememanager.h"
@ -203,7 +203,7 @@ void TagFilterModel::tagRemoved(const QString &tag) @@ -203,7 +203,7 @@ void TagFilterModel::tagRemoved(const QString &tag)
endRemoveRows();
}
void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, const QString &tag)
void TagFilterModel::torrentTagAdded(BitTorrent::Torrent *const torrent, const QString &tag)
{
if (torrent->tags().count() == 1)
untaggedItem()->decreaseTorrentsCount();
@ -217,7 +217,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c @@ -217,7 +217,7 @@ void TagFilterModel::torrentTagAdded(BitTorrent::TorrentHandle *const torrent, c
emit dataChanged(i, i);
}
void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, const QString &tag)
void TagFilterModel::torrentTagRemoved(BitTorrent::Torrent *const torrent, const QString &tag)
{
if (torrent->tags().empty())
untaggedItem()->increaseTorrentsCount();
@ -232,7 +232,7 @@ void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent, @@ -232,7 +232,7 @@ void TagFilterModel::torrentTagRemoved(BitTorrent::TorrentHandle *const torrent,
emit dataChanged(i, i);
}
void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
void TagFilterModel::torrentAdded(BitTorrent::Torrent *const torrent)
{
allTagsItem()->increaseTorrentsCount();
@ -244,7 +244,7 @@ void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent) @@ -244,7 +244,7 @@ void TagFilterModel::torrentAdded(BitTorrent::TorrentHandle *const torrent)
item->increaseTorrentsCount();
}
void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
void TagFilterModel::torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent)
{
allTagsItem()->decreaseTorrentsCount();
@ -266,7 +266,7 @@ QString TagFilterModel::tagDisplayName(const QString &tag) @@ -266,7 +266,7 @@ QString TagFilterModel::tagDisplayName(const QString &tag)
void TagFilterModel::populate()
{
using Torrent = BitTorrent::TorrentHandle;
using Torrent = BitTorrent::Torrent;
const auto *session = BitTorrent::Session::instance();
const auto torrents = session->torrents();

10
src/gui/tagfiltermodel.h

@ -37,7 +37,7 @@ class TagModelItem; @@ -37,7 +37,7 @@ class TagModelItem;
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
class TagFilterModel final : public QAbstractListModel
@ -62,10 +62,10 @@ public: @@ -62,10 +62,10 @@ public:
private slots:
void tagAdded(const QString &tag);
void tagRemoved(const QString &tag);
void torrentTagAdded(BitTorrent::TorrentHandle *const torrent, const QString &tag);
void torrentTagRemoved(BitTorrent::TorrentHandle *const, const QString &tag);
void torrentAdded(BitTorrent::TorrentHandle *const torrent);
void torrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent);
void torrentTagAdded(BitTorrent::Torrent *const torrent, const QString &tag);
void torrentTagRemoved(BitTorrent::Torrent *const, const QString &tag);
void torrentAdded(BitTorrent::Torrent *const torrent);
void torrentAboutToBeRemoved(BitTorrent::Torrent *const torrent);
private:
static QString tagDisplayName(const QString &tag);

2
src/gui/torrentcontenttreeview.cpp

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
#include "base/bittorrent/abstractfilestorage.h"
#include "base/bittorrent/common.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/exceptions.h"
#include "base/global.h"

2
src/gui/torrentcontenttreeview.h

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
namespace BitTorrent
{
class AbstractFileStorage;
class TorrentHandle;
class Torrent;
class TorrentInfo;
}

4
src/gui/torrentcreatordialog.cpp

@ -246,8 +246,8 @@ void TorrentCreatorDialog::handleCreationSuccess(const QString &path, const QStr @@ -246,8 +246,8 @@ void TorrentCreatorDialog::handleCreationSuccess(const QString &path, const QStr
params.skipChecking = true;
if (m_ui->checkIgnoreShareLimits->isChecked())
{
params.ratioLimit = BitTorrent::TorrentHandle::NO_RATIO_LIMIT;
params.seedingTimeLimit = BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT;
params.ratioLimit = BitTorrent::Torrent::NO_RATIO_LIMIT;
params.seedingTimeLimit = BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT;
}
params.useAutoTMM = false; // otherwise if it is on by default, it will overwrite `savePath` to the default save path

24
src/gui/torrentoptionsdialog.cpp

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/unicodestrings.h"
#include "ui_torrentoptionsdialog.h"
@ -53,7 +53,7 @@ namespace @@ -53,7 +53,7 @@ namespace
}
}
TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTorrent::TorrentHandle *> &torrents)
TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTorrent::Torrent *> &torrents)
: QDialog {parent}
, m_ui {new Ui::TorrentOptionsDialog}
, m_storeDialogSize {SETTINGS_KEY("Size")}
@ -76,7 +76,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor @@ -76,7 +76,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
const bool isFirstTorrentLSDDisabled = torrents[0]->isLSDDisabled();
m_torrentHashes.reserve(torrents.size());
for (const BitTorrent::TorrentHandle *torrent : torrents)
for (const BitTorrent::Torrent *torrent : torrents)
{
m_torrentHashes << torrent->hash();
if (allSameUpLimit)
@ -180,8 +180,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor @@ -180,8 +180,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
}
const bool useGlobalValue = allSameRatio && allSameSeedingTime
&& (firstTorrentRatio == BitTorrent::TorrentHandle::USE_GLOBAL_RATIO)
&& (firstTorrentSeedingTime == BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME);
&& (firstTorrentRatio == BitTorrent::Torrent::USE_GLOBAL_RATIO)
&& (firstTorrentSeedingTime == BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME);
if (!allSameRatio || !allSameSeedingTime)
{
@ -193,8 +193,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor @@ -193,8 +193,8 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
{
m_ui->radioUseGlobalShareLimits->setChecked(true);
}
else if ((firstTorrentRatio == BitTorrent::TorrentHandle::NO_RATIO_LIMIT)
&& (firstTorrentSeedingTime == BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT))
else if ((firstTorrentRatio == BitTorrent::Torrent::NO_RATIO_LIMIT)
&& (firstTorrentSeedingTime == BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT))
{
m_ui->radioNoLimit->setChecked(true);
}
@ -288,7 +288,7 @@ void TorrentOptionsDialog::accept() @@ -288,7 +288,7 @@ void TorrentOptionsDialog::accept()
const auto *session = BitTorrent::Session::instance();
for (const BitTorrent::InfoHash &hash : asConst(m_torrentHashes))
{
BitTorrent::TorrentHandle *torrent = session->findTorrent(hash);
BitTorrent::Torrent *torrent = session->findTorrent(hash);
if (!torrent) continue;
if (m_initialValues.upSpeedLimit != m_ui->spinUploadLimit->value())
@ -324,10 +324,10 @@ qreal TorrentOptionsDialog::getRatio() const @@ -324,10 +324,10 @@ qreal TorrentOptionsDialog::getRatio() const
return MIXED_SHARE_LIMITS;
if (m_ui->radioUseGlobalShareLimits->isChecked())
return BitTorrent::TorrentHandle::USE_GLOBAL_RATIO;
return BitTorrent::Torrent::USE_GLOBAL_RATIO;
if (m_ui->radioNoLimit->isChecked() || !m_ui->checkMaxRatio->isChecked())
return BitTorrent::TorrentHandle::NO_RATIO_LIMIT;
return BitTorrent::Torrent::NO_RATIO_LIMIT;
return m_ui->spinRatioLimit->value();
}
@ -338,10 +338,10 @@ int TorrentOptionsDialog::getSeedingTime() const @@ -338,10 +338,10 @@ int TorrentOptionsDialog::getSeedingTime() const
return MIXED_SHARE_LIMITS;
if (m_ui->radioUseGlobalShareLimits->isChecked())
return BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME;
return BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME;
if (m_ui->radioNoLimit->isChecked() || !m_ui->checkMaxTime->isChecked())
return BitTorrent::TorrentHandle::NO_SEEDING_TIME_LIMIT;
return BitTorrent::Torrent::NO_SEEDING_TIME_LIMIT;
return m_ui->spinTimeLimit->value();
}

4
src/gui/torrentoptionsdialog.h

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
namespace BitTorrent
{
class InfoHash;
class TorrentHandle;
class Torrent;
}
namespace Ui
@ -49,7 +49,7 @@ class TorrentOptionsDialog final : public QDialog @@ -49,7 +49,7 @@ class TorrentOptionsDialog final : public QDialog
Q_DISABLE_COPY(TorrentOptionsDialog)
public:
explicit TorrentOptionsDialog(QWidget *parent, const QVector<BitTorrent::TorrentHandle *> &torrents);
explicit TorrentOptionsDialog(QWidget *parent, const QVector<BitTorrent::Torrent *> &torrents);
~TorrentOptionsDialog() override;
public slots:

26
src/gui/transferlistfilterswidget.cpp

@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
#include "base/logger.h"
@ -240,8 +240,8 @@ void StatusFilterWidget::updateTorrentNumbers() @@ -240,8 +240,8 @@ void StatusFilterWidget::updateTorrentNumbers()
int nbStalledDownloading = 0;
int nbErrored = 0;
const QVector<BitTorrent::TorrentHandle *> torrents = BitTorrent::Session::instance()->torrents();
for (const BitTorrent::TorrentHandle *torrent : torrents)
const QVector<BitTorrent::Torrent *> torrents = BitTorrent::Session::instance()->torrents();
for (const BitTorrent::Torrent *torrent : torrents)
{
if (torrent->isDownloading())
++nbDownloading;
@ -288,9 +288,9 @@ void StatusFilterWidget::applyFilter(int row) @@ -288,9 +288,9 @@ void StatusFilterWidget::applyFilter(int row)
transferList->applyStatusFilter(row);
}
void StatusFilterWidget::handleNewTorrent(BitTorrent::TorrentHandle *const) {}
void StatusFilterWidget::handleNewTorrent(BitTorrent::Torrent *const) {}
void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) {}
void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::Torrent *const) {}
TrackerFiltersList::TrackerFiltersList(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon)
: BaseFilterWidget(parent, transferList)
@ -577,7 +577,7 @@ void TrackerFiltersList::applyFilter(const int row) @@ -577,7 +577,7 @@ void TrackerFiltersList::applyFilter(const int row)
transferList->applyTrackerFilter(getInfoHashes(row));
}
void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torrent)
void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent)
{
const BitTorrent::InfoHash hash {torrent->hash()};
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
@ -591,7 +591,7 @@ void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torre @@ -591,7 +591,7 @@ void TrackerFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torre
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(++m_totalTorrents));
}
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent)
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent)
{
const BitTorrent::InfoHash hash {torrent->hash()};
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
@ -742,34 +742,34 @@ void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value) @@ -742,34 +742,34 @@ void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value)
m_trackerFilters->setDownloadTrackerFavicon(value);
}
void TransferListFiltersWidget::addTrackers(const BitTorrent::TorrentHandle *torrent, const QVector<BitTorrent::TrackerEntry> &trackers)
void TransferListFiltersWidget::addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers)
{
for (const BitTorrent::TrackerEntry &tracker : trackers)
m_trackerFilters->addItem(tracker.url(), torrent->hash());
}
void TransferListFiltersWidget::removeTrackers(const BitTorrent::TorrentHandle *torrent, const QVector<BitTorrent::TrackerEntry> &trackers)
void TransferListFiltersWidget::removeTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers)
{
for (const BitTorrent::TrackerEntry &tracker : trackers)
m_trackerFilters->removeItem(tracker.url(), torrent->hash());
}
void TransferListFiltersWidget::changeTrackerless(const BitTorrent::TorrentHandle *torrent, const bool trackerless)
void TransferListFiltersWidget::changeTrackerless(const BitTorrent::Torrent *torrent, const bool trackerless)
{
m_trackerFilters->changeTrackerless(trackerless, torrent->hash());
}
void TransferListFiltersWidget::trackerSuccess(const BitTorrent::TorrentHandle *torrent, const QString &tracker)
void TransferListFiltersWidget::trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerSuccess(torrent->hash(), tracker);
}
void TransferListFiltersWidget::trackerWarning(const BitTorrent::TorrentHandle *torrent, const QString &tracker)
void TransferListFiltersWidget::trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerWarning(torrent->hash(), tracker);
}
void TransferListFiltersWidget::trackerError(const BitTorrent::TorrentHandle *torrent, const QString &tracker)
void TransferListFiltersWidget::trackerError(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerError(torrent->hash(), tracker);
}

26
src/gui/transferlistfilterswidget.h

@ -40,7 +40,7 @@ class TransferListWidget; @@ -40,7 +40,7 @@ class TransferListWidget;
namespace BitTorrent
{
class InfoHash;
class TorrentHandle;
class Torrent;
class TrackerEntry;
}
@ -69,8 +69,8 @@ protected: @@ -69,8 +69,8 @@ protected:
private slots:
virtual void showMenu(const QPoint &) = 0;
virtual void applyFilter(int row) = 0;
virtual void handleNewTorrent(BitTorrent::TorrentHandle *const) = 0;
virtual void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) = 0;
virtual void handleNewTorrent(BitTorrent::Torrent *const) = 0;
virtual void torrentAboutToBeDeleted(BitTorrent::Torrent *const) = 0;
};
class StatusFilterWidget final : public BaseFilterWidget
@ -90,8 +90,8 @@ private: @@ -90,8 +90,8 @@ private:
// No need to redeclare them here as slots.
void showMenu(const QPoint &) override;
void applyFilter(int row) override;
void handleNewTorrent(BitTorrent::TorrentHandle *const) override;
void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const) override;
void handleNewTorrent(BitTorrent::Torrent *const) override;
void torrentAboutToBeDeleted(BitTorrent::Torrent *const) override;
};
class TrackerFiltersList final : public BaseFilterWidget
@ -122,8 +122,8 @@ private: @@ -122,8 +122,8 @@ private:
// No need to redeclare them here as slots.
void showMenu(const QPoint &) override;
void applyFilter(int row) override;
void handleNewTorrent(BitTorrent::TorrentHandle *const torrent) override;
void torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const torrent) override;
void handleNewTorrent(BitTorrent::Torrent *const torrent) override;
void torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent) override;
QString trackerFromRow(int row) const;
int rowFromTracker(const QString &tracker) const;
QSet<BitTorrent::InfoHash> getInfoHashes(int row) const;
@ -150,12 +150,12 @@ public: @@ -150,12 +150,12 @@ public:
void setDownloadTrackerFavicon(bool value);
public slots:
void addTrackers(const BitTorrent::TorrentHandle *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void removeTrackers(const BitTorrent::TorrentHandle *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void changeTrackerless(const BitTorrent::TorrentHandle *torrent, bool trackerless);
void trackerSuccess(const BitTorrent::TorrentHandle *torrent, const QString &tracker);
void trackerWarning(const BitTorrent::TorrentHandle *torrent, const QString &tracker);
void trackerError(const BitTorrent::TorrentHandle *torrent, const QString &tracker);
void addTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void removeTrackers(const BitTorrent::Torrent *torrent, const QVector<BitTorrent::TrackerEntry> &trackers);
void changeTrackerless(const BitTorrent::Torrent *torrent, bool trackerless);
void trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker);
void trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker);
void trackerError(const BitTorrent::Torrent *torrent, const QString &tracker);
signals:
void trackerSuccess(const BitTorrent::InfoHash &hash, const QString &tracker);

26
src/gui/transferlistmodel.cpp

@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
#include <QPalette>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/preferences.h"
#include "base/unicodestrings.h"
@ -133,7 +133,7 @@ TransferListModel::TransferListModel(QObject *parent) @@ -133,7 +133,7 @@ TransferListModel::TransferListModel(QObject *parent)
// Load the torrents
using namespace BitTorrent;
for (TorrentHandle *const torrent : asConst(Session::instance()->torrents()))
for (Torrent *const torrent : asConst(Session::instance()->torrents()))
addTorrent(torrent);
// Listen for torrent changes
@ -234,7 +234,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, @@ -234,7 +234,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
return {};
}
QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent, const int column) const
QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, const int column) const
{
bool hideValues = false;
if (m_hideZeroValuesMode == HideZeroValuesMode::Always)
@ -276,7 +276,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent @@ -276,7 +276,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent
if (hideValues && (value <= 0))
return {};
return ((static_cast<int>(value) == -1) || (value > BitTorrent::TorrentHandle::MAX_RATIO))
return ((static_cast<int>(value) == -1) || (value > BitTorrent::Torrent::MAX_RATIO))
? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(value, 2);
};
@ -399,7 +399,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent @@ -399,7 +399,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent
return {};
}
QVariant TransferListModel::internalValue(const BitTorrent::TorrentHandle *torrent, const int column, const bool alt) const
QVariant TransferListModel::internalValue(const BitTorrent::Torrent *torrent, const int column, const bool alt) const
{
switch (column)
{
@ -474,7 +474,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const @@ -474,7 +474,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
{
if (!index.isValid()) return {};
const BitTorrent::TorrentHandle *torrent = m_torrentList.value(index.row());
const BitTorrent::Torrent *torrent = m_torrentList.value(index.row());
if (!torrent) return {};
switch (role)
@ -537,7 +537,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, @@ -537,7 +537,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
{
if (!index.isValid() || (role != Qt::DisplayRole)) return false;
BitTorrent::TorrentHandle *const torrent = m_torrentList.value(index.row());
BitTorrent::Torrent *const torrent = m_torrentList.value(index.row());
if (!torrent) return false;
// Category and Name columns can be edited
@ -556,7 +556,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value, @@ -556,7 +556,7 @@ bool TransferListModel::setData(const QModelIndex &index, const QVariant &value,
return true;
}
void TransferListModel::addTorrent(BitTorrent::TorrentHandle *const torrent)
void TransferListModel::addTorrent(BitTorrent::Torrent *const torrent)
{
Q_ASSERT(!m_torrentMap.contains(torrent));
@ -576,14 +576,14 @@ Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const @@ -576,14 +576,14 @@ Qt::ItemFlags TransferListModel::flags(const QModelIndex &index) const
return QAbstractListModel::flags(index) | Qt::ItemIsEditable;
}
BitTorrent::TorrentHandle *TransferListModel::torrentHandle(const QModelIndex &index) const
BitTorrent::Torrent *TransferListModel::torrentHandle(const QModelIndex &index) const
{
if (!index.isValid()) return nullptr;
return m_torrentList.value(index.row());
}
void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent)
void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::Torrent *const torrent)
{
const int row = m_torrentMap.value(torrent, -1);
Q_ASSERT(row >= 0);
@ -599,7 +599,7 @@ void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle @@ -599,7 +599,7 @@ void TransferListModel::handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle
endRemoveRows();
}
void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent)
void TransferListModel::handleTorrentStatusUpdated(BitTorrent::Torrent *const torrent)
{
const int row = m_torrentMap.value(torrent, -1);
Q_ASSERT(row >= 0);
@ -607,13 +607,13 @@ void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *co @@ -607,13 +607,13 @@ void TransferListModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *co
emit dataChanged(index(row, 0), index(row, columnCount() - 1));
}
void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents)
void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::Torrent *> &torrents)
{
const int columns = (columnCount() - 1);
if (torrents.size() <= (m_torrentList.size() * 0.5))
{
for (BitTorrent::TorrentHandle *const torrent : torrents)
for (BitTorrent::Torrent *const torrent : torrents)
{
const int row = m_torrentMap.value(torrent, -1);
Q_ASSERT(row >= 0);

20
src/gui/transferlistmodel.h

@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
#include <QHash>
#include <QList>
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
namespace BitTorrent
{
@ -99,21 +99,21 @@ public: @@ -99,21 +99,21 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
BitTorrent::TorrentHandle *torrentHandle(const QModelIndex &index) const;
BitTorrent::Torrent *torrentHandle(const QModelIndex &index) const;
private slots:
void addTorrent(BitTorrent::TorrentHandle *const torrent);
void handleTorrentAboutToBeRemoved(BitTorrent::TorrentHandle *const torrent);
void handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent);
void handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents);
void addTorrent(BitTorrent::Torrent *const torrent);
void handleTorrentAboutToBeRemoved(BitTorrent::Torrent *const torrent);
void handleTorrentStatusUpdated(BitTorrent::Torrent *const torrent);
void handleTorrentsUpdated(const QVector<BitTorrent::Torrent *> &torrents);
private:
void configure();
QString displayValue(const BitTorrent::TorrentHandle *torrent, int column) const;
QVariant internalValue(const BitTorrent::TorrentHandle *torrent, int column, bool alt = false) const;
QString displayValue(const BitTorrent::Torrent *torrent, int column) const;
QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt = false) const;
QList<BitTorrent::TorrentHandle *> m_torrentList; // maps row number to torrent handle
QHash<BitTorrent::TorrentHandle *, int> m_torrentMap; // maps torrent handle to row number
QList<BitTorrent::Torrent *> m_torrentList; // maps row number to torrent handle
QHash<BitTorrent::Torrent *, int> m_torrentMap; // maps torrent handle to row number
const QHash<BitTorrent::TorrentState, QString> m_statusStrings;
// row text colors
const QHash<BitTorrent::TorrentState, QColor> m_stateThemeColors;

4
src/gui/transferlistsortmodel.cpp

@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
#include <QDateTime>
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/global.h"
#include "base/types.h"
#include "base/utils/string.h"
@ -292,7 +292,7 @@ bool TransferListSortModel::matchFilter(const int sourceRow, const QModelIndex & @@ -292,7 +292,7 @@ bool TransferListSortModel::matchFilter(const int sourceRow, const QModelIndex &
const auto *model = qobject_cast<TransferListModel *>(sourceModel());
if (!model) return false;
const BitTorrent::TorrentHandle *torrent = model->torrentHandle(model->index(sourceRow, 0, sourceParent));
const BitTorrent::Torrent *torrent = model->torrentHandle(model->index(sourceRow, 0, sourceParent));
if (!torrent) return false;
return m_filter.match(torrent);

96
src/gui/transferlistwidget.cpp

@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
#include "base/logger.h"
@ -77,16 +77,16 @@ @@ -77,16 +77,16 @@
namespace
{
QVector<BitTorrent::InfoHash> extractHashes(const QVector<BitTorrent::TorrentHandle *> &torrents)
QVector<BitTorrent::InfoHash> extractHashes(const QVector<BitTorrent::Torrent *> &torrents)
{
QVector<BitTorrent::InfoHash> hashes;
hashes.reserve(torrents.size());
for (const BitTorrent::TorrentHandle *torrent : torrents)
for (const BitTorrent::Torrent *torrent : torrents)
hashes << torrent->hash();
return hashes;
}
bool torrentContainsPreviewableFiles(const BitTorrent::TorrentHandle *const torrent)
bool torrentContainsPreviewableFiles(const BitTorrent::Torrent *const torrent)
{
if (!torrent->hasMetadata())
return false;
@ -100,7 +100,7 @@ namespace @@ -100,7 +100,7 @@ namespace
return false;
}
void openDestinationFolder(const BitTorrent::TorrentHandle *const torrent)
void openDestinationFolder(const BitTorrent::Torrent *const torrent)
{
#ifdef Q_OS_MACOS
MacUtils::openFiles({torrent->contentPath(true)});
@ -112,11 +112,11 @@ namespace @@ -112,11 +112,11 @@ namespace
#endif
}
void removeTorrents(const QVector<BitTorrent::TorrentHandle *> &torrents, const bool isDeleteFileSelected)
void removeTorrents(const QVector<BitTorrent::Torrent *> &torrents, const bool isDeleteFileSelected)
{
auto *session = BitTorrent::Session::instance();
const DeleteOption deleteOption = isDeleteFileSelected ? TorrentAndFiles : Torrent;
for (const BitTorrent::TorrentHandle *torrent : torrents)
const DeleteOption deleteOption = isDeleteFileSelected ? DeleteTorrentAndFiles : DeleteTorrent;
for (const BitTorrent::Torrent *torrent : torrents)
session->deleteTorrent(torrent->hash(), deleteOption);
}
}
@ -271,7 +271,7 @@ void TransferListWidget::torrentDoubleClicked() @@ -271,7 +271,7 @@ void TransferListWidget::torrentDoubleClicked()
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
const QModelIndex index = m_listModel->index(mapToSource(selectedIndexes.first()).row());
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(index);
BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(index);
if (!torrent) return;
int action;
@ -307,22 +307,22 @@ void TransferListWidget::torrentDoubleClicked() @@ -307,22 +307,22 @@ void TransferListWidget::torrentDoubleClicked()
}
}
QVector<BitTorrent::TorrentHandle *> TransferListWidget::getSelectedTorrents() const
QVector<BitTorrent::Torrent *> TransferListWidget::getSelectedTorrents() const
{
const QModelIndexList selectedRows = selectionModel()->selectedRows();
QVector<BitTorrent::TorrentHandle *> torrents;
QVector<BitTorrent::Torrent *> torrents;
torrents.reserve(selectedRows.size());
for (const QModelIndex &index : selectedRows)
torrents << m_listModel->torrentHandle(mapToSource(index));
return torrents;
}
QVector<BitTorrent::TorrentHandle *> TransferListWidget::getVisibleTorrents() const
QVector<BitTorrent::Torrent *> TransferListWidget::getVisibleTorrents() const
{
const int visibleTorrentsCount = m_sortFilterModel->rowCount();
QVector<BitTorrent::TorrentHandle *> torrents;
QVector<BitTorrent::Torrent *> torrents;
torrents.reserve(visibleTorrentsCount);
for (int i = 0; i < visibleTorrentsCount; ++i)
torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0)));
@ -331,7 +331,7 @@ QVector<BitTorrent::TorrentHandle *> TransferListWidget::getVisibleTorrents() co @@ -331,7 +331,7 @@ QVector<BitTorrent::TorrentHandle *> TransferListWidget::getVisibleTorrents() co
void TransferListWidget::setSelectedTorrentsLocation()
{
const QVector<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
if (torrents.isEmpty()) return;
const QString oldLocation = torrents[0]->savePath();
@ -340,49 +340,49 @@ void TransferListWidget::setSelectedTorrentsLocation() @@ -340,49 +340,49 @@ void TransferListWidget::setSelectedTorrentsLocation()
if (newLocation.isEmpty() || !QDir(newLocation).exists()) return;
// Actually move storage
for (BitTorrent::TorrentHandle *const torrent : torrents)
for (BitTorrent::Torrent *const torrent : torrents)
torrent->move(Utils::Fs::expandPathAbs(newLocation));
}
void TransferListWidget::pauseAllTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->pause();
}
void TransferListWidget::resumeAllTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
torrent->resume();
}
void TransferListWidget::startSelectedTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->resume();
}
void TransferListWidget::forceStartSelectedTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->resume(BitTorrent::TorrentOperatingMode::Forced);
}
void TransferListWidget::startVisibleTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
torrent->resume();
}
void TransferListWidget::pauseSelectedTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->pause();
}
void TransferListWidget::pauseVisibleTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getVisibleTorrents()))
torrent->pause();
}
@ -400,7 +400,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) @@ -400,7 +400,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles)
{
if (m_mainWindow->currentTabWidget() != this) return;
const QVector<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
if (torrents.empty()) return;
if (Preferences::instance()->confirmTorrentDeletion())
@ -423,7 +423,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) @@ -423,7 +423,7 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles)
void TransferListWidget::deleteVisibleTorrents()
{
const QVector<BitTorrent::TorrentHandle *> torrents = getVisibleTorrents();
const QVector<BitTorrent::Torrent *> torrents = getVisibleTorrents();
if (torrents.empty()) return;
if (Preferences::instance()->confirmTorrentDeletion())
@ -473,7 +473,7 @@ void TransferListWidget::bottomQueuePosSelectedTorrents() @@ -473,7 +473,7 @@ void TransferListWidget::bottomQueuePosSelectedTorrents()
void TransferListWidget::copySelectedMagnetURIs() const
{
QStringList magnetUris;
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
magnetUris << torrent->createMagnetURI();
qApp->clipboard()->setText(magnetUris.join('\n'));
@ -482,7 +482,7 @@ void TransferListWidget::copySelectedMagnetURIs() const @@ -482,7 +482,7 @@ void TransferListWidget::copySelectedMagnetURIs() const
void TransferListWidget::copySelectedNames() const
{
QStringList torrentNames;
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrentNames << torrent->name();
qApp->clipboard()->setText(torrentNames.join('\n'));
@ -491,7 +491,7 @@ void TransferListWidget::copySelectedNames() const @@ -491,7 +491,7 @@ void TransferListWidget::copySelectedNames() const
void TransferListWidget::copySelectedHashes() const
{
QStringList torrentHashes;
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrentHashes << torrent->hash();
qApp->clipboard()->setText(torrentHashes.join('\n'));
@ -510,14 +510,14 @@ void TransferListWidget::openSelectedTorrentsFolder() const @@ -510,14 +510,14 @@ void TransferListWidget::openSelectedTorrentsFolder() const
#ifdef Q_OS_MACOS
// On macOS you expect both the files and folders to be opened in their parent
// folders prehilighted for opening, so we use a custom method.
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
{
QString path = torrent->contentPath(true);
pathsList.insert(path);
}
MacUtils::openFiles(pathsList);
#else
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
{
QString path = torrent->contentPath(true);
if (!pathsList.contains(path))
@ -534,7 +534,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const @@ -534,7 +534,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
void TransferListWidget::previewSelectedTorrents()
{
for (const BitTorrent::TorrentHandle *torrent : asConst(getSelectedTorrents()))
for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))
{
if (torrentContainsPreviewableFiles(torrent))
{
@ -553,7 +553,7 @@ void TransferListWidget::previewSelectedTorrents() @@ -553,7 +553,7 @@ void TransferListWidget::previewSelectedTorrents()
void TransferListWidget::setTorrentOptions()
{
const QVector<BitTorrent::TorrentHandle *> selectedTorrents = getSelectedTorrents();
const QVector<BitTorrent::Torrent *> selectedTorrents = getSelectedTorrents();
if (selectedTorrents.empty()) return;
auto dialog = new TorrentOptionsDialog {this, selectedTorrents};
@ -569,13 +569,13 @@ void TransferListWidget::recheckSelectedTorrents() @@ -569,13 +569,13 @@ void TransferListWidget::recheckSelectedTorrents()
if (ret != QMessageBox::Yes) return;
}
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->forceRecheck();
}
void TransferListWidget::reannounceSelectedTorrents()
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->forceReannounce();
}
@ -627,7 +627,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) @@ -627,7 +627,7 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
void TransferListWidget::setSelectedTorrentsSuperSeeding(const bool enabled) const
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
{
if (torrent->hasMetadata())
torrent->setSuperSeeding(enabled);
@ -636,19 +636,19 @@ void TransferListWidget::setSelectedTorrentsSuperSeeding(const bool enabled) con @@ -636,19 +636,19 @@ void TransferListWidget::setSelectedTorrentsSuperSeeding(const bool enabled) con
void TransferListWidget::setSelectedTorrentsSequentialDownload(const bool enabled) const
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->setSequentialDownload(enabled);
}
void TransferListWidget::setSelectedFirstLastPiecePrio(const bool enabled) const
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->setFirstLastPiecePriority(enabled);
}
void TransferListWidget::setSelectedAutoTMMEnabled(const bool enabled) const
{
for (BitTorrent::TorrentHandle *const torrent : asConst(getSelectedTorrents()))
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrent->setAutoTMMEnabled(enabled);
}
@ -668,14 +668,14 @@ void TransferListWidget::askAddTagsForSelection() @@ -668,14 +668,14 @@ void TransferListWidget::askAddTagsForSelection()
void TransferListWidget::editTorrentTrackers()
{
const QVector<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
QVector<BitTorrent::TrackerEntry> commonTrackers;
if (!torrents.empty())
{
commonTrackers = torrents[0]->trackers();
for (const BitTorrent::TorrentHandle *torrent : torrents)
for (const BitTorrent::Torrent *torrent : torrents)
{
QSet<BitTorrent::TrackerEntry> trackerSet;
@ -694,7 +694,7 @@ void TransferListWidget::editTorrentTrackers() @@ -694,7 +694,7 @@ void TransferListWidget::editTorrentTrackers()
connect(trackerDialog, &QDialog::accepted, this, [torrents, trackerDialog]()
{
for (BitTorrent::TorrentHandle *torrent : torrents)
for (BitTorrent::Torrent *torrent : torrents)
torrent->replaceTrackers(trackerDialog->trackers());
});
@ -737,11 +737,11 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle) @@ -737,11 +737,11 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle)
return tags;
}
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn)
void TransferListWidget::applyToSelectedTorrents(const std::function<void (BitTorrent::Torrent *const)> &fn)
{
for (const QModelIndex &index : asConst(selectionModel()->selectedRows()))
{
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(index));
BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mapToSource(index));
Q_ASSERT(torrent);
fn(torrent);
}
@ -753,7 +753,7 @@ void TransferListWidget::renameSelectedTorrent() @@ -753,7 +753,7 @@ void TransferListWidget::renameSelectedTorrent()
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
const QModelIndex mi = m_listModel->index(mapToSource(selectedIndexes.first()).row(), TransferListModel::TR_NAME);
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mi);
BitTorrent::Torrent *const torrent = m_listModel->torrentHandle(mi);
if (!torrent) return;
// Ask for a new Name
@ -775,17 +775,17 @@ void TransferListWidget::setSelectionCategory(const QString &category) @@ -775,17 +775,17 @@ void TransferListWidget::setSelectionCategory(const QString &category)
void TransferListWidget::addSelectionTag(const QString &tag)
{
applyToSelectedTorrents([&tag](BitTorrent::TorrentHandle *const torrent) { torrent->addTag(tag); });
applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->addTag(tag); });
}
void TransferListWidget::removeSelectionTag(const QString &tag)
{
applyToSelectedTorrents([&tag](BitTorrent::TorrentHandle *const torrent) { torrent->removeTag(tag); });
applyToSelectedTorrents([&tag](BitTorrent::Torrent *const torrent) { torrent->removeTag(tag); });
}
void TransferListWidget::clearSelectionTags()
{
applyToSelectedTorrents([](BitTorrent::TorrentHandle *const torrent) { torrent->removeAllTags(); });
applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); });
}
void TransferListWidget::displayListMenu(const QPoint &)
@ -866,7 +866,7 @@ void TransferListWidget::displayListMenu(const QPoint &) @@ -866,7 +866,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
{
// Get the file name
// Get handle and pause the torrent
const BitTorrent::TorrentHandle *torrent = m_listModel->torrentHandle(mapToSource(index));
const BitTorrent::Torrent *torrent = m_listModel->torrentHandle(mapToSource(index));
if (!torrent) continue;
if (firstCategory.isEmpty() && first)
@ -1100,7 +1100,7 @@ void TransferListWidget::displayListMenu(const QPoint &) @@ -1100,7 +1100,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
void TransferListWidget::currentChanged(const QModelIndex &current, const QModelIndex&)
{
qDebug("CURRENT CHANGED");
BitTorrent::TorrentHandle *torrent = nullptr;
BitTorrent::Torrent *torrent = nullptr;
if (current.isValid())
{
torrent = m_listModel->torrentHandle(mapToSource(current));

10
src/gui/transferlistwidget.h

@ -40,7 +40,7 @@ class TransferListSortModel; @@ -40,7 +40,7 @@ class TransferListSortModel;
namespace BitTorrent
{
class InfoHash;
class TorrentHandle;
class Torrent;
}
class TransferListWidget final : public QTreeView
@ -96,7 +96,7 @@ protected: @@ -96,7 +96,7 @@ protected:
QModelIndex mapToSource(const QModelIndex &index) const;
QModelIndex mapFromSource(const QModelIndex &index) const;
bool loadSettings();
QVector<BitTorrent::TorrentHandle *> getSelectedTorrents() const;
QVector<BitTorrent::Torrent *> getSelectedTorrents() const;
protected slots:
void torrentDoubleClicked();
@ -110,7 +110,7 @@ protected slots: @@ -110,7 +110,7 @@ protected slots:
void saveSettings();
signals:
void currentTorrentChanged(BitTorrent::TorrentHandle *const torrent);
void currentTorrentChanged(BitTorrent::Torrent *const torrent);
private:
void wheelEvent(QWheelEvent *event) override;
@ -118,8 +118,8 @@ private: @@ -118,8 +118,8 @@ private:
void editTorrentTrackers();
void confirmRemoveAllTagsForSelection();
QStringList askTagsForSelection(const QString &dialogTitle);
void applyToSelectedTorrents(const std::function<void (BitTorrent::TorrentHandle *const)> &fn);
QVector<BitTorrent::TorrentHandle *> getVisibleTorrents() const;
void applyToSelectedTorrents(const std::function<void (BitTorrent::Torrent *const)> &fn);
QVector<BitTorrent::Torrent *> getVisibleTorrents() const;
TransferListDelegate *m_listDelegate;
TransferListModel *m_listModel;

6
src/webui/api/serialize/serialize_torrent.cpp

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
#include <QVector>
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/utils/fs.h"
@ -83,7 +83,7 @@ namespace @@ -83,7 +83,7 @@ namespace
}
}
QVariantMap serialize(const BitTorrent::TorrentHandle &torrent)
QVariantMap serialize(const BitTorrent::Torrent &torrent)
{
QVariantMap ret =
{
@ -136,7 +136,7 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) @@ -136,7 +136,7 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent)
};
const qreal ratio = torrent.realRatio();
ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio;
ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::Torrent::MAX_RATIO) ? -1 : ratio;
if (torrent.isPaused() || torrent.isChecking())
{

4
src/webui/api/serialize/serialize_torrent.h

@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
namespace BitTorrent
{
class TorrentHandle;
class Torrent;
}
// Torrent keys
@ -82,4 +82,4 @@ const char KEY_TORRENT_AUTO_TORRENT_MANAGEMENT[] = "auto_tmm"; @@ -82,4 +82,4 @@ const char KEY_TORRENT_AUTO_TORRENT_MANAGEMENT[] = "auto_tmm";
const char KEY_TORRENT_TIME_ACTIVE[] = "time_active";
const char KEY_TORRENT_AVAILABILITY[] = "availability";
QVariantMap serialize(const BitTorrent::TorrentHandle &torrent);
QVariantMap serialize(const BitTorrent::Torrent &torrent);

6
src/webui/api/synccontroller.cpp

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include "base/bittorrent/peeraddress.h"
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
#include "base/net/geoipmanager.h"
@ -458,7 +458,7 @@ void SyncController::maindataAction() @@ -458,7 +458,7 @@ void SyncController::maindataAction()
QVariantHash torrents;
QHash<QString, QStringList> trackers;
for (const BitTorrent::TorrentHandle *torrent : asConst(session->torrents()))
for (const BitTorrent::Torrent *torrent : asConst(session->torrents()))
{
const BitTorrent::InfoHash torrentHash = torrent->hash();
@ -542,7 +542,7 @@ void SyncController::torrentPeersAction() @@ -542,7 +542,7 @@ void SyncController::torrentPeersAction()
auto lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastAcceptedResponse")).toMap();
const QString hash {params()["hash"]};
const BitTorrent::TorrentHandle *torrent = BitTorrent::Session::instance()->findTorrent(hash);
const BitTorrent::Torrent *torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);

84
src/webui/api/torrentscontroller.cpp

@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
#include "base/bittorrent/peeraddress.h"
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/torrent.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/trackerentry.h"
#include "base/global.h"
@ -118,25 +118,25 @@ namespace @@ -118,25 +118,25 @@ namespace
{
using Utils::String::parseBool;
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::TorrentHandle *torrent)> &func)
void applyToTorrents(const QStringList &hashes, const std::function<void (BitTorrent::Torrent *torrent)> &func)
{
if ((hashes.size() == 1) && (hashes[0] == QLatin1String("all")))
{
for (BitTorrent::TorrentHandle *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
for (BitTorrent::Torrent *const torrent : asConst(BitTorrent::Session::instance()->torrents()))
func(torrent);
}
else
{
for (const QString &hash : hashes)
{
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (torrent)
func(torrent);
}
}
}
QJsonArray getStickyTrackers(const BitTorrent::TorrentHandle *const torrent)
QJsonArray getStickyTrackers(const BitTorrent::Torrent *const torrent)
{
int seedsDHT = 0, seedsPeX = 0, seedsLSD = 0, leechesDHT = 0, leechesPeX = 0, leechesLSD = 0;
for (const BitTorrent::PeerInfo &peer : asConst(torrent->peers()))
@ -263,7 +263,7 @@ void TorrentsController::infoAction() @@ -263,7 +263,7 @@ void TorrentsController::infoAction()
const TorrentFilter torrentFilter(filter, (hashes.isEmpty() ? TorrentFilter::AnyHash : hashSet), category);
QVariantList torrentList;
for (const BitTorrent::TorrentHandle *torrent : asConst(BitTorrent::Session::instance()->torrents()))
for (const BitTorrent::Torrent *torrent : asConst(BitTorrent::Session::instance()->torrents()))
{
if (torrentFilter.match(torrent))
torrentList.append(serialize(*torrent));
@ -372,7 +372,7 @@ void TorrentsController::propertiesAction() @@ -372,7 +372,7 @@ void TorrentsController::propertiesAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -401,7 +401,7 @@ void TorrentsController::propertiesAction() @@ -401,7 +401,7 @@ void TorrentsController::propertiesAction()
dataDict[KEY_PROP_PEERS] = torrent->leechsCount();
dataDict[KEY_PROP_PEERS_TOTAL] = torrent->totalLeechersCount();
const qreal ratio = torrent->realRatio();
dataDict[KEY_PROP_RATIO] = ratio > BitTorrent::TorrentHandle::MAX_RATIO ? -1 : ratio;
dataDict[KEY_PROP_RATIO] = ratio > BitTorrent::Torrent::MAX_RATIO ? -1 : ratio;
dataDict[KEY_PROP_REANNOUNCE] = torrent->nextAnnounce();
dataDict[KEY_PROP_TOTAL_SIZE] = torrent->totalSize();
dataDict[KEY_PROP_PIECES_NUM] = torrent->piecesCount();
@ -443,7 +443,7 @@ void TorrentsController::trackersAction() @@ -443,7 +443,7 @@ void TorrentsController::trackersAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -479,7 +479,7 @@ void TorrentsController::webseedsAction() @@ -479,7 +479,7 @@ void TorrentsController::webseedsAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -510,7 +510,7 @@ void TorrentsController::filesAction() @@ -510,7 +510,7 @@ void TorrentsController::filesAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -556,7 +556,7 @@ void TorrentsController::pieceHashesAction() @@ -556,7 +556,7 @@ void TorrentsController::pieceHashesAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -578,7 +578,7 @@ void TorrentsController::pieceStatesAction() @@ -578,7 +578,7 @@ void TorrentsController::pieceStatesAction()
requireParams({"hash"});
const QString hash {params()["hash"]};
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -684,7 +684,7 @@ void TorrentsController::addTrackersAction() @@ -684,7 +684,7 @@ void TorrentsController::addTrackersAction()
requireParams({"hash", "urls"});
const QString hash = params()["hash"];
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -706,7 +706,7 @@ void TorrentsController::editTrackerAction() @@ -706,7 +706,7 @@ void TorrentsController::editTrackerAction()
const QString origUrl = params()["origUrl"];
const QString newUrl = params()["newUrl"];
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -746,7 +746,7 @@ void TorrentsController::removeTrackersAction() @@ -746,7 +746,7 @@ void TorrentsController::removeTrackersAction()
requireParams({"hash", "urls"});
const QString hash = params()["hash"];
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -791,7 +791,7 @@ void TorrentsController::addPeersAction() @@ -791,7 +791,7 @@ void TorrentsController::addPeersAction()
QJsonObject results;
applyToTorrents(hashes, [peers, peerList, &results](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [peers, peerList, &results](BitTorrent::Torrent *const torrent)
{
const int peersAdded = std::count_if(peerList.cbegin(), peerList.cend(), [torrent](const BitTorrent::PeerAddress &peer)
{
@ -813,7 +813,7 @@ void TorrentsController::pauseAction() @@ -813,7 +813,7 @@ void TorrentsController::pauseAction()
requireParams({"hashes"});
const QStringList hashes = params()["hashes"].split('|');
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->pause(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->pause(); });
}
void TorrentsController::resumeAction()
@ -821,7 +821,7 @@ void TorrentsController::resumeAction() @@ -821,7 +821,7 @@ void TorrentsController::resumeAction()
requireParams({"hashes"});
const QStringList hashes = params()["hashes"].split('|');
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->resume(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->resume(); });
}
void TorrentsController::filePrioAction()
@ -837,7 +837,7 @@ void TorrentsController::filePrioAction() @@ -837,7 +837,7 @@ void TorrentsController::filePrioAction()
if (!BitTorrent::isValidDownloadPriority(priority))
throw APIError(APIErrorType::BadParams, tr("Priority is not valid"));
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
if (!torrent->hasMetadata())
@ -874,7 +874,7 @@ void TorrentsController::uploadLimitAction() @@ -874,7 +874,7 @@ void TorrentsController::uploadLimitAction()
for (const QString &hash : hashes)
{
int limit = -1;
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (torrent)
limit = torrent->uploadLimit();
map[hash] = limit;
@ -892,7 +892,7 @@ void TorrentsController::downloadLimitAction() @@ -892,7 +892,7 @@ void TorrentsController::downloadLimitAction()
for (const QString &hash : hashes)
{
int limit = -1;
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
const BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (torrent)
limit = torrent->downloadLimit();
map[hash] = limit;
@ -910,7 +910,7 @@ void TorrentsController::setUploadLimitAction() @@ -910,7 +910,7 @@ void TorrentsController::setUploadLimitAction()
limit = -1;
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [limit](BitTorrent::TorrentHandle *const torrent) { torrent->setUploadLimit(limit); });
applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setUploadLimit(limit); });
}
void TorrentsController::setDownloadLimitAction()
@ -922,7 +922,7 @@ void TorrentsController::setDownloadLimitAction() @@ -922,7 +922,7 @@ void TorrentsController::setDownloadLimitAction()
limit = -1;
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [limit](BitTorrent::TorrentHandle *const torrent) { torrent->setDownloadLimit(limit); });
applyToTorrents(hashes, [limit](BitTorrent::Torrent *const torrent) { torrent->setDownloadLimit(limit); });
}
void TorrentsController::setShareLimitsAction()
@ -933,7 +933,7 @@ void TorrentsController::setShareLimitsAction() @@ -933,7 +933,7 @@ void TorrentsController::setShareLimitsAction()
const qlonglong seedingTimeLimit = params()["seedingTimeLimit"].toLongLong();
const QStringList hashes = params()["hashes"].split('|');
applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::Torrent *const torrent)
{
torrent->setRatioLimit(ratioLimit);
torrent->setSeedingTimeLimit(seedingTimeLimit);
@ -945,7 +945,7 @@ void TorrentsController::toggleSequentialDownloadAction() @@ -945,7 +945,7 @@ void TorrentsController::toggleSequentialDownloadAction()
requireParams({"hashes"});
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleSequentialDownload(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleSequentialDownload(); });
}
void TorrentsController::toggleFirstLastPiecePrioAction()
@ -953,7 +953,7 @@ void TorrentsController::toggleFirstLastPiecePrioAction() @@ -953,7 +953,7 @@ void TorrentsController::toggleFirstLastPiecePrioAction()
requireParams({"hashes"});
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->toggleFirstLastPiecePriority(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->toggleFirstLastPiecePriority(); });
}
void TorrentsController::setSuperSeedingAction()
@ -962,7 +962,7 @@ void TorrentsController::setSuperSeedingAction() @@ -962,7 +962,7 @@ void TorrentsController::setSuperSeedingAction()
const bool value {parseBool(params()["value"]).value_or(false)};
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [value](BitTorrent::TorrentHandle *const torrent) { torrent->setSuperSeeding(value); });
applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent) { torrent->setSuperSeeding(value); });
}
void TorrentsController::setForceStartAction()
@ -971,7 +971,7 @@ void TorrentsController::setForceStartAction() @@ -971,7 +971,7 @@ void TorrentsController::setForceStartAction()
const bool value {parseBool(params()["value"]).value_or(false)};
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [value](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [value](BitTorrent::Torrent *const torrent)
{
torrent->resume(value ? BitTorrent::TorrentOperatingMode::Forced : BitTorrent::TorrentOperatingMode::AutoManaged);
});
@ -983,8 +983,8 @@ void TorrentsController::deleteAction() @@ -983,8 +983,8 @@ void TorrentsController::deleteAction()
const QStringList hashes {params()["hashes"].split('|')};
const DeleteOption deleteOption = parseBool(params()["deleteFiles"]).value_or(false)
? TorrentAndFiles : Torrent;
applyToTorrents(hashes, [deleteOption](const BitTorrent::TorrentHandle *torrent)
? DeleteTorrentAndFiles : DeleteTorrent;
applyToTorrents(hashes, [deleteOption](const BitTorrent::Torrent *torrent)
{
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteOption);
});
@ -1052,7 +1052,7 @@ void TorrentsController::setLocationAction() @@ -1052,7 +1052,7 @@ void TorrentsController::setLocationAction()
if (!QFileInfo(newLocation).isWritable())
throw APIError(APIErrorType::AccessDenied, tr("Cannot write to directory"));
applyToTorrents(hashes, [newLocation](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [newLocation](BitTorrent::Torrent *const torrent)
{
LogMsg(tr("WebUI Set location: moving \"%1\", from \"%2\" to \"%3\"")
.arg(torrent->name(), Utils::Fs::toNativePath(torrent->savePath()), Utils::Fs::toNativePath(newLocation)));
@ -1070,7 +1070,7 @@ void TorrentsController::renameAction() @@ -1070,7 +1070,7 @@ void TorrentsController::renameAction()
if (name.isEmpty())
throw APIError(APIErrorType::Conflict, tr("Incorrect torrent name"));
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -1085,7 +1085,7 @@ void TorrentsController::setAutoManagementAction() @@ -1085,7 +1085,7 @@ void TorrentsController::setAutoManagementAction()
const QStringList hashes {params()["hashes"].split('|')};
const bool isEnabled {parseBool(params()["enable"]).value_or(false)};
applyToTorrents(hashes, [isEnabled](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [isEnabled](BitTorrent::Torrent *const torrent)
{
torrent->setAutoTMMEnabled(isEnabled);
});
@ -1096,7 +1096,7 @@ void TorrentsController::recheckAction() @@ -1096,7 +1096,7 @@ void TorrentsController::recheckAction()
requireParams({"hashes"});
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceRecheck(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceRecheck(); });
}
void TorrentsController::reannounceAction()
@ -1104,7 +1104,7 @@ void TorrentsController::reannounceAction() @@ -1104,7 +1104,7 @@ void TorrentsController::reannounceAction()
requireParams({"hashes"});
const QStringList hashes {params()["hashes"].split('|')};
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent) { torrent->forceReannounce(); });
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent) { torrent->forceReannounce(); });
}
void TorrentsController::setCategoryAction()
@ -1114,7 +1114,7 @@ void TorrentsController::setCategoryAction() @@ -1114,7 +1114,7 @@ void TorrentsController::setCategoryAction()
const QStringList hashes {params()["hashes"].split('|')};
const QString category {params()["category"]};
applyToTorrents(hashes, [category](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [category](BitTorrent::Torrent *const torrent)
{
if (!torrent->setCategory(category))
throw APIError(APIErrorType::Conflict, tr("Incorrect category name"));
@ -1188,7 +1188,7 @@ void TorrentsController::addTagsAction() @@ -1188,7 +1188,7 @@ void TorrentsController::addTagsAction()
for (const QString &tag : tags)
{
const QString tagTrimmed {tag.trimmed()};
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::Torrent *const torrent)
{
torrent->addTag(tagTrimmed);
});
@ -1205,7 +1205,7 @@ void TorrentsController::removeTagsAction() @@ -1205,7 +1205,7 @@ void TorrentsController::removeTagsAction()
for (const QString &tag : tags)
{
const QString tagTrimmed {tag.trimmed()};
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [&tagTrimmed](BitTorrent::Torrent *const torrent)
{
torrent->removeTag(tagTrimmed);
});
@ -1213,7 +1213,7 @@ void TorrentsController::removeTagsAction() @@ -1213,7 +1213,7 @@ void TorrentsController::removeTagsAction()
if (tags.isEmpty())
{
applyToTorrents(hashes, [](BitTorrent::TorrentHandle *const torrent)
applyToTorrents(hashes, [](BitTorrent::Torrent *const torrent)
{
torrent->removeAllTags();
});
@ -1252,7 +1252,7 @@ void TorrentsController::renameFileAction() @@ -1252,7 +1252,7 @@ void TorrentsController::renameFileAction()
requireParams({"hash", "oldPath", "newPath"});
const QString hash = params()["hash"];
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);
@ -1274,7 +1274,7 @@ void TorrentsController::renameFolderAction() @@ -1274,7 +1274,7 @@ void TorrentsController::renameFolderAction()
requireParams({"hash", "oldPath", "newPath"});
const QString hash = params()["hash"];
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
if (!torrent)
throw APIError(APIErrorType::NotFound);

Loading…
Cancel
Save