Browse Source

Merge pull request #7480 from Chocobo1/lastAct

Fix last activity calculation
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
1fe9272a8f
  1. 8
      src/base/bittorrent/torrenthandle.cpp
  2. 12
      src/gui/transferlistdelegate.cpp

8
src/base/bittorrent/torrenthandle.cpp

@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
* exception statement from your version.
*/
#include <algorithm>
#include <type_traits>
#include <QDebug>
@ -1108,10 +1109,9 @@ int TorrentHandle::timeSinceDownload() const @@ -1108,10 +1109,9 @@ int TorrentHandle::timeSinceDownload() const
int TorrentHandle::timeSinceActivity() const
{
if (m_nativeStatus.time_since_upload < m_nativeStatus.time_since_download)
return m_nativeStatus.time_since_upload;
else
return m_nativeStatus.time_since_download;
return ((m_nativeStatus.time_since_upload < 0) != (m_nativeStatus.time_since_download < 0))
? std::max(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download)
: std::min(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download);
}
int TorrentHandle::downloadLimit() const

12
src/gui/transferlistdelegate.cpp

@ -181,14 +181,14 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem @@ -181,14 +181,14 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
break;
QString elapsedString;
// Show '< 1m ago' when elapsed time is 0
if (elapsed == 0)
// Show '< 1m ago' when elapsed time is 0
elapsed = 1;
else if (elapsed < 0)
elapsedString = Utils::Misc::userFriendlyDuration(elapsed);
else
elapsedString = tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed));
QString elapsedString = (elapsed >= 0)
? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed))
: Utils::Misc::userFriendlyDuration(elapsed);
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
break;

Loading…
Cancel
Save