Skip to content

Commit

Permalink
Changed the parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
veloman-yunkan committed Feb 27, 2024
1 parent 0fe0fbf commit c03e0de
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/rownode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
namespace
{

QString convertToUnits(QString size)
QString convertToUnits(double bytes)
{
QStringList units = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB"};
int unitIndex = 0;
auto bytes = size.toDouble();
while (bytes >= 1024 && unitIndex < units.size()) {
bytes /= 1024;
unitIndex++;
Expand All @@ -31,8 +30,8 @@ void DownloadState::update(const DownloadInfo& downloadInfos)
double percent = downloadInfos["completedLength"].toDouble() / downloadInfos["totalLength"].toDouble();
percent *= 100;
percent = QString::number(percent, 'g', 3).toDouble();
auto completedLength = convertToUnits(downloadInfos["completedLength"].toString());
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toString()) + "/s";
auto completedLength = convertToUnits(downloadInfos["completedLength"].toDouble());
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toDouble()) + "/s";
*this = {percent, completedLength, downloadSpeed, false};
}

Expand Down

0 comments on commit c03e0de

Please sign in to comment.