Browse Source

Added 'Ratio Limit' column. Closes #936.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
e294b2f456
  1. 6
      src/qtlibtorrent/qbtsession.cpp
  2. 5
      src/qtlibtorrent/torrentmodel.cpp
  3. 2
      src/qtlibtorrent/torrentmodel.h
  4. 16
      src/transferlistdelegate.h
  5. 1
      src/transferlistwidget.cpp

6
src/qtlibtorrent/qbtsession.cpp

@ -1970,9 +1970,11 @@ qreal QBtSession::getMaxRatioPerTorrent(const QString &hash, bool *usesGlobalRat @@ -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;
}

5
src/qtlibtorrent/torrentmodel.cpp

@ -260,6 +260,10 @@ QVariant TorrentModelItem::data(int column, int role) const @@ -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<qlonglong>(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, @@ -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();
}

2
src/qtlibtorrent/torrentmodel.h

@ -49,7 +49,7 @@ Q_OBJECT @@ -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);

16
src/transferlistdelegate.h

@ -66,12 +66,12 @@ public: @@ -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: @@ -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: @@ -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: @@ -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;

1
src/transferlistwidget.cpp

@ -125,6 +125,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, @@ -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

Loading…
Cancel
Save