|
|
@ -665,16 +665,15 @@ void TransferListWidget::displayListMenu(const QPoint&) |
|
|
|
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
|
|
|
|
QMenu listMenu(this); |
|
|
|
|
|
|
|
// Enable/disable pause/start action given the DL state
|
|
|
|
// Enable/disable pause/start action given the DL state
|
|
|
|
bool has_pause = false, has_start = false, has_force = false, has_preview = false; |
|
|
|
bool needs_pause = false, needs_start = false, needs_force = false, needs_preview = false; |
|
|
|
bool all_same_super_seeding = true; |
|
|
|
bool all_same_super_seeding = true; |
|
|
|
bool super_seeding_mode = false; |
|
|
|
bool super_seeding_mode = false; |
|
|
|
bool all_same_sequential_download_mode = true, all_same_prio_firstlast = true; |
|
|
|
bool all_same_sequential_download_mode = true, all_same_prio_firstlast = true; |
|
|
|
bool sequential_download_mode = false, prioritize_first_last = false; |
|
|
|
bool 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; |
|
|
|
bool first = true; |
|
|
|
bool first = true; |
|
|
|
bool forced = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BitTorrent::TorrentHandle *torrent; |
|
|
|
BitTorrent::TorrentHandle *torrent; |
|
|
|
qDebug("Displaying menu"); |
|
|
|
qDebug("Displaying menu"); |
|
|
@ -686,7 +685,6 @@ void TransferListWidget::displayListMenu(const QPoint&) |
|
|
|
|
|
|
|
|
|
|
|
if (torrent->hasMetadata()) |
|
|
|
if (torrent->hasMetadata()) |
|
|
|
one_has_metadata = true; |
|
|
|
one_has_metadata = true; |
|
|
|
forced = torrent->isForced(); |
|
|
|
|
|
|
|
if (!torrent->isSeed()) { |
|
|
|
if (!torrent->isSeed()) { |
|
|
|
one_not_seed = true; |
|
|
|
one_not_seed = true; |
|
|
|
if (torrent->hasMetadata()) { |
|
|
|
if (torrent->hasMetadata()) { |
|
|
@ -712,35 +710,32 @@ void TransferListWidget::displayListMenu(const QPoint&) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (torrent->isPaused()) { |
|
|
|
if (!torrent->isForced()) |
|
|
|
if (!has_start) { |
|
|
|
needs_force = true; |
|
|
|
listMenu.addAction(&actionStart); |
|
|
|
else |
|
|
|
has_start = true; |
|
|
|
needs_start = true; |
|
|
|
} |
|
|
|
if (torrent->isPaused()) |
|
|
|
if (!has_force) { |
|
|
|
needs_start = true; |
|
|
|
listMenu.addAction(&actionForceStart); |
|
|
|
else |
|
|
|
has_force = true; |
|
|
|
needs_pause = true; |
|
|
|
|
|
|
|
if (torrent->hasMetadata()) |
|
|
|
|
|
|
|
needs_preview = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
first = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (one_has_metadata && one_not_seed && !all_same_sequential_download_mode |
|
|
|
|
|
|
|
&& !all_same_prio_firstlast && !all_same_super_seeding && needs_start |
|
|
|
|
|
|
|
&& needs_force && needs_pause && needs_preview) { |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
QMenu listMenu(this); |
|
|
|
if (forced && !has_start) { |
|
|
|
if (needs_start) |
|
|
|
listMenu.addAction(&actionStart); |
|
|
|
listMenu.addAction(&actionStart); |
|
|
|
has_start = true; |
|
|
|
if (needs_pause) |
|
|
|
} |
|
|
|
|
|
|
|
if (!has_pause) { |
|
|
|
|
|
|
|
listMenu.addAction(&actionPause); |
|
|
|
listMenu.addAction(&actionPause); |
|
|
|
has_pause = true; |
|
|
|
if (needs_force) |
|
|
|
} |
|
|
|
|
|
|
|
if (!forced && !has_force) { |
|
|
|
|
|
|
|
listMenu.addAction(&actionForceStart); |
|
|
|
listMenu.addAction(&actionForceStart); |
|
|
|
has_force = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (torrent->hasMetadata() && !has_preview) |
|
|
|
|
|
|
|
has_preview = true; |
|
|
|
|
|
|
|
first = false; |
|
|
|
|
|
|
|
if (has_pause && has_start && has_force && has_preview && one_not_seed) break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
listMenu.addSeparator(); |
|
|
|
listMenu.addSeparator(); |
|
|
|
listMenu.addAction(&actionDelete); |
|
|
|
listMenu.addAction(&actionDelete); |
|
|
|
listMenu.addSeparator(); |
|
|
|
listMenu.addSeparator(); |
|
|
@ -768,7 +763,7 @@ void TransferListWidget::displayListMenu(const QPoint&) |
|
|
|
} |
|
|
|
} |
|
|
|
listMenu.addSeparator(); |
|
|
|
listMenu.addSeparator(); |
|
|
|
bool added_preview_action = false; |
|
|
|
bool added_preview_action = false; |
|
|
|
if (has_preview) { |
|
|
|
if (needs_preview) { |
|
|
|
listMenu.addAction(&actionPreview_file); |
|
|
|
listMenu.addAction(&actionPreview_file); |
|
|
|
added_preview_action = true; |
|
|
|
added_preview_action = true; |
|
|
|
} |
|
|
|
} |
|
|
|