mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-21 19:18:39 -04:00
Changed the parameter type
This commit is contained in:
parent
b434833edc
commit
5d28f8a332
@ -10,11 +10,10 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
QString convertToUnits(QString size)
|
QString convertToUnits(double bytes)
|
||||||
{
|
{
|
||||||
QStringList units = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB"};
|
QStringList units = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB"};
|
||||||
int unitIndex = 0;
|
int unitIndex = 0;
|
||||||
auto bytes = size.toDouble();
|
|
||||||
while (bytes >= 1024 && unitIndex < units.size()) {
|
while (bytes >= 1024 && unitIndex < units.size()) {
|
||||||
bytes /= 1024;
|
bytes /= 1024;
|
||||||
unitIndex++;
|
unitIndex++;
|
||||||
@ -31,8 +30,8 @@ void DownloadState::update(const DownloadInfo& downloadInfos)
|
|||||||
double percent = downloadInfos["completedLength"].toDouble() / downloadInfos["totalLength"].toDouble();
|
double percent = downloadInfos["completedLength"].toDouble() / downloadInfos["totalLength"].toDouble();
|
||||||
percent *= 100;
|
percent *= 100;
|
||||||
percent = QString::number(percent, 'g', 3).toDouble();
|
percent = QString::number(percent, 'g', 3).toDouble();
|
||||||
auto completedLength = convertToUnits(downloadInfos["completedLength"].toString());
|
auto completedLength = convertToUnits(downloadInfos["completedLength"].toDouble());
|
||||||
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toString()) + "/s";
|
auto downloadSpeed = convertToUnits(downloadInfos["downloadSpeed"].toDouble()) + "/s";
|
||||||
*this = {percent, completedLength, downloadSpeed, false};
|
*this = {percent, completedLength, downloadSpeed, false};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user