|
|
@ -594,19 +594,25 @@ void TransferListWidget::torrentDoubleClicked(QModelIndex index) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::startSelectedTorrents() { |
|
|
|
QStringList TransferListWidget::getSelectedTorrentsHashes() const { |
|
|
|
|
|
|
|
QStringList hashes; |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
// Get the file hash
|
|
|
|
hashes << getHashFromRow(mapToSource(index).row()); |
|
|
|
int row = mapToSource(index).row(); |
|
|
|
} |
|
|
|
QString hash = getHashFromRow(row); |
|
|
|
return hashes; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::startSelectedTorrents() { |
|
|
|
|
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
|
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.is_paused()) { |
|
|
|
if(h.is_valid() && h.is_paused()) { |
|
|
|
h.resume(); |
|
|
|
h.resume(); |
|
|
|
resumeTorrent(row, false); |
|
|
|
resumeTorrent(getRowFromHash(hash), false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!selectedIndexes.empty()) |
|
|
|
if(!hashes.empty()) |
|
|
|
refreshList(); |
|
|
|
refreshList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -622,18 +628,15 @@ void TransferListWidget::startAllTorrents() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::pauseSelectedTorrents() { |
|
|
|
void TransferListWidget::pauseSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
// Get the file hash
|
|
|
|
|
|
|
|
int row = mapToSource(index).row(); |
|
|
|
|
|
|
|
QString hash = getHashFromRow(row); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && !h.is_paused()) { |
|
|
|
if(h.is_valid() && !h.is_paused()) { |
|
|
|
h.pause(); |
|
|
|
h.pause(); |
|
|
|
pauseTorrent(row, false); |
|
|
|
pauseTorrent(getRowFromHash(hash), false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(!selectedIndexes.empty()) |
|
|
|
if(!hashes.empty()) |
|
|
|
refreshList(); |
|
|
|
refreshList(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -650,15 +653,10 @@ void TransferListWidget::pauseAllTorrents() { |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::deleteSelectedTorrents() { |
|
|
|
void TransferListWidget::deleteSelectedTorrents() { |
|
|
|
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return; |
|
|
|
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return; |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
if(!selectedIndexes.empty()) { |
|
|
|
if(!hashes.empty()) { |
|
|
|
bool delete_local_files = false; |
|
|
|
bool delete_local_files = false; |
|
|
|
if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { |
|
|
|
if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { |
|
|
|
QStringList hashes; |
|
|
|
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
|
|
|
|
// Get the file hash
|
|
|
|
|
|
|
|
hashes << getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
int row = getRowFromHash(hash); |
|
|
|
int row = getRowFromHash(hash); |
|
|
|
deleteTorrent(row, false); |
|
|
|
deleteTorrent(row, false); |
|
|
@ -671,9 +669,9 @@ void TransferListWidget::deleteSelectedTorrents() { |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Should work only if the tab is displayed
|
|
|
|
// FIXME: Should work only if the tab is displayed
|
|
|
|
void TransferListWidget::increasePrioSelectedTorrents() { |
|
|
|
void TransferListWidget::increasePrioSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
h.queue_position_up(); |
|
|
|
h.queue_position_up(); |
|
|
|
} |
|
|
|
} |
|
|
@ -683,9 +681,9 @@ void TransferListWidget::increasePrioSelectedTorrents() { |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Should work only if the tab is displayed
|
|
|
|
// FIXME: Should work only if the tab is displayed
|
|
|
|
void TransferListWidget::decreasePrioSelectedTorrents() { |
|
|
|
void TransferListWidget::decreasePrioSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
h.queue_position_down(); |
|
|
|
h.queue_position_down(); |
|
|
|
} |
|
|
|
} |
|
|
@ -694,19 +692,19 @@ void TransferListWidget::decreasePrioSelectedTorrents() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::buySelectedTorrents() const { |
|
|
|
void TransferListWidget::buySelectedTorrents() const { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid()) |
|
|
|
if(h.is_valid()) |
|
|
|
QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33"); |
|
|
|
QDesktopServices::openUrl("http://match.sharemonkey.com/?info_hash="+h.hash()+"&n="+h.name()+"&cid=33"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::copySelectedMagnetURIs() const { |
|
|
|
void TransferListWidget::copySelectedMagnetURIs() const { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
QStringList magnet_uris; |
|
|
|
QStringList magnet_uris; |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.has_metadata()) |
|
|
|
if(h.is_valid() && h.has_metadata()) |
|
|
|
magnet_uris << misc::toQString(make_magnet_uri(h.get_torrent_info())); |
|
|
|
magnet_uris << misc::toQString(make_magnet_uri(h.get_torrent_info())); |
|
|
|
} |
|
|
|
} |
|
|
@ -718,10 +716,10 @@ void TransferListWidget::hidePriorityColumn(bool hide) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::openSelectedTorrentsFolder() const { |
|
|
|
void TransferListWidget::openSelectedTorrentsFolder() const { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
QStringList pathsList; |
|
|
|
QStringList pathsList; |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid()) { |
|
|
|
if(h.is_valid()) { |
|
|
|
QString savePath = h.root_path(); |
|
|
|
QString savePath = h.root_path(); |
|
|
|
if(!pathsList.contains(savePath)) { |
|
|
|
if(!pathsList.contains(savePath)) { |
|
|
@ -733,10 +731,10 @@ void TransferListWidget::openSelectedTorrentsFolder() const { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::previewSelectedTorrents() { |
|
|
|
void TransferListWidget::previewSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
QStringList pathsList; |
|
|
|
QStringList pathsList; |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(mapToSource(index).row())); |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
new previewSelect(this, h); |
|
|
|
new previewSelect(this, h); |
|
|
|
} |
|
|
|
} |
|
|
@ -744,14 +742,11 @@ void TransferListWidget::previewSelectedTorrents() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setDlLimitSelectedTorrents() { |
|
|
|
void TransferListWidget::setDlLimitSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
QStringList hashes; |
|
|
|
|
|
|
|
QList<QTorrentHandle> selected_torrents; |
|
|
|
QList<QTorrentHandle> selected_torrents; |
|
|
|
bool first = true; |
|
|
|
bool first = true; |
|
|
|
bool all_same_limit = true; |
|
|
|
bool all_same_limit = true; |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
// Get the file hash
|
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
if(h.is_valid() && !h.is_seed()) { |
|
|
|
selected_torrents << h; |
|
|
|
selected_torrents << h; |
|
|
@ -780,14 +775,11 @@ void TransferListWidget::setDlLimitSelectedTorrents() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setUpLimitSelectedTorrents() { |
|
|
|
void TransferListWidget::setUpLimitSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
QStringList hashes; |
|
|
|
|
|
|
|
QList<QTorrentHandle> selected_torrents; |
|
|
|
QList<QTorrentHandle> selected_torrents; |
|
|
|
bool first = true; |
|
|
|
bool first = true; |
|
|
|
bool all_same_limit = true; |
|
|
|
bool all_same_limit = true; |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
// Get the file hash
|
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid()) { |
|
|
|
if(h.is_valid()) { |
|
|
|
selected_torrents << h; |
|
|
|
selected_torrents << h; |
|
|
@ -816,13 +808,9 @@ void TransferListWidget::setUpLimitSelectedTorrents() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::recheckSelectedTorrents() { |
|
|
|
void TransferListWidget::recheckSelectedTorrents() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes){ |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
BTSession->recheckTorrent(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
|
|
|
|
if(h.is_valid()) { |
|
|
|
|
|
|
|
BTSession->recheckTorrent(h.hash()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -897,10 +885,8 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&){ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef LIBTORRENT_0_15 |
|
|
|
#ifdef LIBTORRENT_0_15 |
|
|
|
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() { |
|
|
|
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
// Get the file hash
|
|
|
|
|
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
h.super_seeding(!h.super_seeding()); |
|
|
|
h.super_seeding(!h.super_seeding()); |
|
|
@ -910,10 +896,8 @@ void TransferListWidget::toggleSelectedTorrentsSuperSeeding() { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() { |
|
|
|
void TransferListWidget::toggleSelectedTorrentsSequentialDownload() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
// Get the file hash
|
|
|
|
|
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
h.set_sequential_download(!h.is_sequential_download()); |
|
|
|
h.set_sequential_download(!h.is_sequential_download()); |
|
|
@ -922,10 +906,8 @@ void TransferListWidget::toggleSelectedTorrentsSequentialDownload() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::toggleSelectedFirstLastPiecePrio() { |
|
|
|
void TransferListWidget::toggleSelectedFirstLastPiecePrio() { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
// Get the file hash
|
|
|
|
|
|
|
|
QString hash = getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
if(h.is_valid() && h.has_metadata()) { |
|
|
|
h.prioritize_first_last_piece(!h.first_last_piece_first()); |
|
|
|
h.prioritize_first_last_piece(!h.first_last_piece_first()); |
|
|
@ -971,11 +953,7 @@ void TransferListWidget::renameSelectedTorrent() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::setSelectionLabel(QString label) { |
|
|
|
void TransferListWidget::setSelectionLabel(QString label) { |
|
|
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
QStringList hashes = getSelectedTorrentsHashes(); |
|
|
|
QStringList hashes; |
|
|
|
|
|
|
|
foreach(const QModelIndex &index, selectedIndexes) { |
|
|
|
|
|
|
|
hashes << getHashFromRow(mapToSource(index).row()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
foreach(const QString &hash, hashes) { |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
int row = getRowFromHash(hash); |
|
|
|
int row = getRowFromHash(hash); |
|
|
|