Browse Source

Add "Last Activity" column to transfer list

This column shows the time elapsed since the related torrent has
received or sent a chunk.

Closes #517.
adaptive-webui-19844
Gabriele 10 years ago
parent
commit
b1af99ffba
  1. 8
      src/qtlibtorrent/torrentmodel.cpp
  2. 2
      src/qtlibtorrent/torrentmodel.h
  3. 12
      src/transferlistdelegate.cpp
  4. 1
      src/transferlistwidget.cpp

8
src/qtlibtorrent/torrentmodel.cpp

@ -292,6 +292,13 @@ QVariant TorrentModelItem::data(int column, int role) const
} }
case TR_SEEN_COMPLETE_DATE: case TR_SEEN_COMPLETE_DATE:
return m_lastStatus.last_seen_complete ? QDateTime::fromTime_t(m_lastStatus.last_seen_complete) : QDateTime(); return m_lastStatus.last_seen_complete ? QDateTime::fromTime_t(m_lastStatus.last_seen_complete) : QDateTime();
case TR_LAST_ACTIVITY:
if (m_torrent.is_paused(m_lastStatus) || m_torrent.is_checking(m_lastStatus))
return -1;
if (m_lastStatus.time_since_upload < m_lastStatus.time_since_download)
return m_lastStatus.time_since_upload;
else
return m_lastStatus.time_since_download;
default: default:
return QVariant(); return QVariant();
} }
@ -369,6 +376,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation,
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"); case TorrentModelItem::TR_RATIO_LIMIT: return tr("Ratio Limit", "Upload share ratio limit");
case TorrentModelItem::TR_SEEN_COMPLETE_DATE: return tr("Last Seen Complete", "Torrent was seen complete on 01/01/2010 08:00"); case TorrentModelItem::TR_SEEN_COMPLETE_DATE: return tr("Last Seen Complete", "Torrent was seen complete on 01/01/2010 08:00");
case TorrentModelItem::TR_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded");
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, TR_RATIO_LIMIT, TR_SEEN_COMPLETE_DATE, 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, TR_SEEN_COMPLETE_DATE, TR_LAST_ACTIVITY, NB_COLUMNS};
public: public:
TorrentModelItem(const QTorrentHandle& h); TorrentModelItem(const QTorrentHandle& h);

12
src/transferlistdelegate.cpp

@ -201,6 +201,18 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
#endif #endif
break; break;
} }
case TorrentModelItem::TR_LAST_ACTIVITY: {
QString elapsedString;
long long elapsed = index.data().toLongLong();
QItemDelegate::drawBackground(painter, opt, index);
opt.displayAlignment = Qt::AlignRight;
if (elapsed == 0)
// Show '< 1m ago' when elapsed time is 0
elapsed = 1;
elapsedString = tr("%1 ago", "e.g.: 1h 20m ago").arg(misc::userFriendlyDuration(elapsed));
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
break;
}
default: default:
QItemDelegate::paint(painter, option, index); QItemDelegate::paint(painter, option, index);
} }

1
src/transferlistwidget.cpp

@ -131,6 +131,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
setColumnHidden(TorrentModelItem::TR_COMPLETED, true); setColumnHidden(TorrentModelItem::TR_COMPLETED, true);
setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true); setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true);
setColumnHidden(TorrentModelItem::TR_SEEN_COMPLETE_DATE, true); setColumnHidden(TorrentModelItem::TR_SEEN_COMPLETE_DATE, true);
setColumnHidden(TorrentModelItem::TR_LAST_ACTIVITY, 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