diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 7e4046b5b..b4718b122 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1970,9 +1970,11 @@ qreal QBtSession::getMaxRatioPerTorrent(const QString &hash, bool *usesGlobalRat qreal ratio_limit = TorrentPersistentData::getRatioLimit(hash); if (ratio_limit == TorrentPersistentData::USE_GLOBAL_RATIO) { ratio_limit = global_ratio_limit; - *usesGlobalRatio = true; + if (usesGlobalRatio) + *usesGlobalRatio = true; } else { - *usesGlobalRatio = false; + if (usesGlobalRatio) + *usesGlobalRatio = false; } return ratio_limit; } diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 12645a91b..3dca808c7 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -260,6 +260,10 @@ QVariant TorrentModelItem::data(int column, int role) const return fsutils::toNativePath(m_torrent.save_path_parsed()); case TR_COMPLETED: return static_cast(m_lastStatus.total_wanted_done); + case TR_RATIO_LIMIT: { + QString hash = misc::toQString(m_lastStatus.info_hash); + return QBtSession::instance()->getMaxRatioPerTorrent(hash, NULL); + } default: return QVariant(); } @@ -335,6 +339,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, case TorrentModelItem::TR_TIME_ELAPSED: return tr("Time Active", "Time (duration) the torrent is active (not paused)"); case TorrentModelItem::TR_SAVE_PATH: return tr("Save path", "Torrent save path"); case TorrentModelItem::TR_COMPLETED: return tr("Completed", "Amount of data completed (e.g. in MB)"); + case TorrentModelItem::TR_RATIO_LIMIT: return tr("Ratio Limit", "Upload share ratio limit"); default: return QVariant(); } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 8540155d0..40e35bb0a 100644 --- a/src/qtlibtorrent/torrentmodel.h +++ b/src/qtlibtorrent/torrentmodel.h @@ -49,7 +49,7 @@ Q_OBJECT public: enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_INVALID}; - enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, TR_SAVE_PATH, TR_COMPLETED, NB_COLUMNS}; + enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_TRACKER, TR_DLLIMIT, TR_UPLIMIT, TR_AMOUNT_DOWNLOADED, TR_AMOUNT_UPLOADED, TR_AMOUNT_LEFT, TR_TIME_ELAPSED, TR_SAVE_PATH, TR_COMPLETED, TR_RATIO_LIMIT, NB_COLUMNS}; public: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/transferlistdelegate.h b/src/transferlistdelegate.h index 17fe94da4..6125c4a59 100644 --- a/src/transferlistdelegate.h +++ b/src/transferlistdelegate.h @@ -66,12 +66,12 @@ public: case TorrentModelItem::TR_AMOUNT_UPLOADED: case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_COMPLETED: - case TorrentModelItem::TR_SIZE:{ + case TorrentModelItem::TR_SIZE: { QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); break; } - case TorrentModelItem::TR_ETA:{ + case TorrentModelItem::TR_ETA: { QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong())); break; @@ -134,14 +134,14 @@ public: break; } case TorrentModelItem::TR_UPSPEED: - case TorrentModelItem::TR_DLSPEED:{ + case TorrentModelItem::TR_DLSPEED: { QItemDelegate::drawBackground(painter, opt, index); const qulonglong speed = index.data().toULongLong(); QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); break; } case TorrentModelItem::TR_UPLIMIT: - case TorrentModelItem::TR_DLLIMIT:{ + case TorrentModelItem::TR_DLLIMIT: { QItemDelegate::drawBackground(painter, opt, index); const qlonglong limit = index.data().toLongLong(); QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? misc::accurateDoubleToString(limit/1024., 1) + " " + tr("KiB/s", "KiB/second (.i.e per second)") : QString::fromUtf8("∞")); @@ -161,10 +161,12 @@ public: QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate)); break; - case TorrentModelItem::TR_RATIO:{ + case TorrentModelItem::TR_RATIO_LIMIT: + case TorrentModelItem::TR_RATIO: { QItemDelegate::drawBackground(painter, opt, index); const qreal ratio = index.data().toDouble(); - QItemDelegate::drawDisplay(painter, opt, opt.rect, ratio > QBtSession::MAX_RATIO ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2)); + QItemDelegate::drawDisplay(painter, opt, opt.rect, + (ratio == -1 || ratio > QBtSession::MAX_RATIO) ? QString::fromUtf8("∞") : misc::accurateDoubleToString(ratio, 2)); break; } case TorrentModelItem::TR_PRIORITY: { @@ -177,7 +179,7 @@ public: } break; } - case TorrentModelItem::TR_PROGRESS:{ + case TorrentModelItem::TR_PROGRESS: { QStyleOptionProgressBarV2 newopt; qreal progress = index.data().toDouble()*100.; newopt.rect = opt.rect; diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index ab3a980c4..fbe9a912d 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -125,6 +125,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true); setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true); setColumnHidden(TorrentModelItem::TR_COMPLETED, true); + setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true); } //Ensure that at least one column is visible at all times