1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Fixed broken graph color change when secondary graphs present

This commit is contained in:
Martin Tůma 2020-03-28 23:28:39 +01:00
parent d94938261a
commit c9244c0684
2 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,4 @@
#include <QSet>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QEvent> #include <QEvent>
#include <QMouseEvent> #include <QMouseEvent>
@ -494,8 +495,23 @@ void GraphView::setPalette(const Palette &palette)
_palette = palette; _palette = palette;
_palette.reset(); _palette.reset();
for (int i = 0; i < _graphs.count(); i++) QSet<GraphItem*> secondary;
_graphs.at(i)->setColor(_palette.nextColor()); for (int i = 0; i < _graphs.count(); i++) {
GraphItem *g = _graphs[i];
if (g->secondaryGraph())
secondary.insert(g->secondaryGraph());
}
for (int i = 0; i < _graphs.count(); i++) {
GraphItem *g = _graphs[i];
if (secondary.contains(g))
continue;
QColor color(_palette.nextColor());
g->setColor(color);
if (g->secondaryGraph())
g->secondaryGraph()->setColor(color);
}
} }
void GraphView::setGraphWidth(int width) void GraphView::setGraphWidth(int width)

View File

@ -3,7 +3,6 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QList> #include <QList>
#include <QSet>
#include "data/graph.h" #include "data/graph.h"
#include "palette.h" #include "palette.h"
#include "units.h" #include "units.h"