mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Make setSequentialDownload/setFirstLastPiecePriority independent.
This commit is contained in:
parent
88abe2baff
commit
67e90d8d2a
@ -189,7 +189,6 @@ TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle
|
||||
if (!data.resumed) {
|
||||
setSequentialDownload(data.sequential);
|
||||
if (hasMetadata()) {
|
||||
setFirstLastPiecePriority(data.sequential);
|
||||
if (m_session->isAppendExtensionEnabled())
|
||||
appendExtensionsToIncompleteFiles();
|
||||
}
|
||||
@ -1088,11 +1087,6 @@ void TorrentHandle::setLabel(const QString &label)
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentHandle::setSequentialDownload(bool b)
|
||||
{
|
||||
SAFE_CALL(set_sequential_download, b);
|
||||
}
|
||||
|
||||
void TorrentHandle::move(QString path)
|
||||
{
|
||||
path = Utils::Fs::toNativePath(path);
|
||||
@ -1130,24 +1124,22 @@ void TorrentHandle::forceRecheck()
|
||||
SAFE_CALL(force_recheck);
|
||||
}
|
||||
|
||||
void TorrentHandle::toggleSequentialDownload()
|
||||
void TorrentHandle::setSequentialDownload(bool b)
|
||||
{
|
||||
if (hasMetadata()) {
|
||||
bool was_sequential = isSequentialDownload();
|
||||
SAFE_CALL(set_sequential_download, !was_sequential);
|
||||
if (!was_sequential)
|
||||
setFirstLastPiecePriority(true);
|
||||
if (b != isSequentialDownload()) {
|
||||
SAFE_CALL(set_sequential_download, b);
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentHandle::toggleFirstLastPiecePriority()
|
||||
void TorrentHandle::toggleSequentialDownload()
|
||||
{
|
||||
if (hasMetadata())
|
||||
setFirstLastPiecePriority(!hasFirstLastPiecePriority());
|
||||
setSequentialDownload(!isSequentialDownload());
|
||||
}
|
||||
|
||||
void TorrentHandle::setFirstLastPiecePriority(bool b)
|
||||
{
|
||||
if (!hasMetadata()) return;
|
||||
|
||||
std::vector<int> fp;
|
||||
SAFE_GET(fp, file_priorities);
|
||||
|
||||
@ -1168,6 +1160,11 @@ void TorrentHandle::setFirstLastPiecePriority(bool b)
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentHandle::toggleFirstLastPiecePriority()
|
||||
{
|
||||
setFirstLastPiecePriority(!hasFirstLastPiecePriority());
|
||||
}
|
||||
|
||||
void TorrentHandle::pause()
|
||||
{
|
||||
if (isPaused()) return;
|
||||
@ -1756,9 +1753,12 @@ QString TorrentHandle::toMagnetUri() const
|
||||
|
||||
void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if (!hasMetadata()) return;
|
||||
if (priorities.size() != filesCount()) return;
|
||||
|
||||
// Save first/last piece first option state
|
||||
bool firstLastPieceFirst = hasFirstLastPiecePriority();
|
||||
|
||||
// Reset 'm_hasSeedStatus' if needed in order to react again to
|
||||
// 'torrent_finished_alert' and eg show tray notifications
|
||||
QVector<qreal> progress = filesProgress();
|
||||
@ -1828,5 +1828,9 @@ void TorrentHandle::prioritizeFiles(const QVector<int> &priorities)
|
||||
}
|
||||
}
|
||||
|
||||
// Restore first/last piece first option if necessary
|
||||
if (firstLastPieceFirst)
|
||||
setFirstLastPiecePriority(true);
|
||||
|
||||
updateStatus();
|
||||
}
|
||||
|
@ -304,8 +304,8 @@ namespace BitTorrent
|
||||
void setLabel(const QString &label);
|
||||
void setSequentialDownload(bool b);
|
||||
void toggleSequentialDownload();
|
||||
void toggleFirstLastPiecePriority();
|
||||
void setFirstLastPiecePriority(bool b);
|
||||
void toggleFirstLastPiecePriority();
|
||||
void pause();
|
||||
void resume(bool forced = false);
|
||||
void move(QString path);
|
||||
|
@ -450,7 +450,7 @@ void PropertiesWidget::loadDynamicData() {
|
||||
downloaded_pieces->setProgress(m_torrent->pieces(), m_torrent->downloadingPieces());
|
||||
}
|
||||
else {
|
||||
showPiecesAvailability(false);
|
||||
showPiecesAvailability(false);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -840,14 +840,9 @@ void PropertiesWidget::editWebSeed() {
|
||||
bool PropertiesWidget::applyPriorities() {
|
||||
qDebug("Saving files priorities");
|
||||
const QVector<int> priorities = PropListModel->model()->getFilePriorities();
|
||||
// Save first/last piece first option state
|
||||
bool first_last_piece_first = m_torrent->hasFirstLastPiecePriority();
|
||||
// Prioritize the files
|
||||
qDebug("prioritize files: %d", priorities[0]);
|
||||
m_torrent->prioritizeFiles(priorities);
|
||||
// Restore first/last piece first option if necessary
|
||||
if (first_last_piece_first)
|
||||
m_torrent->setFirstLastPiecePriority(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ void TransferListWidget::toggleSelectedTorrentsSequentialDownload() const
|
||||
void TransferListWidget::toggleSelectedFirstLastPiecePrio() const
|
||||
{
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents())
|
||||
torrent->setFirstLastPiecePriority(!torrent->hasFirstLastPiecePriority());
|
||||
torrent->toggleFirstLastPiecePriority();
|
||||
}
|
||||
|
||||
void TransferListWidget::askNewLabelForSelection()
|
||||
|
Loading…
Reference in New Issue
Block a user