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

Fixed track view resizing issues

This commit is contained in:
Martin Tůma 2015-12-20 09:33:40 +01:00
parent 6659e2ffa7
commit d8068ad994
2 changed files with 24 additions and 0 deletions

View File

@ -339,3 +339,26 @@ void Track::drawBackground(QPainter *painter, const QRectF &rect)
painter->drawPixmap(tp, t.pixmap());
}
}
void Track::resizeEvent(QResizeEvent *e)
{
if (_tracks.isEmpty())
return;
QRectF br = trackBoundingRect();
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
if (ba.width() < e->size().width()) {
qreal diff = e->size().width() - ba.width();
ba.adjust(-diff/2, 0, diff/2, 0);
}
if (ba.height() < e->size().height()) {
qreal diff = e->size().height() - ba.height();
ba.adjust(0, -diff/2, 0, diff/2);
}
_scene->setSceneRect(ba);
centerOn(br.center());
resetCachedContent();
}

View File

@ -51,6 +51,7 @@ private:
void wheelEvent(QWheelEvent *event);
void drawBackground(QPainter *painter, const QRectF &rect);
void resizeEvent(QResizeEvent *e);
QGraphicsScene *_scene;
QList<QVector<QPointF> > _tracks;