Add the tooltip item to the new profile.

The functionality is not there yet - just the item hovering
the screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-02-05 14:34:45 -02:00 committed by Dirk Hohndel
parent c1ed9babc7
commit 19585d9a13
2 changed files with 13 additions and 21 deletions

View file

@ -8,6 +8,7 @@
#include "profile.h"
#include "diveeventitem.h"
#include "divetextitem.h"
#include "divetooltipitem.h"
#include <QStateMachine>
#include <QSignalTransition>
#include <QPropertyAnimation>
@ -28,6 +29,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
zoomLevel(0),
stateMachine(new QStateMachine(this)),
background (new DivePixmapItem()),
toolTipItem(new ToolTipItem()),
profileYAxis(new DepthAxis()),
gasYAxis(new PartialGasPressureAxis()),
temperatureAxis(new TemperatureAxis()),
@ -53,6 +55,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
setMouseTracking(true);
scene()->addItem(toolTipItem);
// Creating the needed items.
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
@ -481,14 +486,11 @@ void ProfileWidget2::fixBackgroundPos()
void ProfileWidget2::wheelEvent(QWheelEvent* event)
{
// if (!toolTip)
// return;
// doesn't seem to work for Qt 4.8.1
// setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
// QPoint toolTipPos = mapFromScene(toolTip->pos());
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
double scaleFactor = 1.15;
if (event->delta() > 0 && zoomLevel < 20) {
@ -501,13 +503,7 @@ void ProfileWidget2::wheelEvent(QWheelEvent* event)
}
scrollViewTo(event->pos());
// toolTip->setPos(mapToScene(toolTipPos));
// toolBarProxy->setPos(mapToScene(TOOLBAR_POS));
// if (zoomLevel != 0) {
// toolBarProxy->hide();
// } else {
// toolBarProxy->show();
// }
toolTipItem->setPos(mapToScene(toolTipPos));
}
void ProfileWidget2::scrollViewTo(const QPoint& pos)
@ -526,18 +522,12 @@ void ProfileWidget2::scrollViewTo(const QPoint& pos)
void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)
{
// if (!toolTip)
// return;
//
// toolTip->refresh(&gc, mapToScene(event->pos()));
// QPoint toolTipPos = mapFromScene(toolTip->pos());
//toolTipItem->refresh(&gc, mapToScene(event->pos()));
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
if (zoomLevel == 0) {
QGraphicsView::mouseMoveEvent(event);
} else {/*
toolTip->setPos(mapToScene(toolTipPos));
toolBarProxy->setPos(mapToScene(TOOLBAR_POS));*/
} else {
toolTipItem->setPos(mapToScene(toolTipPos));
scrollViewTo(event->pos());
}
}

View file

@ -16,6 +16,7 @@
#include "graphicsview-common.h"
#include "divelineitem.h"
class ToolTipItem;
class MeanDepthLine;
class DiveReportedCeiling;
class DiveTextItem;
@ -75,6 +76,7 @@ private:
QStateMachine *stateMachine;
int zoomLevel;
DivePixmapItem *background ;
ToolTipItem *toolTipItem;
// All those here should probably be merged into one structure,
// So it's esyer to replicate for more dives later.
// In the meantime, keep it here.