mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Improve and fix comic file size format
This commit is contained in:
parent
374898702d
commit
2b2762c045
@ -8,6 +8,7 @@ Version counting is based on semantic versioning (Major.Feature.Patch)
|
|||||||
* Fix columns in the search results.
|
* Fix columns in the search results.
|
||||||
* Fix type not being propagated to new folders from their parents.
|
* Fix type not being propagated to new folders from their parents.
|
||||||
* Fix default type set to folders in the root folder when they are added.
|
* Fix default type set to folders in the root folder when they are added.
|
||||||
|
* Improve and fix comic file size format.
|
||||||
|
|
||||||
## 9.14.1
|
## 9.14.1
|
||||||
|
|
||||||
|
@ -290,7 +290,18 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
|
|||||||
auto item = static_cast<ComicItem *>(index.internalPointer());
|
auto item = static_cast<ComicItem *>(index.internalPointer());
|
||||||
|
|
||||||
auto sizeString = [=] {
|
auto sizeString = [=] {
|
||||||
return QString::number(item->data(ComicModel::Hash).toString().right(item->data(ComicModel::Hash).toString().length() - 40).toInt() / 1024.0 / 1024.0, 'f', 2) + "Mb";
|
auto bytes = item->data(ComicModel::Hash).toString().right(item->data(ComicModel::Hash).toString().length() - 40).toULongLong();
|
||||||
|
|
||||||
|
QStringList units = { "B", "KB", "MB", "GB", "TB" };
|
||||||
|
int i;
|
||||||
|
double outputSize = bytes;
|
||||||
|
for (i = 0; i < units.size() - 1; i++) {
|
||||||
|
if (outputSize < 1024) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
outputSize = outputSize / 1024;
|
||||||
|
}
|
||||||
|
return QString("%1 %2").arg(outputSize, 0, 'f', 2).arg(units[i]);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (role == NumberRole)
|
if (role == NumberRole)
|
||||||
|
Loading…
Reference in New Issue
Block a user