From 6a45919b259fc91a16927bec15b4f5eea8992fe1 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 6 Feb 2021 11:25:17 +0800 Subject: [PATCH] Clean up coding style --- src/base/bittorrent/torrent.cpp | 8 +++----- src/gui/transferlistmodel.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/base/bittorrent/torrent.cpp b/src/base/bittorrent/torrent.cpp index e0dcb9ca0..d7e52ff8d 100644 --- a/src/base/bittorrent/torrent.cpp +++ b/src/base/bittorrent/torrent.cpp @@ -29,8 +29,6 @@ #include "torrent.h" -#include - #include namespace BitTorrent @@ -42,13 +40,13 @@ namespace BitTorrent // Torrent - const qreal Torrent::USE_GLOBAL_RATIO = -2.; - const qreal Torrent::NO_RATIO_LIMIT = -1.; + const qreal Torrent::USE_GLOBAL_RATIO = -2; + const qreal Torrent::NO_RATIO_LIMIT = -1; const int Torrent::USE_GLOBAL_SEEDING_TIME = -2; const int Torrent::NO_SEEDING_TIME_LIMIT = -1; - const qreal Torrent::MAX_RATIO = 9999.; + const qreal Torrent::MAX_RATIO = 9999; const int Torrent::MAX_SEEDING_TIME = 525600; bool Torrent::isResumed() const diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 1c6508412..5f8b6a3f0 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -239,7 +239,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons bool hideValues = false; if (m_hideZeroValuesMode == HideZeroValuesMode::Always) hideValues = true; - else if (m_hideZeroValuesMode != HideZeroValuesMode::Never) + else if (m_hideZeroValuesMode == HideZeroValuesMode::Paused) hideValues = (torrent->state() == BitTorrent::TorrentState::PausedDownloading); const auto availabilityString = [hideValues](const qreal value) -> QString @@ -269,9 +269,9 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons const auto amountString = [hideValues](const qint64 value, const qint64 total) -> QString { - return (hideValues && (value == 0) && (total == 0)) - ? QString {} - : QString::number(value) + " (" + QString::number(total) + ')'; + if (hideValues && (value == 0) && (total == 0)) + return {}; + return QString::fromLatin1("%1 (%2)").arg(QString::number(value), QString::number(total)); }; const auto ratioString = [hideValues](const qreal value) -> QString @@ -285,13 +285,13 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons const auto queuePositionString = [](const qint64 value) -> QString { - return (value > 0) ? QString::number(value) : "*"; + return (value > 0) ? QString::number(value) : QLatin1String("*"); }; const auto lastActivityString = [hideValues](qint64 value) -> QString { if (hideValues && ((value < 0) || (value >= MAX_ETA))) - return QString {}; + return {}; // Show '< 1m ago' when elapsed time is 0 if (value == 0)