mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Remove redundant suffix from TorrentHandle class
Originally, it was just a wrapper for libtorrent::torrent_handle class, so it mimicked its name. It was then transformed into a more complex aggregate, but the name was retained (just by inertia). Unlike libtorrent::torrent_handle class in whose name "handle" means the pattern used, it does not matter for qBittorrent classes and just eats up space in the source code.
This commit is contained in:
parent
0cbd15890a
commit
1880082017
52 changed files with 647 additions and 647 deletions
|
@ -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)
|
|||
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)
|
|||
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)
|
|||
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)
|
|||
|
||||
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)
|
|||
{
|
||||
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()
|
|||
|
||||
// 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()
|
|||
{
|
||||
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()
|
|||
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()
|
|||
}
|
||||
}
|
||||
|
||||
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()
|
|||
|
||||
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()
|
|||
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)
|
|||
|
||||
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
|
|||
}
|
||||
|
||||
// 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
|
|||
|
||||
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
|
|||
|
||||
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)
|
|||
// 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)
|
|||
|
||||
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)
|
|||
// 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)
|
|||
// 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)
|
|||
|
||||
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)
|
|||
// 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)
|
|||
|
||||
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)
|
|||
// 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)
|
|||
|
||||
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)
|
|||
// 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)
|
|||
// 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)
|
|||
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
|
|||
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)
|
|||
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
|
|||
|
||||
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()
|
|||
{
|
||||
// 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)
|
|||
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)
|
|||
|
||||
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
|
|||
|
||||
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()
|
|||
}
|
||||
}
|
||||
|
||||
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
|
|||
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
|
|||
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)
|
|||
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)
|
|||
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
|
|||
#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
|
|||
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()
|
|||
|
||||
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()
|
|||
// 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
|
|||
|
||||
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()
|
|||
|
||||
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
|
|||
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
|
|||
|
||||
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)
|
|||
|
||||
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)
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
|||
}
|
||||
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)
|
|||
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)
|
|||
|
||||
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)
|
|||
|
||||
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)
|
|||
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
|
|||
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
|
|||
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue