From 4dadf969250c0f8524f78183b3ab83132ed31ddd Mon Sep 17 00:00:00 2001 From: LazyBui Date: Mon, 16 Mar 2015 09:41:39 -0500 Subject: [PATCH] Implementing support for session-based download and upload statistics --- src/core/qtlibtorrent/torrentmodel.cpp | 8 ++++++++ src/core/qtlibtorrent/torrentmodel.h | 2 +- src/gui/transferlistdelegate.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/qtlibtorrent/torrentmodel.cpp b/src/core/qtlibtorrent/torrentmodel.cpp index 43c9a28f9..e02ecb74a 100644 --- a/src/core/qtlibtorrent/torrentmodel.cpp +++ b/src/core/qtlibtorrent/torrentmodel.cpp @@ -284,6 +284,10 @@ QVariant TorrentModelItem::data(int column, int role) const return static_cast(m_lastStatus.all_time_download); case TR_AMOUNT_UPLOADED: return static_cast(m_lastStatus.all_time_upload); + case TR_AMOUNT_DOWNLOADED_SESSION: + return static_cast(m_lastStatus.total_payload_download); + case TR_AMOUNT_UPLOADED_SESSION: + return static_cast(m_lastStatus.total_payload_upload); case TR_AMOUNT_LEFT: return static_cast(m_lastStatus.total_wanted - m_lastStatus.total_wanted_done); case TR_TIME_ELAPSED: @@ -377,6 +381,8 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, case TorrentModelItem::TR_UPLIMIT: return tr("Up Limit", "i.e: Upload limit"); case TorrentModelItem::TR_AMOUNT_DOWNLOADED: return tr("Downloaded", "Amount of data downloaded (e.g. in MB)"); case TorrentModelItem::TR_AMOUNT_UPLOADED: return tr("Uploaded", "Amount of data uploaded (e.g. in MB)"); + case TorrentModelItem::TR_AMOUNT_DOWNLOADED_SESSION: return tr("Session Download", "Amount of data downloaded since program open (e.g. in MB)"); + case TorrentModelItem::TR_AMOUNT_UPLOADED_SESSION: return tr("Session Upload", "Amount of data uploaded since program open (e.g. in MB)"); case TorrentModelItem::TR_AMOUNT_LEFT: return tr("Remaining", "Amount of data left to download (e.g. in MB)"); 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"); @@ -393,6 +399,8 @@ QVariant TorrentModel::headerData(int section, Qt::Orientation orientation, switch(section) { case TorrentModelItem::TR_AMOUNT_DOWNLOADED: case TorrentModelItem::TR_AMOUNT_UPLOADED: + case TorrentModelItem::TR_AMOUNT_DOWNLOADED_SESSION: + case TorrentModelItem::TR_AMOUNT_UPLOADED_SESSION: case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_COMPLETED: case TorrentModelItem::TR_SIZE: diff --git a/src/core/qtlibtorrent/torrentmodel.h b/src/core/qtlibtorrent/torrentmodel.h index d2d5a64c4..28d751b0c 100644 --- a/src/core/qtlibtorrent/torrentmodel.h +++ b/src/core/qtlibtorrent/torrentmodel.h @@ -49,7 +49,7 @@ class TorrentModelItem : public QObject { public: enum State {STATE_DOWNLOADING, STATE_DOWNLOADING_META, STATE_ALLOCATING, STATE_STALLED_DL, STATE_SEEDING, STATE_STALLED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_QUEUED_CHECK, STATE_QUEUED_FASTCHECK, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_PAUSED_MISSING, STATE_INVALID}; - 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}; + 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, TR_AMOUNT_DOWNLOADED_SESSION, TR_AMOUNT_UPLOADED_SESSION, NB_COLUMNS}; public: TorrentModelItem(const QTorrentHandle& h); diff --git a/src/gui/transferlistdelegate.cpp b/src/gui/transferlistdelegate.cpp index f3c3ceed8..ac872f237 100644 --- a/src/gui/transferlistdelegate.cpp +++ b/src/gui/transferlistdelegate.cpp @@ -56,6 +56,8 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem switch(index.column()) { case TorrentModelItem::TR_AMOUNT_DOWNLOADED: case TorrentModelItem::TR_AMOUNT_UPLOADED: + case TorrentModelItem::TR_AMOUNT_DOWNLOADED_SESSION: + case TorrentModelItem::TR_AMOUNT_UPLOADED_SESSION: case TorrentModelItem::TR_AMOUNT_LEFT: case TorrentModelItem::TR_COMPLETED: case TorrentModelItem::TR_SIZE: