diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-14 16:28:07 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-16 10:12:30 +0700 |
commit | 215e22481af5b19331882af27a3243eca7c2cf38 (patch) | |
tree | 05d4fe9707b3c029e72d2ff45ab652a897312486 /qt-ui | |
parent | 36475c1ee5e082a40cbb6562db756e57ca7648ad (diff) | |
download | subsurface-215e22481af5b19331882af27a3243eca7c2cf38.tar.gz |
Added the remaining of the ticks to their correct position.
When we prepare the axis to show something on the Profile
we need to add the remaining ticks to show on screen,
Since this method tries to animately move / remove things
before calling this.
This has no animations yet - will have in the future.
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 | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index dc99d1f88..358b85ef4 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -78,6 +78,36 @@ void DiveCartesianAxis::updateTicks() } } + // Add's the rest of the needed Ticks / Text. + for(int i = ticks.size(); i < steps; i++, currValue += interval){ + qreal childPos = begin + i * stepSize; + DiveLineItem *item = new DiveLineItem(this); + item->setPen(pen()); + ticks.push_back(item); + + DiveTextItem *label = new DiveTextItem(this); + label->setText(textForValue(currValue)); + label->setBrush(QBrush(textColor)); + + labels.push_back(label); + if(orientation == Qt::Horizontal){ + item->setLine(0, 0, 0, tickSize); + item->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene + item->animateMoveTo(childPos, m.y1() + tickSize); // anim it to scene. + label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); + label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene); + label->animateMoveTo(childPos, m.y1() + tickSize); + } + else{ + item->setLine(0, 0, tickSize, 0); + item->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10); + item->animateMoveTo(m.x1() - tickSize, childPos); + label->setAlignment(Qt::AlignVCenter| Qt::AlignRight); + label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10); + label->animateMoveTo(m.x1() - tickSize, childPos); + } + } + } QString DiveCartesianAxis::textForValue(double value) |