mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Simplify the calculation of speed graph scale
This commit is contained in:
parent
75cead9266
commit
eaaacd71a8
@ -28,9 +28,12 @@
|
|||||||
|
|
||||||
#include "speedplotview.h"
|
#include "speedplotview.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
|
||||||
#include "base/global.h"
|
#include "base/global.h"
|
||||||
#include "base/unicodestrings.h"
|
#include "base/unicodestrings.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
@ -85,20 +88,16 @@ namespace
|
|||||||
calculatedUnit = static_cast<SizeUnit>(static_cast<int>(calculatedUnit) + 1);
|
calculatedUnit = static_cast<SizeUnit>(static_cast<int>(calculatedUnit) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value > 100.0)
|
if (value > 100)
|
||||||
{
|
{
|
||||||
int roundedValue = static_cast<int>(value / 40) * 40;
|
const double roundedValue {std::ceil(value / 40) * 40};
|
||||||
while (roundedValue < value)
|
return {roundedValue, calculatedUnit};
|
||||||
roundedValue += 40;
|
|
||||||
return {static_cast<double>(roundedValue), calculatedUnit};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value > 10.0)
|
if (value > 10)
|
||||||
{
|
{
|
||||||
int roundedValue = static_cast<int>(value / 4) * 4;
|
const double roundedValue {std::ceil(value / 4) * 4};
|
||||||
while (roundedValue < value)
|
return {roundedValue, calculatedUnit};
|
||||||
roundedValue += 4;
|
|
||||||
return {static_cast<double>(roundedValue), calculatedUnit};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &roundedValue : roundingTable)
|
for (const auto &roundedValue : roundingTable)
|
||||||
|
Loading…
Reference in New Issue
Block a user