Improve "info hash" handling

Define "torrent ID" concept, which is either a SHA1 hash for torrents of version 1,
or a SHA256 hash (truncated to SHA1 hash length) for torrents of version 2.
Add support for native libtorrent2 info hashes.
This commit is contained in:
Vladimir Golovnev (Glassez)
2021-03-05 12:43:58 +03:00
parent 4da4fb0676
commit 561b597031
34 changed files with 463 additions and 320 deletions

View File

@@ -270,12 +270,12 @@ bool AddNewTorrentDialog::loadTorrentFile(const QString &torrentPath)
bool AddNewTorrentDialog::loadTorrentImpl()
{
m_hasMetadata = true;
const BitTorrent::InfoHash infoHash = m_torrentInfo.hash();
const auto torrentID = BitTorrent::TorrentID::fromInfoHash(m_torrentInfo.infoHash());
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
if (BitTorrent::Session::instance()->isKnownTorrent(torrentID))
{
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
if (torrent)
{
if (torrent->isPrivate() || m_torrentInfo.isPrivate())
@@ -296,7 +296,7 @@ bool AddNewTorrentDialog::loadTorrentImpl()
return false;
}
m_ui->labelHashData->setText(infoHash.toString());
m_ui->labelHashData->setText(torrentID.toString());
setupTreeview();
TMMChanged(m_ui->comboTTM->currentIndex());
return true;
@@ -312,11 +312,11 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
m_torrentGuard = std::make_unique<TorrentFileGuard>();
const BitTorrent::InfoHash infoHash = magnetUri.hash();
const auto torrentID = BitTorrent::TorrentID::fromInfoHash(magnetUri.infoHash());
// Prevent showing the dialog if download is already present
if (BitTorrent::Session::instance()->isKnownTorrent(infoHash))
if (BitTorrent::Session::instance()->isKnownTorrent(torrentID))
{
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(infoHash);
BitTorrent::Torrent *const torrent = BitTorrent::Session::instance()->findTorrent(torrentID);
if (torrent)
{
if (torrent->isPrivate())
@@ -348,7 +348,7 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
BitTorrent::Session::instance()->downloadMetadata(magnetUri);
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
m_ui->labelHashData->setText(infoHash.toString());
m_ui->labelHashData->setText(torrentID.toString());
m_magnetURI = magnetUri;
return true;
@@ -629,7 +629,7 @@ void AddNewTorrentDialog::reject()
if (!m_hasMetadata)
{
setMetadataProgressIndicator(false);
BitTorrent::Session::instance()->cancelDownloadMetadata(m_magnetURI.hash());
BitTorrent::Session::instance()->cancelDownloadMetadata(m_magnetURI.infoHash().toTorrentID());
}
QDialog::reject();
@@ -637,7 +637,7 @@ void AddNewTorrentDialog::reject()
void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &metadata)
{
if (metadata.hash() != m_magnetURI.hash()) return;
if (metadata.infoHash() != m_magnetURI.infoHash()) return;
disconnect(BitTorrent::Session::instance(), &BitTorrent::Session::metadataDownloaded, this, &AddNewTorrentDialog::updateMetadata);

View File

@@ -958,7 +958,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *co
Preferences *const pref = Preferences::instance();
if (pref->recursiveDownloadDisabled()) return;
const auto torrentHash = torrent->hash();
const auto torrentID = torrent->id();
QMessageBox *confirmBox = new QMessageBox(QMessageBox::Question, tr("Recursive download confirmation")
, tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrent->name())
@@ -969,10 +969,10 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *co
const QPushButton *yes = confirmBox->addButton(tr("Yes"), QMessageBox::YesRole);
/*QPushButton *no = */ confirmBox->addButton(tr("No"), QMessageBox::NoRole);
const QPushButton *never = confirmBox->addButton(tr("Never"), QMessageBox::NoRole);
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentHash, yes, never](const QAbstractButton *button)
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentID, yes, never](const QAbstractButton *button)
{
if (button == yes)
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentHash);
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentID);
if (button == never)
Preferences::instance()->disableRecursiveDownload();
});

