Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Drop redundant QString calls #2296

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ QString dateTimeStr(qint64 nTime)

QString formatPingTime(double dPingTime)
{
return (dPingTime == std::numeric_limits<int64_t>::max()/1e6 || dPingTime == 0) ? QObject::tr("N/A") : QString(QObject::tr("%1 ms")).arg(QString::number((int)(dPingTime * 1000), 10));
return (dPingTime == std::numeric_limits<int64_t>::max()/1e6 || dPingTime == 0) ?
QObject::tr("N/A") :
QObject::tr("%1 ms").arg(QString::number((int)(dPingTime * 1000), 10));
}

QString formatTimeOffset(int64_t nTimeOffset)
{
return QString(QObject::tr("%1 s")).arg(QString::number((int)nTimeOffset, 10));
return QObject::tr("%1 s").arg(QString::number((int)nTimeOffset, 10));
}

QString formatNiceTimeOffset(qint64 secs)
Expand Down Expand Up @@ -105,13 +107,13 @@ QString formatNiceTimeOffset(qint64 secs)
QString formatBytes(uint64_t bytes)
{
if(bytes < 1024)
return QString(QObject::tr("%1 B")).arg(bytes);
return QObject::tr("%1 B").arg(bytes);
if(bytes < 1024 * 1024)
return QString(QObject::tr("%1 KB")).arg(bytes / 1024);
return QObject::tr("%1 KB").arg(bytes / 1024);
if(bytes < 1024 * 1024 * 1024)
return QString(QObject::tr("%1 MB")).arg(bytes / 1024 / 1024);
return QObject::tr("%1 MB").arg(bytes / 1024 / 1024);

return QString(QObject::tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024);
return QObject::tr("%1 GB").arg(bytes / 1024 / 1024 / 1024);
}

QString formatDurationStr(int secs)
Expand All @@ -123,13 +125,13 @@ QString formatDurationStr(int secs)
int seconds = secs % 60;

if (days)
strList.append(QString(QObject::tr("%1 d")).arg(days));
strList.append(QObject::tr("%1 d").arg(days));
if (hours)
strList.append(QString(QObject::tr("%1 h")).arg(hours));
strList.append(QObject::tr("%1 h").arg(hours));
if (mins)
strList.append(QString(QObject::tr("%1 m")).arg(mins));
strList.append(QObject::tr("%1 m").arg(mins));
if (seconds || (!days && !hours && !mins))
strList.append(QString(QObject::tr("%1 s")).arg(seconds));
strList.append(QObject::tr("%1 s").arg(seconds));

return strList.join(" ");
}
Expand Down