mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Fix "Pause/Delete" torrents once they reach a given ratio
This commit is contained in:
parent
5a82aee76b
commit
dfecdb1956
@ -212,6 +212,7 @@ ScanFoldersModel* Bittorrent::getScanFoldersModel() const {
|
|||||||
|
|
||||||
void Bittorrent::processBigRatios() {
|
void Bittorrent::processBigRatios() {
|
||||||
if(ratio_limit <= 0) return;
|
if(ratio_limit <= 0) return;
|
||||||
|
qDebug("Process big ratios...");
|
||||||
std::vector<torrent_handle> torrents = getTorrents();
|
std::vector<torrent_handle> torrents = getTorrents();
|
||||||
std::vector<torrent_handle>::iterator torrentIT;
|
std::vector<torrent_handle>::iterator torrentIT;
|
||||||
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||||
@ -220,16 +221,20 @@ void Bittorrent::processBigRatios() {
|
|||||||
if(h.is_seed()) {
|
if(h.is_seed()) {
|
||||||
const QString hash = h.hash();
|
const QString hash = h.hash();
|
||||||
const float ratio = getRealRatio(hash);
|
const float ratio = getRealRatio(hash);
|
||||||
if(ratio <= MAX_RATIO && ratio > ratio_limit) {
|
qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit);
|
||||||
addConsoleMessage(tr("%1 reached the maximum ratio you set.").arg(h.name()));
|
if(ratio <= MAX_RATIO && ratio >= ratio_limit) {
|
||||||
if(high_ratio_action == REMOVE_ACTION) {
|
if(high_ratio_action == REMOVE_ACTION) {
|
||||||
|
addConsoleMessage(tr("%1 reached the maximum ratio you set.").arg(h.name()));
|
||||||
addConsoleMessage(tr("Removing torrent %1...").arg(h.name()));
|
addConsoleMessage(tr("Removing torrent %1...").arg(h.name()));
|
||||||
deleteTorrent(hash);
|
deleteTorrent(hash);
|
||||||
} else {
|
} else {
|
||||||
// Pause it
|
// Pause it
|
||||||
|
if(!h.is_paused()) {
|
||||||
|
addConsoleMessage(tr("%1 reached the maximum ratio you set.").arg(h.name()));
|
||||||
addConsoleMessage(tr("Pausing torrent %1...").arg(h.name()));
|
addConsoleMessage(tr("Pausing torrent %1...").arg(h.name()));
|
||||||
pauseTorrent(hash);
|
pauseTorrent(hash);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//emit torrent_ratio_deleted(fileName);
|
//emit torrent_ratio_deleted(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ void PropertiesWidget::loadDynamicData() {
|
|||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
shareRatio->setText(QString::fromUtf8("∞"));
|
shareRatio->setText(QString::fromUtf8("∞"));
|
||||||
else
|
else
|
||||||
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
|
shareRatio->setText(QString(QByteArray::number(ratio, 'f', 2)));
|
||||||
if(!h.is_seed()) {
|
if(!h.is_seed()) {
|
||||||
showPiecesDownloaded(true);
|
showPiecesDownloaded(true);
|
||||||
// Downloaded pieces
|
// Downloaded pieces
|
||||||
|
@ -142,7 +142,7 @@ public:
|
|||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞"));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::fromUtf8("∞"));
|
||||||
else
|
else
|
||||||
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(ratio, 'f', 1));
|
QItemDelegate::drawDisplay(painter, opt, opt.rect, QString::number(ratio, 'f', 2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TR_PRIORITY: {
|
case TR_PRIORITY: {
|
||||||
|
Loading…
Reference in New Issue
Block a user