From a501f9d223dd1c77784bf8746e4a67d368028c8d Mon Sep 17 00:00:00 2001 From: Gabriele Date: Fri, 24 Oct 2014 20:41:03 +0100 Subject: [PATCH 1/3] Add "Last Seen Complete" column to transfer list This column shows when we or one of our peers last saw a complete copy of the related torrent. Closes #483. --- src/qtlibtorrent/torrentmodel.cpp | 3 +++ src/qtlibtorrent/torrentmodel.h | 2 +- src/transferlistsortmodel.h | 2 +- src/transferlistwidget.cpp | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index b48bc782e..94266f2bc 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -290,6 +290,8 @@ QVariant TorrentModelItem::data(int column, int role) const QString hash = misc::toQString(m_lastStatus.info_hash); return QBtSession::instance()->getMaxRatioPerTorrent(hash, NULL); } + case TR_SEEN_COMPLETE_DATE: + return m_lastStatus.last_seen_complete ? QDateTime::fromTime_t(m_lastStatus.last_seen_complete) : QDateTime(); default: return QVariant(); } @@ -366,6 +368,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, 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"); + case TorrentModelItem::TR_SEEN_COMPLETE_DATE: return tr("Last Seen Complete", "Torrent was seen complete on 01/01/2010 08:00"); default: return QVariant(); } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index e77bf4644..6c138da25 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, TR_RATIO_LIMIT, 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, NB_COLUMNS}; public: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/transferlistsortmodel.h b/src/transferlistsortmodel.h index dd4157e4e..7414172c4 100644 --- a/src/transferlistsortmodel.h +++ b/src/transferlistsortmodel.h @@ -59,7 +59,7 @@ protected: return QSortFilterProxyModel::lessThan(left, right); } - else if (column == TorrentModelItem::TR_ADD_DATE || column == TorrentModelItem::TR_SEED_DATE) { + else if (column == TorrentModelItem::TR_ADD_DATE || column == TorrentModelItem::TR_SEED_DATE || column == TorrentModelItem::TR_SEEN_COMPLETE_DATE) { QDateTime vL = left.data().toDateTime(); QDateTime vR = right.data().toDateTime(); diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 6b22ca885..c53d648bc 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -130,6 +130,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true); setColumnHidden(TorrentModelItem::TR_COMPLETED, true); setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true); + setColumnHidden(TorrentModelItem::TR_SEEN_COMPLETE_DATE, true); } //Ensure that at least one column is visible at all times From b1af99ffbab8973a79be94ac213defbe5414bce1 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Fri, 24 Oct 2014 20:41:06 +0100 Subject: [PATCH 2/3] 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. --- src/qtlibtorrent/torrentmodel.cpp | 8 ++++++++ src/qtlibtorrent/torrentmodel.h | 2 +- src/transferlistdelegate.cpp | 12 ++++++++++++ src/transferlistwidget.cpp | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 94266f2bc..dd31c483e 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -292,6 +292,13 @@ QVariant TorrentModelItem::data(int column, int role) const } case TR_SEEN_COMPLETE_DATE: 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: 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_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_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded"); default: return QVariant(); } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 6c138da25..87de6684a 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, 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: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/transferlistdelegate.cpp b/src/transferlistdelegate.cpp index ed3778c4c..865692c83 100644 --- a/src/transferlistdelegate.cpp +++ b/src/transferlistdelegate.cpp @@ -201,6 +201,18 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem #endif 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: QItemDelegate::paint(painter, option, index); } diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index c53d648bc..7724927ea 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -131,6 +131,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setColumnHidden(TorrentModelItem::TR_COMPLETED, true); setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, 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 From b63f647c2cda89c872df59b4fbb36233833d454e Mon Sep 17 00:00:00 2001 From: Gabriele Date: Sun, 26 Oct 2014 18:02:46 +0100 Subject: [PATCH 3/3] Add "Total Size" column to transfer list This column shows the total size of the related torrent taking into account also the unwanted data. Closes #1233. --- src/qtlibtorrent/torrentmodel.cpp | 3 +++ src/qtlibtorrent/torrentmodel.h | 2 +- src/transferlistdelegate.cpp | 3 ++- src/transferlistwidget.cpp | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index dd31c483e..eb819ee03 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -299,6 +299,8 @@ QVariant TorrentModelItem::data(int column, int role) const return m_lastStatus.time_since_upload; else return m_lastStatus.time_since_download; + case TR_TOTAL_SIZE: + return m_lastStatus.has_metadata ? static_cast(m_torrent.total_size()) : -1; default: return QVariant(); } @@ -377,6 +379,7 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, 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_LAST_ACTIVITY: return tr("Last Activity", "Time passed since a chunk was downloaded/uploaded"); + case TorrentModelItem::TR_TOTAL_SIZE: return tr("Total Size", "i.e. Size including unwanted data"); default: return QVariant(); } diff --git a/src/qtlibtorrent/torrentmodel.h b/src/qtlibtorrent/torrentmodel.h index 87de6684a..e62fce743 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, TR_RATIO_LIMIT, TR_SEEN_COMPLETE_DATE, TR_LAST_ACTIVITY, NB_COLUMNS}; + enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_TOTAL_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: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/transferlistdelegate.cpp b/src/transferlistdelegate.cpp index 865692c83..5fcf2e68d 100644 --- a/src/transferlistdelegate.cpp +++ b/src/transferlistdelegate.cpp @@ -58,7 +58,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem case TorrentModelItem::TR_AMOUNT_UPLOADED: case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_COMPLETED: - case TorrentModelItem::TR_SIZE: { + case TorrentModelItem::TR_SIZE: + case TorrentModelItem::TR_TOTAL_SIZE: { QItemDelegate::drawBackground(painter, opt, index); opt.displayAlignment = Qt::AlignRight; QItemDelegate::drawDisplay(painter, opt, option.rect, misc::friendlyUnit(index.data().toLongLong())); diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 7724927ea..f8e435a09 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -132,6 +132,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setColumnHidden(TorrentModelItem::TR_RATIO_LIMIT, true); setColumnHidden(TorrentModelItem::TR_SEEN_COMPLETE_DATE, true); setColumnHidden(TorrentModelItem::TR_LAST_ACTIVITY, true); + setColumnHidden(TorrentModelItem::TR_TOTAL_SIZE, true); } //Ensure that at least one column is visible at all times