mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-30 22:51:16 +01:00
Fixed content margin computation.
Code cleanup.
This commit is contained in:
parent
77823fba14
commit
bd20d40ba7
@ -144,7 +144,7 @@ void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
|||||||
QList<PathItem *> PathView::loadData(const Data &data)
|
QList<PathItem *> PathView::loadData(const Data &data)
|
||||||
{
|
{
|
||||||
QList<PathItem *> paths;
|
QList<PathItem *> paths;
|
||||||
qreal scale = _map->zoom();
|
qreal zoom = _map->zoom();
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
paths.append(addTrack(*(data.tracks().at(i))));
|
paths.append(addTrack(*(data.tracks().at(i))));
|
||||||
@ -155,7 +155,7 @@ QList<PathItem *> PathView::loadData(const Data &data)
|
|||||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||||
return paths;
|
return paths;
|
||||||
|
|
||||||
if (mapScale() != scale)
|
if (mapZoom() != zoom)
|
||||||
rescale();
|
rescale();
|
||||||
else
|
else
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
@ -179,11 +179,11 @@ void PathView::updateWaypointsBoundingRect(const Coordinates &wp)
|
|||||||
_wr.unite(wp);
|
_wr.unite(wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PathView::mapScale() const
|
qreal PathView::mapZoom() const
|
||||||
{
|
{
|
||||||
RectC br = _tr | _rr | _wr;
|
RectC br = _tr | _rr | _wr;
|
||||||
|
|
||||||
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
|
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN), br);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF PathView::contentCenter() const
|
QPointF PathView::contentCenter() const
|
||||||
@ -647,8 +647,8 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
void PathView::resizeEvent(QResizeEvent *event)
|
void PathView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
qreal scale = _map->zoom();
|
qreal zoom = _map->zoom();
|
||||||
if (mapScale() != scale)
|
if (mapZoom() != zoom)
|
||||||
rescale();
|
rescale();
|
||||||
|
|
||||||
QPointF center = contentCenter();
|
QPointF center = contentCenter();
|
||||||
|
@ -75,7 +75,7 @@ private:
|
|||||||
void loadPOI();
|
void loadPOI();
|
||||||
void clearPOI();
|
void clearPOI();
|
||||||
|
|
||||||
qreal mapScale() const;
|
qreal mapZoom() const;
|
||||||
QPointF contentCenter() const;
|
QPointF contentCenter() const;
|
||||||
void rescale();
|
void rescale();
|
||||||
void zoom(int zoom, const QPoint &pos, const Coordinates &c);
|
void zoom(int zoom, const QPoint &pos, const Coordinates &c);
|
||||||
|
Loading…
Reference in New Issue
Block a user