1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-27 08:54:23 +02:00

Propper path tick tooltip

+ code cleanup
This commit is contained in:
2019-05-28 07:24:39 +02:00
parent a16354a6ba
commit 48674bb50b
3 changed files with 21 additions and 10 deletions

View File

@ -325,20 +325,15 @@ void PathItem::updateTicks()
return;
int ts = tickSize();
qreal f = xInM();
int tc = (int)_path.last().last().distance() / (ts * f);
QFontMetrics fm(PathTickItem::font());
QRect tr = fm.boundingRect(QRect(), Qt::AlignCenter,
QString::number(qMax(ts * (tc - 1), 10)))
.adjusted(-2, 0, 2, 0);
int tc = _path.last().last().distance() / (ts * xInM());
QRect tr = PathTickItem::tickRect(ts * (tc - 1));
_ticks.resize(tc);
for (int i = 0; i < tc; i++) {
QPoint pos(position((i + 1) * ts * xInM()).toPoint());
_ticks[i] = new PathTickItem(tr, (i + 1) * ts, this);
_ticks[i]->setPos(QPointF(pos.x() - 0.5, pos.y() - 0.5));
_ticks[i]->setPos(position((i + 1) * ts * xInM()));
_ticks[i]->setColor(_pen.color());
_ticks[i]->setToolTip(toolTip());
}
}