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