summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-02-05 14:34:45 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-06 06:28:21 -0800
commit19585d9a135257a74f92471ee82bb56499aa0680 (patch)
tree423bdbdd0c0ee0d98a9c644649a598e867ca247c /qt-ui/profile
parentc1ed9babc732a56e978f21eeeb0be9da16197b5b (diff)
downloadsubsurface-19585d9a135257a74f92471ee82bb56499aa0680.tar.gz
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>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/profilewidget2.cpp32
-rw-r--r--qt-ui/profile/profilewidget2.h2
2 files changed, 13 insertions, 21 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 8c255c8be..de44e893b 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -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());
}
}
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index a89cef786..2b0cf0597 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -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.