1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-16 03:44:24 +02:00

Graph loading performance improvement

+ code/API cleanup
This commit is contained in:
2019-08-25 10:54:25 +02:00
parent a70c6f0f24
commit 609ac0c57a
33 changed files with 346 additions and 219 deletions

View File

@ -14,6 +14,11 @@ PowerGraph::PowerGraph(QWidget *parent) : GraphTab(parent)
setSliderPrecision(1);
}
PowerGraph::~PowerGraph()
{
qDeleteAll(_tracks);
}
void PowerGraph::setInfo()
{
if (_showTracks) {
@ -36,23 +41,27 @@ QList<GraphItem*> PowerGraph::loadData(const Data &data)
const Graph &graph = track.power();
if (!graph.isValid()) {
skipColor();
_palette.nextColor();
graphs.append(0);
} else {
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
GraphView::addGraph(gi);
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType, _width,
_palette.nextColor());
_tracks.append(gi);
if (_showTracks)
addGraph(gi);
_avg.append(QPointF(track.distance(), gi->avg()));
graphs.append(gi);
}
}
for (int i = 0; i < data.routes().count(); i++) {
skipColor();
_palette.nextColor();
graphs.append(0);
}
for (int i = 0; i < data.areas().count(); i++)
skipColor();
_palette.nextColor();
setInfo();
redraw();
@ -75,6 +84,9 @@ qreal PowerGraph::avg() const
void PowerGraph::clear()
{
qDeleteAll(_tracks);
_tracks.clear();
_avg.clear();
GraphTab::clear();
@ -84,7 +96,13 @@ void PowerGraph::showTracks(bool show)
{
_showTracks = show;
showGraph(show);
for (int i = 0; i < _tracks.size(); i++) {
if (show)
addGraph(_tracks.at(i));
else
removeGraph(_tracks.at(i));
}
setInfo();
redraw();