View File

@@ -312,8 +312,9 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *const torrent)
// Save path
updateSavePath(m_torrent);
// Hash
m_ui->labelHashVal->setText(m_torrent->hash().toString());
// Info hash (Truncated info hash (torrent ID) with libtorrent2)
// TODO: Update label for this property to express its meaning more clearly (or change it to display real info hash(es))
m_ui->labelHashVal->setText(m_torrent->id().toString());
m_propListModel->model()->clear();
if (m_torrent->hasMetadata())
{

View File

@@ -77,10 +77,10 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
const bool isFirstTorrentPEXDisabled = torrents[0]->isPEXDisabled();
const bool isFirstTorrentLSDDisabled = torrents[0]->isLSDDisabled();
m_torrentHashes.reserve(torrents.size());
m_torrentIDs.reserve(torrents.size());
for (const BitTorrent::Torrent *torrent : torrents)
{
m_torrentHashes << torrent->hash();
m_torrentIDs << torrent->id();
if (allSameUpLimit)
{
if (qMax(0, torrent->uploadLimit()) != firstTorrentUpLimit)
@@ -288,9 +288,9 @@ void TorrentOptionsDialog::accept()
}
const auto *session = BitTorrent::Session::instance();
for (const BitTorrent::InfoHash &hash : asConst(m_torrentHashes))
for (const BitTorrent::TorrentID &id : asConst(m_torrentIDs))
{
BitTorrent::Torrent *torrent = session->findTorrent(hash);
BitTorrent::Torrent *torrent = session->findTorrent(id);
if (!torrent) continue;
if (m_initialValues.upSpeedLimit != m_ui->spinUploadLimit->value())

View File

@@ -36,8 +36,8 @@
namespace BitTorrent
{
class InfoHash;
class Torrent;
class TorrentID;
}
namespace Ui
@@ -67,7 +67,7 @@ private:
qreal getRatio() const;
int getSeedingTime() const;
QVector<BitTorrent::InfoHash> m_torrentHashes;
QVector<BitTorrent::TorrentID> m_torrentIDs;
Ui::TorrentOptionsDialog *m_ui;
SettingValue<QSize> m_storeDialogSize;
struct

View File

@@ -321,7 +321,7 @@ TrackerFiltersList::~TrackerFiltersList()
Utils::Fs::forceRemove(iconPath);
}
void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::InfoHash &hash)
void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::TorrentID &id)
{
const QString host {getHost(tracker)};
const bool exists {m_trackers.contains(host)};
@@ -329,7 +329,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::InfoH
if (exists)
{
if (m_trackers.value(host).contains(hash))
if (m_trackers.value(host).contains(id))
return;
trackerItem = item((host == NULL_HOST)
@@ -346,18 +346,18 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::InfoH
}
if (!trackerItem) return;
QSet<BitTorrent::InfoHash> &hashes {m_trackers[host]};
hashes.insert(hash);
QSet<BitTorrent::TorrentID> &torrentIDs {m_trackers[host]};
torrentIDs.insert(id);
if (host == NULL_HOST)
{
trackerItem->setText(tr("Trackerless (%1)").arg(hashes.size()));
trackerItem->setText(tr("Trackerless (%1)").arg(torrentIDs.size()));
if (currentRow() == TRACKERLESS_ROW)
applyFilter(TRACKERLESS_ROW);
return;
}
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(hashes.size())));
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(torrentIDs.size())));
if (exists)
{
if (currentRow() == rowFromTracker(host))
@@ -379,14 +379,14 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::InfoH
updateGeometry();
}
void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::InfoHash &hash)
void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::TorrentID &id)
{
const QString host = getHost(tracker);
QSet<BitTorrent::InfoHash> hashes = m_trackers.value(host);
QSet<BitTorrent::TorrentID> torrentIDs = m_trackers.value(host);
if (hashes.empty())
if (torrentIDs.empty())
return;
hashes.remove(hash);
torrentIDs.remove(id);
int row = 0;
QListWidgetItem *trackerItem = nullptr;
@@ -394,11 +394,11 @@ void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::In
if (!host.isEmpty())
{
// Remove from 'Error' and 'Warning' view
trackerSuccess(hash, tracker);
trackerSuccess(id, tracker);
row = rowFromTracker(host);
trackerItem = item(row);
if (hashes.empty())
if (torrentIDs.empty())
{
if (currentRow() == row)
setCurrentRow(0, QItemSelectionModel::SelectCurrent);
@@ -409,27 +409,27 @@ void TrackerFiltersList::removeItem(const QString &tracker, const BitTorrent::In
}
if (trackerItem)
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(hashes.size())));
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(torrentIDs.size())));
}
else
{
row = 1;
trackerItem = item(TRACKERLESS_ROW);
trackerItem->setText(tr("Trackerless (%1)").arg(hashes.size()));
trackerItem->setText(tr("Trackerless (%1)").arg(torrentIDs.size()));
}
m_trackers.insert(host, hashes);
m_trackers.insert(host, torrentIDs);
if (currentRow() == row)
applyFilter(row);
}
void TrackerFiltersList::changeTrackerless(const bool trackerless, const BitTorrent::InfoHash &hash)
void TrackerFiltersList::changeTrackerless(const bool trackerless, const BitTorrent::TorrentID &id)
{
if (trackerless)
addItem(NULL_HOST, hash);
addItem(NULL_HOST, id);
else
removeItem(NULL_HOST, hash);
removeItem(NULL_HOST, id);
}
void TrackerFiltersList::setDownloadTrackerFavicon(bool value)
@@ -452,9 +452,9 @@ void TrackerFiltersList::setDownloadTrackerFavicon(bool value)
}
}
void TrackerFiltersList::trackerSuccess(const BitTorrent::InfoHash &hash, const QString &tracker)
void TrackerFiltersList::trackerSuccess(const BitTorrent::TorrentID &id, const QString &tracker)
{
const auto errorHashesIter = m_errors.find(hash);
const auto errorHashesIter = m_errors.find(id);
if (errorHashesIter != m_errors.end())
{
QSet<QString> &errored = *errorHashesIter;
@@ -468,7 +468,7 @@ void TrackerFiltersList::trackerSuccess(const BitTorrent::InfoHash &hash, const
}
}
const auto warningHashesIter = m_warnings.find(hash);
const auto warningHashesIter = m_warnings.find(id);
if (warningHashesIter != m_warnings.end())
{
QSet<QString> &warned = *warningHashesIter;
@@ -483,9 +483,9 @@ void TrackerFiltersList::trackerSuccess(const BitTorrent::InfoHash &hash, const
}
}
void TrackerFiltersList::trackerError(const BitTorrent::InfoHash &hash, const QString &tracker)
void TrackerFiltersList::trackerError(const BitTorrent::TorrentID &id, const QString &tracker)
{
QSet<QString> &trackers {m_errors[hash]};
QSet<QString> &trackers {m_errors[id]};
if (trackers.contains(tracker))
return;
@@ -495,9 +495,9 @@ void TrackerFiltersList::trackerError(const BitTorrent::InfoHash &hash, const QS
applyFilter(ERROR_ROW);
}
void TrackerFiltersList::trackerWarning(const BitTorrent::InfoHash &hash, const QString &tracker)
void TrackerFiltersList::trackerWarning(const BitTorrent::TorrentID &id, const QString &tracker)
{
QSet<QString> &trackers {m_warnings[hash]};
QSet<QString> &trackers {m_warnings[id]};
if (trackers.contains(tracker))
return;
@@ -572,33 +572,33 @@ void TrackerFiltersList::applyFilter(const int row)
if (row == ALL_ROW)
transferList->applyTrackerFilterAll();
else if (isVisible())
transferList->applyTrackerFilter(getInfoHashes(row));
transferList->applyTrackerFilter(getTorrentIDs(row));
}
void TrackerFiltersList::handleNewTorrent(BitTorrent::Torrent *const torrent)
{
const BitTorrent::InfoHash hash {torrent->hash()};
const BitTorrent::TorrentID torrentID {torrent->id()};
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
for (const BitTorrent::TrackerEntry &tracker : trackers)
addItem(tracker.url, hash);
addItem(tracker.url, torrentID);
// Check for trackerless torrent
if (trackers.isEmpty())
addItem(NULL_HOST, hash);
addItem(NULL_HOST, torrentID);
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(++m_totalTorrents));
}
void TrackerFiltersList::torrentAboutToBeDeleted(BitTorrent::Torrent *const torrent)
{
const BitTorrent::InfoHash hash {torrent->hash()};
const BitTorrent::TorrentID torrentID {torrent->id()};
const QVector<BitTorrent::TrackerEntry> trackers {torrent->trackers()};
for (const BitTorrent::TrackerEntry &tracker : trackers)
removeItem(tracker.url, hash);
removeItem(tracker.url, torrentID);
// Check for trackerless torrent
if (trackers.isEmpty())
removeItem(NULL_HOST, hash);
removeItem(NULL_HOST, torrentID);
item(ALL_ROW)->setText(tr("All (%1)", "this is for the tracker filter").arg(--m_totalTorrents));
}
@@ -624,7 +624,7 @@ int TrackerFiltersList::rowFromTracker(const QString &tracker) const
return -1;
}
QSet<BitTorrent::InfoHash> TrackerFiltersList::getInfoHashes(const int row) const
QSet<BitTorrent::TorrentID> TrackerFiltersList::getTorrentIDs(const int row) const
{
switch (row)
{
@@ -727,11 +727,11 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
connect(trackerLabel, &QCheckBox::toggled, m_trackerFilters, &TrackerFiltersList::toggleFilter);
connect(trackerLabel, &QCheckBox::toggled, pref, &Preferences::setTrackerFilterState);
connect(this, qOverload<const BitTorrent::InfoHash &, const QString &>(&TransferListFiltersWidget::trackerSuccess)
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerSuccess)
, m_trackerFilters, &TrackerFiltersList::trackerSuccess);
connect(this, qOverload<const BitTorrent::InfoHash &, const QString &>(&TransferListFiltersWidget::trackerError)
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerError)
, m_trackerFilters, &TrackerFiltersList::trackerError);
connect(this, qOverload<const BitTorrent::InfoHash &, const QString &>(&TransferListFiltersWidget::trackerWarning)
connect(this, qOverload<const BitTorrent::TorrentID &, const QString &>(&TransferListFiltersWidget::trackerWarning)
, m_trackerFilters, &TrackerFiltersList::trackerWarning);
}
@@ -743,33 +743,33 @@ void TransferListFiltersWidget::setDownloadTrackerFavicon(bool value)
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());
m_trackerFilters->addItem(tracker.url, torrent->id());
}
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());
m_trackerFilters->removeItem(tracker.url, torrent->id());
}
void TransferListFiltersWidget::changeTrackerless(const BitTorrent::Torrent *torrent, const bool trackerless)
{
m_trackerFilters->changeTrackerless(trackerless, torrent->hash());
m_trackerFilters->changeTrackerless(trackerless, torrent->id());
}
void TransferListFiltersWidget::trackerSuccess(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerSuccess(torrent->hash(), tracker);
emit trackerSuccess(torrent->id(), tracker);
}
void TransferListFiltersWidget::trackerWarning(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerWarning(torrent->hash(), tracker);
emit trackerWarning(torrent->id(), tracker);
}
void TransferListFiltersWidget::trackerError(const BitTorrent::Torrent *torrent, const QString &tracker)
{
emit trackerError(torrent->hash(), tracker);
emit trackerError(torrent->id(), tracker);
}
void TransferListFiltersWidget::onCategoryFilterStateChanged(bool enabled)

