summaryrefslogtreecommitdiff
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-08-26 04:21:06 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-08-26 04:21:06 -0400
commit2eee72da6815f9d5c643b58c95f633e69da5150a (patch)
treea358d98dbe638c2d353d8e0637cd0682acbf74bc /src/downloadmanager.cpp
parentc42e5fb2fec9b20fe6956d8798b85874b2eff73e (diff)
moved code for byte sizes and speed to uibase
added scoped classes for QSettings groups and arrays servers logged on startup
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 93ca1608..a5dc164c 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1441,22 +1441,11 @@ void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
std::get<4>(info->m_SpeedDiff) = ((calc*0.5) + (std::get<4>(info->m_SpeedDiff)*1.5)) / 2;
// calculate the download speed
- double speed = (std::get<4>(info->m_SpeedDiff) * 1000.0) / (5 * 1000);
+ const double speed = (std::get<4>(info->m_SpeedDiff) * 1000.0) / (5 * 1000);
- QString unit;
- if (speed < 1000) {
- unit = "B/s";
- }
- else if (speed < 1000*1024) {
- speed /= 1024;
- unit = "KB/s";
- }
- else {
- speed /= 1024 * 1024;
- unit = "MB/s";
- }
-
- info->m_Progress.second = QString::fromLatin1("%1% - %2 %3").arg(info->m_Progress.first).arg(QString::number(speed, 'f', 1)).arg(unit);
+ info->m_Progress.second = QString::fromLatin1("%1% - %2")
+ .arg(info->m_Progress.first)
+ .arg(MOBase::localizedByteSpeed(speed));
TaskProgressManager::instance().updateProgress(info->m_TaskProgressId, bytesReceived, bytesTotal);
emit update(index);