Browse Source

Added 'Ratio Limit' column. Closes #936.

adaptive-webui-19844
sledgehammer999 10 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
qreal ratio_limit = TorrentPersistentData::getRatioLimit(hash); qreal ratio_limit = TorrentPersistentData::getRatioLimit(hash);
if (ratio_limit == TorrentPersistentData::USE_GLOBAL_RATIO) { if (ratio_limit == TorrentPersistentData::USE_GLOBAL_RATIO) {
ratio_limit = global_ratio_limit; ratio_limit = global_ratio_limit;
*usesGlobalRatio = true; if (usesGlobalRatio)
*usesGlobalRatio = true;
} else { } else {
*usesGlobalRatio = false; if (usesGlobalRatio)
*usesGlobalRatio = false;
} }
return ratio_limit; return ratio_limit;
} }

5
src/qtlibtorrent/torrentmodel.cpp

@ -260,6 +260,10 @@ QVariant TorrentModelItem::data(int column, int role) const
return fsutils::toNativePath(m_torrent.save_path_parsed()); return fsutils::toNativePath(m_torrent.save_path_parsed());
case TR_COMPLETED: case TR_COMPLETED:
return static_cast<qlonglong>(m_lastStatus.total_wanted_done); 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: default:
return QVariant(); 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_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_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_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: default:
return QVariant(); return QVariant();
} }

2
src/qtlibtorrent/torrentmodel.h

@ -49,7 +49,7 @@ Q_OBJECT
public: 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 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: public:
TorrentModelItem(const QTorrentHandle& h); TorrentModelItem(const QTorrentHandle& h);

16
src/transferlistdelegate.h

@ -66,12 +66,12 @@ public:
case TorrentModelItem::TR_AMOUNT_UPLOADED: case TorrentModelItem::TR_AMOUNT_UPLOADED:
case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_AMOUNT_LEFT:
case TorrentModelItem::TR_COMPLETED: case TorrentModelItem::TR_COMPLETED:
case TorrentModelItem::TR_SIZE:{ case TorrentModelItem::TR_SIZE: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong()));
break; break;
} }
case TorrentModelItem::TR_ETA:{ case TorrentModelItem::TR_ETA: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong())); QItemDelegate::drawDisplay(painter, opt, option.rect, misc::userFriendlyDuration(index.data().toLongLong()));
break; break;
@ -134,14 +134,14 @@ public:
break; break;
} }
case TorrentModelItem::TR_UPSPEED: case TorrentModelItem::TR_UPSPEED:
case TorrentModelItem::TR_DLSPEED:{ case TorrentModelItem::TR_DLSPEED: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
const qulonglong speed = index.data().toULongLong(); const qulonglong speed = index.data().toULongLong();
QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)")); QItemDelegate::drawDisplay(painter, opt, opt.rect, misc::friendlyUnit(speed)+tr("/s", "/second (.i.e per second)"));
break; break;
} }
case TorrentModelItem::TR_UPLIMIT: case TorrentModelItem::TR_UPLIMIT:
case TorrentModelItem::TR_DLLIMIT:{ case TorrentModelItem::TR_DLLIMIT: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
const qlonglong limit = index.data().toLongLong(); 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("")); 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::drawBackground(painter, opt, index);
QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate)); QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate));
break; break;
case TorrentModelItem::TR_RATIO:{ case TorrentModelItem::TR_RATIO_LIMIT:
case TorrentModelItem::TR_RATIO: {
QItemDelegate::drawBackground(painter, opt, index); QItemDelegate::drawBackground(painter, opt, index);
const qreal ratio = index.data().toDouble(); 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; break;
} }
case TorrentModelItem::TR_PRIORITY: { case TorrentModelItem::TR_PRIORITY: {
@ -177,7 +179,7 @@ public:
} }
break; break;
} }
case TorrentModelItem::TR_PROGRESS:{ case TorrentModelItem::TR_PROGRESS: {
QStyleOptionProgressBarV2 newopt; QStyleOptionProgressBarV2 newopt;
qreal progress = index.data().toDouble()*100.; qreal progress = index.data().toDouble()*100.;
newopt.rect = opt.rect; newopt.rect = opt.rect;

1
src/transferlistwidget.cpp

@ -125,6 +125,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true); setColumnHidden(TorrentModelItem::TR_TIME_ELAPSED, true);
setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true); setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true);
setColumnHidden(TorrentModelItem::TR_COMPLETED, true); setColumnHidden(TorrentModelItem::TR_COMPLETED, true);
setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true);
} }
//Ensure that at least one column is visible at all times //Ensure that at least one column is visible at all times

Loading…
Cancel
Save