diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-14 16:22:53 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 10:12:30 +0700 |
commit | ca979044d0477e07ba776a74d8cfcc1fe9ebfa40 (patch) | |
tree | 6050a1424fc0a16f2a95518a8bc9914d9210b09f /qt-ui | |
parent | 49f4052c67d31d4870a86f53a52381a4bbf609fd (diff) | |
download | subsurface-ca979044d0477e07ba776a74d8cfcc1fe9ebfa40.tar.gz |
Remove only the Uneeded Ticks / Labels when a update is requested.
This patch makes the updateTicks method not remove / readd everything
when it's triggered, but to only remove the ticks / labels that
are no longer needed on the current display.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divecartesianaxis.cpp | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 78ef38e68..b31003f0b 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -44,48 +44,18 @@ void DiveCartesianAxis::setOrientation(Qt::Orientation o) void DiveCartesianAxis::updateTicks() { - qDeleteAll(ticks); - ticks.clear(); - qDeleteAll(labels); - labels.clear(); - QLineF m = line(); - DiveLineItem *item = NULL; - DiveTextItem *label = NULL; - + QGraphicsView *view = scene()->views().first(); double steps = (max - min) / interval; - qreal pos; double currValue = min; - if (orientation == Qt::Horizontal) { - double stepSize = (m.x2() - m.x1()) / steps; - for (pos = m.x1(); pos <= m.x2(); pos += stepSize, currValue += interval) { - item = new DiveLineItem(this); - item->setLine(pos, m.y1(), pos, m.y1() + tickSize); - item->setPen(pen()); - ticks.push_back(item); - - label = new DiveTextItem(this); - label->setText(QString::number(currValue)); - label->setBrush(QBrush(textColor)); - label->setFlag(ItemIgnoresTransformations); - label->setPos(pos - label->boundingRect().width()/2, m.y1() + tickSize + 5); - labels.push_back(label); - } - } else { - double stepSize = (m.y2() - m.y1()) / steps; - for (pos = m.y1(); pos <= m.y2(); pos += stepSize, currValue += interval) { - item = new DiveLineItem(this); - item->setLine(m.x1(), pos, m.x1() - tickSize, pos); - item->setPen(pen()); - ticks.push_back(item); - - label = new DiveTextItem(this); - label->setText(get_depth_string(currValue, false, false)); - label->setBrush(QBrush(textColor)); - label->setFlag(ItemIgnoresTransformations); - label->setPos(m.x2() - 80, pos); - labels.push_back(label); + // Remove the uneeded Ticks / Texts. + if (ticks.size() > steps){ + while (ticks.size() > steps){ + DiveLineItem *removedLine = ticks.takeLast(); + removedLine->animatedHide(); + DiveTextItem *removedText = labels.takeLast(); + removedText->animatedHide(); } } } |