Fix updateTicks

This is the correct way to add the ticks (and gets rid of two warnings).

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-06-23 13:21:01 -07:00 committed by Dirk Hohndel
parent 106775b196
commit a0e5244ffe

View file

@ -300,19 +300,20 @@ void Ruler::setOrientation(Qt::Orientation o)
void Ruler::updateTicks() void Ruler::updateTicks()
{ {
qDeleteAll(ticks); qDeleteAll(ticks);
ticks.clear();
QLineF m = line(); QLineF m = line();
if (orientation == Qt::Horizontal) { if (orientation == Qt::Horizontal) {
double steps = (max - min) / interval; double steps = (max - min) / interval;
double stepSize = (m.x2() - m.x1()) / steps; double stepSize = (m.x2() - m.x1()) / steps;
for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) { for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) {
QGraphicsLineItem *l = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + 1, this); ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + 1, this));
} }
} else { } else {
double steps = (max - min) / interval; double steps = (max - min) / interval;
double stepSize = (m.y2() - m.y1()) / steps; double stepSize = (m.y2() - m.y1()) / steps;
for (qreal pos = m.y1(); pos < m.y2(); pos += stepSize) { for (qreal pos = m.y1(); pos < m.y2(); pos += stepSize) {
QGraphicsLineItem *l = new QGraphicsLineItem(m.x1(), pos, m.x1() - 1, pos, this); ticks.push_back(new QGraphicsLineItem(m.x1(), pos, m.x1() - 1, pos, this));
} }
} }
} }