View File

@@ -39,8 +39,8 @@ class TransferListWidget;
namespace BitTorrent
{
class InfoHash;
class Torrent;
class TorrentID;
struct TrackerEntry;
}
@@ -104,15 +104,15 @@ public:
~TrackerFiltersList() override;
// Redefine addItem() to make sure the list stays sorted
void addItem(const QString &tracker, const BitTorrent::InfoHash &hash);
void removeItem(const QString &tracker, const BitTorrent::InfoHash &hash);
void changeTrackerless(bool trackerless, const BitTorrent::InfoHash &hash);
void addItem(const QString &tracker, const BitTorrent::TorrentID &id);
void removeItem(const QString &tracker, const BitTorrent::TorrentID &id);
void changeTrackerless(bool trackerless, const BitTorrent::TorrentID &id);
void setDownloadTrackerFavicon(bool value);
public slots:
void trackerSuccess(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerError(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerWarning(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerSuccess(const BitTorrent::TorrentID &id, const QString &tracker);
void trackerError(const BitTorrent::TorrentID &id, const QString &tracker);
void trackerWarning(const BitTorrent::TorrentID &id, const QString &tracker);
private slots:
void handleFavicoDownloadFinished(const Net::DownloadResult &result);
@@ -126,12 +126,12 @@ private:
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;
QSet<BitTorrent::TorrentID> getTorrentIDs(int row) const;
void downloadFavicon(const QString &url);
QHash<QString, QSet<BitTorrent::InfoHash>> m_trackers; // <tracker host, torrent hashes>
QHash<BitTorrent::InfoHash, QSet<QString>> m_errors; // <torrent hash, tracker hosts>
QHash<BitTorrent::InfoHash, QSet<QString>> m_warnings; // <torrent hash, tracker hosts>
QHash<QString, QSet<BitTorrent::TorrentID>> m_trackers; // <tracker host, torrent IDs>
QHash<BitTorrent::TorrentID, QSet<QString>> m_errors; // <torrent ID, tracker hosts>
QHash<BitTorrent::TorrentID, QSet<QString>> m_warnings; // <torrent ID, tracker hosts>
QStringList m_iconPaths;
int m_totalTorrents;
bool m_downloadTrackerFavicon;
@@ -158,9 +158,9 @@ public slots:
void trackerError(const BitTorrent::Torrent *torrent, const QString &tracker);
signals:
void trackerSuccess(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerError(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerWarning(const BitTorrent::InfoHash &hash, const QString &tracker);
void trackerSuccess(const BitTorrent::TorrentID &id, const QString &tracker);
void trackerError(const BitTorrent::TorrentID &id, const QString &tracker);
void trackerWarning(const BitTorrent::TorrentID &id, const QString &tracker);
private slots:
void onCategoryFilterStateChanged(bool enabled);

View File

@@ -99,15 +99,15 @@ void TransferListSortModel::disableTagFilter()
invalidateFilter();
}
void TransferListSortModel::setTrackerFilter(const QSet<BitTorrent::InfoHash> &hashes)
void TransferListSortModel::setTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs)
{
if (m_filter.setHashSet(hashes))
if (m_filter.setTorrentIDSet(torrentIDs))
invalidateFilter();
}
void TransferListSortModel::disableTrackerFilter()
{
if (m_filter.setHashSet(TorrentFilter::AnyHash))
if (m_filter.setTorrentIDSet(TorrentFilter::AnyID))
invalidateFilter();
}

View File

@@ -50,7 +50,7 @@ public:
void disableCategoryFilter();
void setTagFilter(const QString &tag);
void disableTagFilter();
void setTrackerFilter(const QSet<BitTorrent::InfoHash> &hashes);
void setTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs);
void disableTrackerFilter();
private:

View File

@@ -78,13 +78,13 @@
namespace
{
QVector<BitTorrent::InfoHash> extractHashes(const QVector<BitTorrent::Torrent *> &torrents)
QVector<BitTorrent::TorrentID> extractIDs(const QVector<BitTorrent::Torrent *> &torrents)
{
QVector<BitTorrent::InfoHash> hashes;
hashes.reserve(torrents.size());
QVector<BitTorrent::TorrentID> torrentIDs;
torrentIDs.reserve(torrents.size());
for (const BitTorrent::Torrent *torrent : torrents)
hashes << torrent->hash();
return hashes;
torrentIDs << torrent->id();
return torrentIDs;
}
bool torrentContainsPreviewableFiles(const BitTorrent::Torrent *const torrent)
@@ -121,7 +121,7 @@ namespace
auto *session = BitTorrent::Session::instance();
const DeleteOption deleteOption = isDeleteFileSelected ? DeleteTorrentAndFiles : DeleteTorrent;
for (const BitTorrent::Torrent *torrent : torrents)
session->deleteTorrent(torrent->hash(), deleteOption);
session->deleteTorrent(torrent->id(), deleteOption);
}
}
@@ -452,26 +452,26 @@ void TransferListWidget::increaseQueuePosSelectedTorrents()
{
qDebug() << Q_FUNC_INFO;
if (m_mainWindow->currentTabWidget() == this)
BitTorrent::Session::instance()->increaseTorrentsQueuePos(extractHashes(getSelectedTorrents()));
BitTorrent::Session::instance()->increaseTorrentsQueuePos(extractIDs(getSelectedTorrents()));
}
void TransferListWidget::decreaseQueuePosSelectedTorrents()
{
qDebug() << Q_FUNC_INFO;
if (m_mainWindow->currentTabWidget() == this)
BitTorrent::Session::instance()->decreaseTorrentsQueuePos(extractHashes(getSelectedTorrents()));
BitTorrent::Session::instance()->decreaseTorrentsQueuePos(extractIDs(getSelectedTorrents()));
}
void TransferListWidget::topQueuePosSelectedTorrents()
{
if (m_mainWindow->currentTabWidget() == this)
BitTorrent::Session::instance()->topTorrentsQueuePos(extractHashes(getSelectedTorrents()));
BitTorrent::Session::instance()->topTorrentsQueuePos(extractIDs(getSelectedTorrents()));
}
void TransferListWidget::bottomQueuePosSelectedTorrents()
{
if (m_mainWindow->currentTabWidget() == this)
BitTorrent::Session::instance()->bottomTorrentsQueuePos(extractHashes(getSelectedTorrents()));
BitTorrent::Session::instance()->bottomTorrentsQueuePos(extractIDs(getSelectedTorrents()));
}
void TransferListWidget::copySelectedMagnetURIs() const
@@ -494,11 +494,11 @@ void TransferListWidget::copySelectedNames() const
void TransferListWidget::copySelectedHashes() const
{
QStringList torrentHashes;
QStringList torrentIDs;
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
torrentHashes << torrent->hash().toString();
torrentIDs << torrent->id().toString();
qApp->clipboard()->setText(torrentHashes.join('\n'));
qApp->clipboard()->setText(torrentIDs.join('\n'));
}
void TransferListWidget::hideQueuePosColumn(bool hide)
@@ -1129,9 +1129,9 @@ void TransferListWidget::applyTrackerFilterAll()
m_sortFilterModel->disableTrackerFilter();
}
void TransferListWidget::applyTrackerFilter(const QSet<BitTorrent::InfoHash> &hashes)
void TransferListWidget::applyTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs)
{
m_sortFilterModel->setTrackerFilter(hashes);
m_sortFilterModel->setTrackerFilter(torrentIDs);
}
void TransferListWidget::applyNameFilter(const QString &name)

View File

@@ -39,8 +39,8 @@ class TransferListSortModel;
namespace BitTorrent
{
class InfoHash;
class Torrent;
class TorrentID;
}
class TransferListWidget final : public QTreeView
@@ -88,7 +88,7 @@ public slots:
void applyCategoryFilter(const QString &category);
void applyTagFilter(const QString &tag);
void applyTrackerFilterAll();
void applyTrackerFilter(const QSet<BitTorrent::InfoHash> &hashes);
void applyTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs);
void previewFile(const QString &filePath);
void renameSelectedTorrent();