mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 06:17:58 +00:00
FEATURE: Added option to download first and last piece of a torrent first (for preview)
This commit is contained in:
parent
873221ec14
commit
62604e32c0
@ -17,6 +17,7 @@
|
|||||||
- FEATURE: Display trackers status as well as error/warning messages
|
- FEATURE: Display trackers status as well as error/warning messages
|
||||||
- FEATURE: Display the number of peers returned by each tracker & DHT
|
- FEATURE: Display the number of peers returned by each tracker & DHT
|
||||||
- FEATURE: Global upload/download speeds can be capped from status bar (µTorrent behavior)
|
- FEATURE: Global upload/download speeds can be capped from status bar (µTorrent behavior)
|
||||||
|
- FEATURE: Added option to download first and last piece of a torrent first (for preview)
|
||||||
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required)
|
- FEATURE: Dropped Qt 4.3 support (Qt >= 4.4 is now required)
|
||||||
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
|
- FEATURE: Added per-torrent super seeding mode (libtorrent >= v0.15 only)
|
||||||
- FEATURE: Support for storing symbolic links in .torrent files (libtorrent >= v0.15 only)
|
- FEATURE: Support for storing symbolic links in .torrent files (libtorrent >= v0.15 only)
|
||||||
|
@ -134,6 +134,11 @@ void QTorrentHandle::get_peer_info(std::vector<peer_info>& v) const {
|
|||||||
h.get_peer_info(v);
|
h.get_peer_info(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QTorrentHandle::first_last_piece_first() const {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
|
return (h.piece_priority(0) == 7) && (h.piece_priority(h.get_torrent_info().num_pieces()-1) == 7);
|
||||||
|
}
|
||||||
|
|
||||||
size_type QTorrentHandle::total_wanted_done() const {
|
size_type QTorrentHandle::total_wanted_done() const {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
return h.status().total_wanted_done;
|
return h.status().total_wanted_done;
|
||||||
@ -532,6 +537,14 @@ void QTorrentHandle::add_tracker(announce_entry const& url) {
|
|||||||
h.add_tracker(url);
|
h.add_tracker(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QTorrentHandle::prioritize_first_last_piece(bool b) {
|
||||||
|
Q_ASSERT(h.is_valid());
|
||||||
|
int prio = 1;
|
||||||
|
if(b) prio = 7;
|
||||||
|
h.piece_priority(0, prio);
|
||||||
|
h.piece_priority(h.get_torrent_info().num_pieces()-1, prio);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
//
|
//
|
||||||
|
@ -122,6 +122,7 @@ class QTorrentHandle {
|
|||||||
void get_peer_info(std::vector<peer_info>&) const;
|
void get_peer_info(std::vector<peer_info>&) const;
|
||||||
bool resolve_countries() const;
|
bool resolve_countries() const;
|
||||||
bool priv() const;
|
bool priv() const;
|
||||||
|
bool first_last_piece_first() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setters
|
// Setters
|
||||||
@ -155,6 +156,7 @@ class QTorrentHandle {
|
|||||||
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
void set_peer_upload_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||||
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
void set_peer_download_limit(asio::ip::tcp::endpoint ip, int limit) const;
|
||||||
void add_tracker(announce_entry const& url);
|
void add_tracker(announce_entry const& url);
|
||||||
|
void prioritize_first_last_piece(bool b);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Operators
|
// Operators
|
||||||
|
@ -731,6 +731,18 @@ void TransferListWidget::toggleSelectedTorrentsSequentialDownload() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransferListWidget::toggleSelectedFirstLastPiecePrio() {
|
||||||
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
|
foreach(const QModelIndex &index, selectedIndexes) {
|
||||||
|
// Get the file hash
|
||||||
|
QString hash = getHashFromRow(proxyModel->mapToSource(index).row());
|
||||||
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
|
if(h.is_valid() && h.num_files() == 1) {
|
||||||
|
h.prioritize_first_last_piece(!h.first_last_piece_first());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListWidget::displayListMenu(const QPoint&) {
|
void TransferListWidget::displayListMenu(const QPoint&) {
|
||||||
// Create actions
|
// Create actions
|
||||||
QAction actionStart(QIcon(QString::fromUtf8(":/Icons/skin/play.png")), tr("Start"), 0);
|
QAction actionStart(QIcon(QString::fromUtf8(":/Icons/skin/play.png")), tr("Start"), 0);
|
||||||
@ -761,14 +773,16 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
||||||
QAction actionSequential_download(tr("Download in sequential order"), 0);
|
QAction actionSequential_download(tr("Download in sequential order"), 0);
|
||||||
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);
|
||||||
|
connect(&actionFirstLastPiece_prio, SIGNAL(triggered()), this, SLOT(toggleSelectedFirstLastPiecePrio()));
|
||||||
// End of actions
|
// End of actions
|
||||||
QMenu listMenu(this);
|
QMenu listMenu(this);
|
||||||
// Enable/disable pause/start action given the DL state
|
// Enable/disable pause/start action given the DL state
|
||||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||||
bool has_pause = false, has_start = false, has_preview = false;
|
bool has_pause = false, has_start = false, has_preview = false;
|
||||||
bool all_same_super_seeding = true, all_same_sequential_download_mode = true;
|
bool all_same_super_seeding = true, all_same_sequential_download_mode = true, all_same_prio_firstlast = true;
|
||||||
bool super_seeding_mode = false, sequential_download_mode = false;
|
bool super_seeding_mode = false, sequential_download_mode = false, prioritize_first_last = false;
|
||||||
bool one_has_metadata = false, one_not_seed = false;
|
bool one_has_metadata = false, one_not_seed = false, one_has_single_file = false;;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
qDebug("Displaying menu");
|
qDebug("Displaying menu");
|
||||||
@ -784,11 +798,16 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
one_not_seed = true;
|
one_not_seed = true;
|
||||||
if(first) {
|
if(first) {
|
||||||
sequential_download_mode = h.is_sequential_download();
|
sequential_download_mode = h.is_sequential_download();
|
||||||
|
prioritize_first_last = h.first_last_piece_first();
|
||||||
} else {
|
} else {
|
||||||
if(sequential_download_mode != h.is_sequential_download()) {
|
if(sequential_download_mode != h.is_sequential_download()) {
|
||||||
all_same_sequential_download_mode = false;
|
all_same_sequential_download_mode = false;
|
||||||
}
|
}
|
||||||
|
if(prioritize_first_last != h.first_last_piece_first()) {
|
||||||
|
all_same_prio_firstlast = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(h.num_files() == 1) one_has_single_file = true;
|
||||||
} else {
|
} else {
|
||||||
if(!one_not_seed && all_same_super_seeding) {
|
if(!one_not_seed && all_same_super_seeding) {
|
||||||
if(first) {
|
if(first) {
|
||||||
@ -812,7 +831,6 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(h.has_metadata() && BTSession->isFilePreviewPossible(hash) && !has_preview) {
|
if(h.has_metadata() && BTSession->isFilePreviewPossible(hash) && !has_preview) {
|
||||||
listMenu.addAction(&actionPreview_file);
|
|
||||||
has_preview = true;
|
has_preview = true;
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
@ -834,16 +852,37 @@ void TransferListWidget::displayListMenu(const QPoint&) {
|
|||||||
actionSuper_seeding_mode.setIcon(ico);
|
actionSuper_seeding_mode.setIcon(ico);
|
||||||
listMenu.addAction(&actionSuper_seeding_mode);
|
listMenu.addAction(&actionSuper_seeding_mode);
|
||||||
}
|
}
|
||||||
if(one_not_seed && all_same_sequential_download_mode) {
|
listMenu.addSeparator();
|
||||||
QIcon ico;
|
bool added_preview_action = false;
|
||||||
if(sequential_download_mode) {
|
if(has_preview) {
|
||||||
ico = QIcon(":/Icons/oxygen/button_ok.png");
|
listMenu.addAction(&actionPreview_file);
|
||||||
} else {
|
added_preview_action = true;
|
||||||
ico = QIcon(":/Icons/oxygen/button_cancel.png");
|
|
||||||
}
|
|
||||||
actionSequential_download.setIcon(ico);
|
|
||||||
listMenu.addAction(&actionSequential_download);
|
|
||||||
}
|
}
|
||||||
|
if(one_not_seed) {
|
||||||
|
if(all_same_sequential_download_mode) {
|
||||||
|
QIcon ico;
|
||||||
|
if(sequential_download_mode) {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_ok.png");
|
||||||
|
} else {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_cancel.png");
|
||||||
|
}
|
||||||
|
actionSequential_download.setIcon(ico);
|
||||||
|
listMenu.addAction(&actionSequential_download);
|
||||||
|
added_preview_action = true;
|
||||||
|
}
|
||||||
|
if(all_same_prio_firstlast && one_has_single_file) {
|
||||||
|
QIcon ico;
|
||||||
|
if(prioritize_first_last) {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_ok.png");
|
||||||
|
} else {
|
||||||
|
ico = QIcon(":/Icons/oxygen/button_cancel.png");
|
||||||
|
}
|
||||||
|
actionFirstLastPiece_prio.setIcon(ico);
|
||||||
|
listMenu.addAction(&actionFirstLastPiece_prio);
|
||||||
|
added_preview_action = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(added_preview_action)
|
||||||
listMenu.addSeparator();
|
listMenu.addSeparator();
|
||||||
if(one_has_metadata) {
|
if(one_has_metadata) {
|
||||||
listMenu.addAction(&actionForce_recheck);
|
listMenu.addAction(&actionForce_recheck);
|
||||||
|
@ -81,6 +81,7 @@ protected slots:
|
|||||||
void toggleSelectedTorrentsSuperSeeding();
|
void toggleSelectedTorrentsSuperSeeding();
|
||||||
#endif
|
#endif
|
||||||
void toggleSelectedTorrentsSequentialDownload();
|
void toggleSelectedTorrentsSequentialDownload();
|
||||||
|
void toggleSelectedFirstLastPiecePrio();
|
||||||
//void setRowColor(int row, QColor color);
|
//void setRowColor(int row, QColor color);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
Loading…
Reference in New Issue
Block a user