1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Improve the graph clearing logic

This commit is contained in:
Martin Tůma 2024-09-20 09:34:54 +02:00
parent 672fca9dd5
commit c68a2a1ac4

View File

@ -264,8 +264,7 @@ QRectF GraphView::bounds() const
void GraphView::redraw() void GraphView::redraw()
{ {
if (!_graphs.isEmpty()) redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
} }
void GraphView::redraw(const QSizeF &size) void GraphView::redraw(const QSizeF &size)
@ -275,7 +274,6 @@ void GraphView::redraw(const QSizeF &size)
RangeF rx, ry; RangeF rx, ry;
qreal sx, sy; qreal sx, sy;
if (_bounds.isNull()) { if (_bounds.isNull()) {
removeItem(_xAxis); removeItem(_xAxis);
removeItem(_yAxis); removeItem(_yAxis);
@ -284,7 +282,10 @@ void GraphView::redraw(const QSizeF &size)
removeItem(_slider); removeItem(_slider);
removeItem(_info); removeItem(_info);
removeItem(_grid); removeItem(_grid);
addItem(_message); if (_graphs.isEmpty())
removeItem(_message);
else
addItem(_message);
_scene->setSceneRect(_scene->itemsBoundingRect()); _scene->setSceneRect(_scene->itemsBoundingRect());
return; return;
} }
@ -357,8 +358,7 @@ void GraphView::redraw(const QSizeF &size)
void GraphView::resizeEvent(QResizeEvent *e) void GraphView::resizeEvent(QResizeEvent *e)
{ {
if (!_graphs.isEmpty()) redraw(e->size() - QSizeF(MARGIN, MARGIN));
redraw(e->size() - QSizeF(MARGIN, MARGIN));
QGraphicsView::resizeEvent(e); QGraphicsView::resizeEvent(e);
} }