From 0a24a8e466d6f26e5fdc59e5ec2f127f4be17986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 15 Mar 2019 19:43:17 +0100 Subject: [PATCH] Code cleanup --- src/GUI/cadencegraph.cpp | 8 ++++---- src/GUI/cadencegraph.h | 2 +- src/GUI/heartrategraph.cpp | 8 ++++---- src/GUI/heartrategraph.h | 2 +- src/GUI/powergraph.cpp | 8 ++++---- src/GUI/powergraph.h | 2 +- src/GUI/speedgraph.cpp | 10 +++++----- src/GUI/speedgraph.h | 4 ++-- src/GUI/temperaturegraph.cpp | 8 ++++---- src/GUI/temperaturegraph.h | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/GUI/cadencegraph.cpp b/src/GUI/cadencegraph.cpp index d64e07d1..fe589fa0 100644 --- a/src/GUI/cadencegraph.cpp +++ b/src/GUI/cadencegraph.cpp @@ -63,11 +63,11 @@ QList CadenceGraph::loadData(const Data &data) qreal CadenceGraph::avg() const { qreal sum = 0, w = 0; - QList::const_iterator it; - for (it = _avg.begin(); it != _avg.end(); it++) { - sum += it->y() * it->x(); - w += it->x(); + for (int i = 0; i < _avg.size(); i++) { + const QPointF &p = _avg.at(i); + sum += p.y() * p.x(); + w += p.x(); } return (sum / w); diff --git a/src/GUI/cadencegraph.h b/src/GUI/cadencegraph.h index a50aa984..4ffa7649 100644 --- a/src/GUI/cadencegraph.h +++ b/src/GUI/cadencegraph.h @@ -21,7 +21,7 @@ private: qreal max() const {return bounds().bottom();} void setInfo(); - QList _avg; + QVector _avg; bool _showTracks; }; diff --git a/src/GUI/heartrategraph.cpp b/src/GUI/heartrategraph.cpp index da8ec847..c7e431c9 100644 --- a/src/GUI/heartrategraph.cpp +++ b/src/GUI/heartrategraph.cpp @@ -63,11 +63,11 @@ QList HeartRateGraph::loadData(const Data &data) qreal HeartRateGraph::avg() const { qreal sum = 0, w = 0; - QList::const_iterator it; - for (it = _avg.begin(); it != _avg.end(); it++) { - sum += it->y() * it->x(); - w += it->x(); + for (int i = 0; i < _avg.size(); i++) { + const QPointF &p = _avg.at(i); + sum += p.y() * p.x(); + w += p.x(); } return (sum / w); diff --git a/src/GUI/heartrategraph.h b/src/GUI/heartrategraph.h index 1c6dce9a..cf633c44 100644 --- a/src/GUI/heartrategraph.h +++ b/src/GUI/heartrategraph.h @@ -20,7 +20,7 @@ private: qreal max() const {return bounds().bottom();} void setInfo(); - QList _avg; + QVector _avg; bool _showTracks; }; diff --git a/src/GUI/powergraph.cpp b/src/GUI/powergraph.cpp index 9af559e0..d0926a4c 100644 --- a/src/GUI/powergraph.cpp +++ b/src/GUI/powergraph.cpp @@ -63,11 +63,11 @@ QList PowerGraph::loadData(const Data &data) qreal PowerGraph::avg() const { qreal sum = 0, w = 0; - QList::const_iterator it; - for (it = _avg.begin(); it != _avg.end(); it++) { - sum += it->y() * it->x(); - w += it->x(); + for (int i = 0; i < _avg.size(); i++) { + const QPointF &p = _avg.at(i); + sum += p.y() * p.x(); + w += p.x(); } return (sum / w); diff --git a/src/GUI/powergraph.h b/src/GUI/powergraph.h index ddd0a770..03165fec 100644 --- a/src/GUI/powergraph.h +++ b/src/GUI/powergraph.h @@ -20,7 +20,7 @@ private: qreal max() const {return bounds().bottom();} void setInfo(); - QList _avg; + QVector _avg; bool _showTracks; }; diff --git a/src/GUI/speedgraph.cpp b/src/GUI/speedgraph.cpp index db4ea222..48d10fa5 100644 --- a/src/GUI/speedgraph.cpp +++ b/src/GUI/speedgraph.cpp @@ -74,12 +74,12 @@ QList SpeedGraph::loadData(const Data &data) qreal SpeedGraph::avg() const { qreal sum = 0, w = 0; - QList::const_iterator it; - const QList &list = (_timeType == Moving) ? _mavg : _avg; + const QVector &vector = (_timeType == Moving) ? _mavg : _avg; - for (it = list.begin(); it != list.end(); it++) { - sum += it->y() * it->x(); - w += it->x(); + for (int i = 0; i < vector.size(); i++) { + const QPointF &p = vector.at(i); + sum += p.y() * p.x(); + w += p.x(); } return (sum / w); diff --git a/src/GUI/speedgraph.h b/src/GUI/speedgraph.h index e7e657fc..420539f4 100644 --- a/src/GUI/speedgraph.h +++ b/src/GUI/speedgraph.h @@ -24,8 +24,8 @@ private: void setYUnits(); void setInfo(); - QList _avg; - QList _mavg; + QVector _avg; + QVector _mavg; Units _units; TimeType _timeType; diff --git a/src/GUI/temperaturegraph.cpp b/src/GUI/temperaturegraph.cpp index eaa624e7..0f7a4573 100644 --- a/src/GUI/temperaturegraph.cpp +++ b/src/GUI/temperaturegraph.cpp @@ -66,11 +66,11 @@ QList TemperatureGraph::loadData(const Data &data) qreal TemperatureGraph::avg() const { qreal sum = 0, w = 0; - QList::const_iterator it; - for (it = _avg.begin(); it != _avg.end(); it++) { - sum += it->y() * it->x(); - w += it->x(); + for (int i = 0; i < _avg.size(); i++) { + const QPointF &p = _avg.at(i); + sum += p.y() * p.x(); + w += p.x(); } return (sum / w); diff --git a/src/GUI/temperaturegraph.h b/src/GUI/temperaturegraph.h index a30e513d..1b35f4fb 100644 --- a/src/GUI/temperaturegraph.h +++ b/src/GUI/temperaturegraph.h @@ -23,7 +23,7 @@ private: void setYUnits(Units units); void setInfo(); - QList _avg; + QVector _avg; bool _showTracks; };