From 2eee72da6815f9d5c643b58c95f633e69da5150a Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 26 Aug 2019 04:21:06 -0400 Subject: moved code for byte sizes and speed to uibase added scoped classes for QSettings groups and arrays servers logged on startup --- src/downloadlist.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/downloadlist.cpp') diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp index 36bc2b7f..6957f270 100644 --- a/src/downloadlist.cpp +++ b/src/downloadlist.cpp @@ -19,6 +19,7 @@ along with Mod Organizer. If not, see . #include "downloadlist.h" #include "downloadmanager.h" +#include #include #include #include @@ -121,7 +122,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const return QString("%1").arg(m_Manager->getModID(index.row())); } } - case COL_SIZE: return sizeFormat(m_Manager->getFileSize(index.row())); + case COL_SIZE: return MOBase::localizedByteSize(m_Manager->getFileSize(index.row())); case COL_FILETIME: return m_Manager->getFileTime(index.row()); case COL_STATUS: switch (m_Manager->getState(index.row())) { @@ -195,21 +196,3 @@ void DownloadList::update(int row) else log::error("invalid row {} in download list, update failed", row); } - -QString DownloadList::sizeFormat(quint64 size) const -{ - qreal calc = size; - QStringList list; - list << "MB" << "GB" << "TB"; - - QStringListIterator i(list); - QString unit("KB"); - - calc /= 1024.0; - while (calc >= 1024.0 && i.hasNext()) { - unit = i.next(); - calc /= 1024.0; - } - - return QString().setNum(calc, 'f', 2) + " " + unit; -} -- cgit v1.3.1