|
|
@ -501,6 +501,17 @@ QVector<BitTorrent::TorrentHandle *> TransferListWidget::getSelectedTorrents() c |
|
|
|
return torrents; |
|
|
|
return torrents; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<BitTorrent::TorrentHandle *> TransferListWidget::getVisibleTorrents() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const int visibleTorrentsCount = m_sortFilterModel->rowCount(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QVector<BitTorrent::TorrentHandle *> torrents; |
|
|
|
|
|
|
|
torrents.reserve(visibleTorrentsCount); |
|
|
|
|
|
|
|
for (int i = 0; i < visibleTorrentsCount; ++i) |
|
|
|
|
|
|
|
torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
|
|
|
|
return torrents; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setSelectedTorrentsLocation() |
|
|
|
void TransferListWidget::setSelectedTorrentsLocation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QVector<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents(); |
|
|
|
const QVector<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents(); |
|
|
@ -547,12 +558,9 @@ void TransferListWidget::forceStartSelectedTorrents() |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::startVisibleTorrents() |
|
|
|
void TransferListWidget::startVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) { |
|
|
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents())) |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
|
|
|
|
if (torrent) |
|
|
|
|
|
|
|
torrent->resume(); |
|
|
|
torrent->resume(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::pauseSelectedTorrents() |
|
|
|
void TransferListWidget::pauseSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -562,12 +570,9 @@ void TransferListWidget::pauseSelectedTorrents() |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::pauseVisibleTorrents() |
|
|
|
void TransferListWidget::pauseVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) { |
|
|
|
for (BitTorrent::TorrentHandle *const torrent : asConst(getVisibleTorrents())) |
|
|
|
BitTorrent::TorrentHandle *const torrent = m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
|
|
|
|
if (torrent) |
|
|
|
|
|
|
|
torrent->pause(); |
|
|
|
torrent->pause(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::softDeleteSelectedTorrents() |
|
|
|
void TransferListWidget::softDeleteSelectedTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -589,9 +594,11 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) |
|
|
|
if (Preferences::instance()->confirmTorrentDeletion()) { |
|
|
|
if (Preferences::instance()->confirmTorrentDeletion()) { |
|
|
|
auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), deleteLocalFiles); |
|
|
|
auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), deleteLocalFiles); |
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
connect(dialog, &DeletionConfirmationDialog::accepted, this, [dialog, torrents]() |
|
|
|
connect(dialog, &DeletionConfirmationDialog::accepted, this, [this, dialog]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
removeTorrents(torrents, dialog->isDeleteFileSelected()); |
|
|
|
// Some torrents might be removed when waiting for user input, so refetch the torrent list
|
|
|
|
|
|
|
|
// NOTE: this will only work when dialog is modal
|
|
|
|
|
|
|
|
removeTorrents(getSelectedTorrents(), dialog->isDeleteFileSelected()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
dialog->open(); |
|
|
|
dialog->open(); |
|
|
|
} |
|
|
|
} |
|
|
@ -602,18 +609,17 @@ void TransferListWidget::deleteSelectedTorrents(const bool deleteLocalFiles) |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::deleteVisibleTorrents() |
|
|
|
void TransferListWidget::deleteVisibleTorrents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_sortFilterModel->rowCount() <= 0) return; |
|
|
|
const QVector<BitTorrent::TorrentHandle *> torrents = getVisibleTorrents(); |
|
|
|
|
|
|
|
if (torrents.empty()) return; |
|
|
|
QVector<BitTorrent::TorrentHandle *> torrents; |
|
|
|
|
|
|
|
for (int i = 0; i < m_sortFilterModel->rowCount(); ++i) |
|
|
|
|
|
|
|
torrents << m_listModel->torrentHandle(mapToSource(m_sortFilterModel->index(i, 0))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Preferences::instance()->confirmTorrentDeletion()) { |
|
|
|
if (Preferences::instance()->confirmTorrentDeletion()) { |
|
|
|
auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), false); |
|
|
|
auto *dialog = new DeletionConfirmationDialog(this, torrents.size(), torrents[0]->name(), false); |
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
connect(dialog, &DeletionConfirmationDialog::accepted, this, [dialog, torrents]() |
|
|
|
connect(dialog, &DeletionConfirmationDialog::accepted, this, [this, dialog]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
removeTorrents(torrents, dialog->isDeleteFileSelected()); |
|
|
|
// Some torrents might be removed when waiting for user input, so refetch the torrent list
|
|
|
|
|
|
|
|
// NOTE: this will only work when dialog is modal
|
|
|
|
|
|
|
|
removeTorrents(getVisibleTorrents(), dialog->isDeleteFileSelected()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
dialog->open(); |
|
|
|
dialog->open(); |
|
|
|
} |
|
|
|
} |
|
|
|