Browse Source

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

adaptive-webui-19844
ngosang 9 years ago committed by ngosang
parent
commit
6b6411d06b
  1. 14
      src/base/bittorrent/torrenthandle.cpp
  2. 2
      src/gui/transferlistwidget.cpp
  3. 2
      src/webui/www/private/index.html

14
src/base/bittorrent/torrenthandle.cpp

@ -1143,6 +1143,8 @@ void TorrentHandle::setFirstLastPiecePriority(bool b)
std::vector<int> fp; std::vector<int> fp;
SAFE_GET(fp, file_priorities); 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 // Download first and last pieces first for all media files in the torrent
int nbfiles = static_cast<int>(fp.size()); int nbfiles = static_cast<int>(fp.size());
@ -1151,14 +1153,22 @@ void TorrentHandle::setFirstLastPiecePriority(bool b)
const QString ext = Utils::Fs::fileExtension(path); const QString ext = Utils::Fs::fileExtension(path);
if (Utils::Misc::isPreviewable(ext) && (fp[index] > 0)) { if (Utils::Misc::isPreviewable(ext) && (fp[index] > 0)) {
qDebug() << "File" << path << "is previewable, toggle downloading of first/last pieces first"; qDebug() << "File" << path << "is previewable, toggle downloading of first/last pieces first";
// Determine the priority to set // Determine the priority to set
int prio = b ? 7 : fp[index]; int prio = b ? 7 : fp[index];
QPair<int, int> extremities = fileExtremityPieces(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() void TorrentHandle::toggleFirstLastPiecePriority()

2
src/gui/transferlistwidget.cpp

@ -668,7 +668,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
QAction actionSequential_download(tr("Download in sequential order"), 0); QAction actionSequential_download(tr("Download in sequential order"), 0);
actionSequential_download.setCheckable(true); actionSequential_download.setCheckable(true);
connect(&actionSequential_download, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSequentialDownload())); 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); actionFirstLastPiece_prio.setCheckable(true);
connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio())); connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio()));
// End of actions // End of actions

2
src/webui/www/private/index.html

@ -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="#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><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 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> <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> </ul>
<div id="desktopFooterWrapper"> <div id="desktopFooterWrapper">

Loading…
Cancel
Save