mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 13:50:12 +08:00
minor refactors
This commit is contained in:
parent
52ca4dbfbe
commit
160c5f2b08
@ -70,7 +70,7 @@ SpeedWidget::SpeedWidget(QWidget *parent) : QGraphicsView(parent)
|
|||||||
UpdateSpeedPlotSettings();
|
UpdateSpeedPlotSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedWidget::AddPointData(QMap<SpeedWidget::GraphType, long> data)
|
void SpeedWidget::AddPointData(const QMap<SpeedWidget::GraphType, long>& data)
|
||||||
{
|
{
|
||||||
SpeedWidget::PointData point;
|
SpeedWidget::PointData point;
|
||||||
point.x = QDateTime::currentMSecsSinceEpoch() / 1000;
|
point.x = QDateTime::currentMSecsSinceEpoch() / 1000;
|
||||||
@ -302,7 +302,7 @@ void SpeedWidget::paintEvent(QPaintEvent *)
|
|||||||
double legendHeight = 0;
|
double legendHeight = 0;
|
||||||
int legendWidth = 0;
|
int legendWidth = 0;
|
||||||
|
|
||||||
for (const auto &property : qAsConst(m_properties))
|
for (const auto &property : std::as_const(m_properties))
|
||||||
{
|
{
|
||||||
if (fontMetrics.horizontalAdvance(property.name) > legendWidth)
|
if (fontMetrics.horizontalAdvance(property.name) > legendWidth)
|
||||||
legendWidth = fontMetrics.horizontalAdvance(property.name);
|
legendWidth = fontMetrics.horizontalAdvance(property.name);
|
||||||
@ -318,7 +318,7 @@ void SpeedWidget::paintEvent(QPaintEvent *)
|
|||||||
painter.fillRect(legendBackgroundRect, legendBackgroundColor);
|
painter.fillRect(legendBackgroundRect, legendBackgroundColor);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &property : qAsConst(m_properties))
|
for (const auto &property : std::as_const(m_properties))
|
||||||
{
|
{
|
||||||
int nameSize = fontMetrics.horizontalAdvance(property.name);
|
int nameSize = fontMetrics.horizontalAdvance(property.name);
|
||||||
double indent = 1.5 * (i++) * fontMetrics.height();
|
double indent = 1.5 * (i++) * fontMetrics.height();
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
class SpeedWidget : public QGraphicsView
|
class SpeedWidget : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -53,14 +54,14 @@ class SpeedWidget : public QGraphicsView
|
|||||||
quint64 y[NB_GRAPHS];
|
quint64 y[NB_GRAPHS];
|
||||||
PointData()
|
PointData()
|
||||||
{
|
{
|
||||||
for (auto i = 0; i < NB_GRAPHS; i++)
|
for (unsigned long long & i : y)
|
||||||
y[i] = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit SpeedWidget(QWidget *parent = nullptr);
|
explicit SpeedWidget(QWidget *parent = nullptr);
|
||||||
void UpdateSpeedPlotSettings();
|
void UpdateSpeedPlotSettings();
|
||||||
void AddPointData(QMap<SpeedWidget::GraphType, long> data);
|
void AddPointData(const QMap<SpeedWidget::GraphType, long>& data);
|
||||||
void Clear();
|
void Clear();
|
||||||
void replot();
|
void replot();
|
||||||
|
|
||||||
@ -70,8 +71,8 @@ class SpeedWidget : public QGraphicsView
|
|||||||
private:
|
private:
|
||||||
struct GraphProperties
|
struct GraphProperties
|
||||||
{
|
{
|
||||||
GraphProperties(){};
|
GraphProperties()= default;
|
||||||
GraphProperties(const QString &name, const QPen &pen) : name(name), pen(pen){};
|
GraphProperties(QString name, QPen pen) : name(std::move(name)), pen(std::move(pen)){};
|
||||||
QString name;
|
QString name;
|
||||||
QPen pen;
|
QPen pen;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user