mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 03:06:37 +03:00
Use qreal
type whenever feasible
The idea is follow Qt and use `qreal` instead of `double` for generic code.
This commit is contained in:
parent
a5a4ea9ba0
commit
852927bf50
1 changed files with 13 additions and 13 deletions
|
@ -43,19 +43,19 @@
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// table of supposed nice steps for grid marks to get nice looking quarters of scale
|
// table of supposed nice steps for grid marks to get nice looking quarters of scale
|
||||||
const double roundingTable[] = {1.2, 1.6, 2, 2.4, 2.8, 3.2, 4, 6, 8};
|
const qreal roundingTable[] = {1.2, 1.6, 2, 2.4, 2.8, 3.2, 4, 6, 8};
|
||||||
|
|
||||||
struct SplitValue
|
struct SplitValue
|
||||||
{
|
{
|
||||||
double arg;
|
qreal arg = 0;
|
||||||
Utils::Misc::SizeUnit unit;
|
Utils::Misc::SizeUnit unit {};
|
||||||
qint64 sizeInBytes() const
|
qlonglong sizeInBytes() const
|
||||||
{
|
{
|
||||||
return Utils::Misc::sizeInBytes(arg, unit);
|
return Utils::Misc::sizeInBytes(arg, unit);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SplitValue getRoundedYScale(double value)
|
SplitValue getRoundedYScale(qreal value)
|
||||||
{
|
{
|
||||||
using Utils::Misc::SizeUnit;
|
using Utils::Misc::SizeUnit;
|
||||||
|
|
||||||
|
@ -71,13 +71,13 @@ namespace
|
||||||
|
|
||||||
if (value > 100)
|
if (value > 100)
|
||||||
{
|
{
|
||||||
const double roundedValue {std::ceil(value / 40) * 40};
|
const qreal roundedValue {std::ceil(value / 40) * 40};
|
||||||
return {roundedValue, calculatedUnit};
|
return {roundedValue, calculatedUnit};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value > 10)
|
if (value > 10)
|
||||||
{
|
{
|
||||||
const double roundedValue {std::ceil(value / 4) * 4};
|
const qreal roundedValue {std::ceil(value / 4) * 4};
|
||||||
return {roundedValue, calculatedUnit};
|
return {roundedValue, calculatedUnit};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ namespace
|
||||||
return {10.0, calculatedUnit};
|
return {10.0, calculatedUnit};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString formatLabel(const double argValue, const Utils::Misc::SizeUnit unit)
|
QString formatLabel(const qreal argValue, const Utils::Misc::SizeUnit unit)
|
||||||
{
|
{
|
||||||
// check is there need for digits after decimal separator
|
// check is there need for digits after decimal separator
|
||||||
const int precision = (argValue < 10) ? friendlyUnitPrecision(unit) : 0;
|
const int precision = (argValue < 10) ? friendlyUnitPrecision(unit) : 0;
|
||||||
|
@ -351,8 +351,8 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
// last point will be drawn at x=0, so we don't need it in the calculation of xTickSize
|
// last point will be drawn at x=0, so we don't need it in the calculation of xTickSize
|
||||||
const milliseconds lastDuration {queue.empty() ? 0ms : queue.back().duration};
|
const milliseconds lastDuration {queue.empty() ? 0ms : queue.back().duration};
|
||||||
const double xTickSize = static_cast<double>(rect.width()) / (m_currentMaxDuration - lastDuration).count();
|
const qreal xTickSize = static_cast<qreal>(rect.width()) / (m_currentMaxDuration - lastDuration).count();
|
||||||
const double yMultiplier = (niceScale.arg == 0) ? 0 : (static_cast<double>(rect.height()) / niceScale.sizeInBytes());
|
const qreal yMultiplier = (niceScale.arg == 0) ? 0 : (static_cast<qreal>(rect.height()) / niceScale.sizeInBytes());
|
||||||
|
|
||||||
for (int id = UP; id < NB_GRAPHS; ++id)
|
for (int id = UP; id < NB_GRAPHS; ++id)
|
||||||
{
|
{
|
||||||
|
@ -381,7 +381,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
// draw legend
|
// draw legend
|
||||||
QPoint legendTopLeft(rect.left() + 4, fullRect.top() + 4);
|
QPoint legendTopLeft(rect.left() + 4, fullRect.top() + 4);
|
||||||
|
|
||||||
double legendHeight = 0;
|
qreal legendHeight = 0;
|
||||||
int legendWidth = 0;
|
int legendWidth = 0;
|
||||||
for (const auto &property : asConst(m_properties))
|
for (const auto &property : asConst(m_properties))
|
||||||
{
|
{
|
||||||
|
@ -404,8 +404,8 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
if (!property.enable)
|
if (!property.enable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int nameSize = fontMetrics.horizontalAdvance(property.name);
|
const int nameSize = fontMetrics.horizontalAdvance(property.name);
|
||||||
double indent = 1.5 * (i++) * fontMetrics.height();
|
const qreal indent = 1.5 * (i++) * fontMetrics.height();
|
||||||
|
|
||||||
painter.setPen(property.pen);
|
painter.setPen(property.pen);
|
||||||
painter.drawLine(legendTopLeft + QPointF(0, indent + fontMetrics.height()),
|
painter.drawLine(legendTopLeft + QPointF(0, indent + fontMetrics.height()),
|
||||||
|
|
Loading…
Reference in a new issue