1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Download more pieces in "Download first and last pieces first" feature

This commit is contained in:
ngosang 2015-09-18 04:58:16 +02:00 committed by ngosang
parent 193913129f
commit 6b6411d06b
3 changed files with 14 additions and 4 deletions

View File

@ -1143,6 +1143,8 @@ void TorrentHandle::setFirstLastPiecePriority(bool b)
std::vector<int> fp;
SAFE_GET(fp, file_priorities);
std::vector<int> pp;
SAFE_GET(pp, piece_priorities);
// Download first and last pieces first for all media files in the torrent
int nbfiles = static_cast<int>(fp.size());
@ -1151,16 +1153,24 @@ void TorrentHandle::setFirstLastPiecePriority(bool b)
const QString ext = Utils::Fs::fileExtension(path);
if (Utils::Misc::isPreviewable(ext) && (fp[index] > 0)) {
qDebug() << "File" << path << "is previewable, toggle downloading of first/last pieces first";
// Determine the priority to set
int prio = b ? 7 : fp[index];
QPair<int, int> extremities = fileExtremityPieces(index);
SAFE_CALL(piece_priority, extremities.first, prio);
SAFE_CALL(piece_priority, extremities.second, prio);
// worst case: AVI index = 1% of total file size (at the end of the file)
int nNumPieces = ceil(fileSize(index) * 0.01 / pieceLength());
for (int i = 0; i < nNumPieces; ++i) {
pp[extremities.first + i] = prio;
pp[extremities.second - i] = prio;
}
}
}
SAFE_CALL(prioritize_pieces, pp);
}
void TorrentHandle::toggleFirstLastPiecePriority()
{
setFirstLastPiecePriority(!hasFirstLastPiecePriority());

View File

@ -668,7 +668,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
QAction actionSequential_download(tr("Download in sequential order"), 0);
actionSequential_download.setCheckable(true);
connect(&actionSequential_download, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSequentialDownload()));
QAction actionFirstLastPiece_prio(tr("Download first and last piece first"), 0);
QAction actionFirstLastPiece_prio(tr("Download first and last pieces first"), 0);
actionFirstLastPiece_prio.setCheckable(true);
connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio()));
// End of actions

View File

@ -122,7 +122,7 @@
<li><a href="#UploadLimit"><img src="images/skin/uploadLimit.png" alt="QBT_TR(Limit upload rate...)QBT_TR"/> QBT_TR(Limit upload rate...)QBT_TR</a></li>
<li><a href="#SuperSeeding"><img src="theme/checked" alt="QBT_TR(Super seeding mode)QBT_TR"/> QBT_TR(Super seeding mode)QBT_TR</a></li>
<li class="separator"><a href="#SequentialDownload"><img src="theme/checked" alt="QBT_TR(Download in sequential order)QBT_TR"/> QBT_TR(Download in sequential order)QBT_TR</a></li>
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last piece first)QBT_TR"/> QBT_TR(Download first and last piece first)QBT_TR</a></li>
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last pieces first)QBT_TR"/> QBT_TR(Download first and last pieces first)QBT_TR</a></li>
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
</ul>
<div id="desktopFooterWrapper">