mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Fix last activity calculation. Closes #7461
`time_since_upload` & `time_since_download` can be -1, so filter them out
This commit is contained in:
parent
83c6b22d30
commit
62493c672d
@ -27,6 +27,7 @@
|
|||||||
* exception statement from your version.
|
* exception statement from your version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -1108,10 +1109,9 @@ int TorrentHandle::timeSinceDownload() const
|
|||||||
|
|
||||||
int TorrentHandle::timeSinceActivity() const
|
int TorrentHandle::timeSinceActivity() const
|
||||||
{
|
{
|
||||||
if (m_nativeStatus.time_since_upload < m_nativeStatus.time_since_download)
|
return ((m_nativeStatus.time_since_upload < 0) != (m_nativeStatus.time_since_download < 0))
|
||||||
return m_nativeStatus.time_since_upload;
|
? std::max(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download)
|
||||||
else
|
: std::min(m_nativeStatus.time_since_upload, m_nativeStatus.time_since_download);
|
||||||
return m_nativeStatus.time_since_download;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TorrentHandle::downloadLimit() const
|
int TorrentHandle::downloadLimit() const
|
||||||
|
@ -181,14 +181,14 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|||||||
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
|
if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
QString elapsedString;
|
// Show '< 1m ago' when elapsed time is 0
|
||||||
if (elapsed == 0)
|
if (elapsed == 0)
|
||||||
// Show '< 1m ago' when elapsed time is 0
|
|
||||||
elapsed = 1;
|
elapsed = 1;
|
||||||
else if (elapsed < 0)
|
|
||||||
elapsedString = Utils::Misc::userFriendlyDuration(elapsed);
|
QString elapsedString = (elapsed >= 0)
|
||||||
else
|
? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed))
|
||||||
elapsedString = tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed));
|
: Utils::Misc::userFriendlyDuration(elapsed);
|
||||||
|
|
||||||
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
|
||||||
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
|
QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user