mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 20:13:24 +00:00
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:
parent
c1ed9babc7
commit
19585d9a13
2 changed files with 13 additions and 21 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "diveeventitem.h"
|
#include "diveeventitem.h"
|
||||||
#include "divetextitem.h"
|
#include "divetextitem.h"
|
||||||
|
#include "divetooltipitem.h"
|
||||||
#include <QStateMachine>
|
#include <QStateMachine>
|
||||||
#include <QSignalTransition>
|
#include <QSignalTransition>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
@ -28,6 +29,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
||||||
zoomLevel(0),
|
zoomLevel(0),
|
||||||
stateMachine(new QStateMachine(this)),
|
stateMachine(new QStateMachine(this)),
|
||||||
background (new DivePixmapItem()),
|
background (new DivePixmapItem()),
|
||||||
|
toolTipItem(new ToolTipItem()),
|
||||||
profileYAxis(new DepthAxis()),
|
profileYAxis(new DepthAxis()),
|
||||||
gasYAxis(new PartialGasPressureAxis()),
|
gasYAxis(new PartialGasPressureAxis()),
|
||||||
temperatureAxis(new TemperatureAxis()),
|
temperatureAxis(new TemperatureAxis()),
|
||||||
|
@ -53,6 +55,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
||||||
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
|
||||||
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
scene()->addItem(toolTipItem);
|
||||||
|
|
||||||
// Creating the needed items.
|
// Creating the needed items.
|
||||||
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
|
// ORDER: {BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
|
||||||
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
|
||||||
|
@ -481,14 +486,11 @@ void ProfileWidget2::fixBackgroundPos()
|
||||||
|
|
||||||
void ProfileWidget2::wheelEvent(QWheelEvent* event)
|
void ProfileWidget2::wheelEvent(QWheelEvent* event)
|
||||||
{
|
{
|
||||||
// if (!toolTip)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// doesn't seem to work for Qt 4.8.1
|
// doesn't seem to work for Qt 4.8.1
|
||||||
// setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
// setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
|
||||||
// Scale the view / do the zoom
|
// Scale the view / do the zoom
|
||||||
// QPoint toolTipPos = mapFromScene(toolTip->pos());
|
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
|
||||||
|
|
||||||
double scaleFactor = 1.15;
|
double scaleFactor = 1.15;
|
||||||
if (event->delta() > 0 && zoomLevel < 20) {
|
if (event->delta() > 0 && zoomLevel < 20) {
|
||||||
|
@ -501,13 +503,7 @@ void ProfileWidget2::wheelEvent(QWheelEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollViewTo(event->pos());
|
scrollViewTo(event->pos());
|
||||||
// toolTip->setPos(mapToScene(toolTipPos));
|
toolTipItem->setPos(mapToScene(toolTipPos));
|
||||||
// toolBarProxy->setPos(mapToScene(TOOLBAR_POS));
|
|
||||||
// if (zoomLevel != 0) {
|
|
||||||
// toolBarProxy->hide();
|
|
||||||
// } else {
|
|
||||||
// toolBarProxy->show();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileWidget2::scrollViewTo(const QPoint& pos)
|
void ProfileWidget2::scrollViewTo(const QPoint& pos)
|
||||||
|
@ -526,18 +522,12 @@ void ProfileWidget2::scrollViewTo(const QPoint& pos)
|
||||||
|
|
||||||
void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)
|
void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
// if (!toolTip)
|
//toolTipItem->refresh(&gc, mapToScene(event->pos()));
|
||||||
// return;
|
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
|
||||||
//
|
|
||||||
// toolTip->refresh(&gc, mapToScene(event->pos()));
|
|
||||||
// QPoint toolTipPos = mapFromScene(toolTip->pos());
|
|
||||||
|
|
||||||
|
|
||||||
if (zoomLevel == 0) {
|
if (zoomLevel == 0) {
|
||||||
QGraphicsView::mouseMoveEvent(event);
|
QGraphicsView::mouseMoveEvent(event);
|
||||||
} else {/*
|
} else {
|
||||||
toolTip->setPos(mapToScene(toolTipPos));
|
toolTipItem->setPos(mapToScene(toolTipPos));
|
||||||
toolBarProxy->setPos(mapToScene(TOOLBAR_POS));*/
|
|
||||||
scrollViewTo(event->pos());
|
scrollViewTo(event->pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "graphicsview-common.h"
|
#include "graphicsview-common.h"
|
||||||
#include "divelineitem.h"
|
#include "divelineitem.h"
|
||||||
|
|
||||||
|
class ToolTipItem;
|
||||||
class MeanDepthLine;
|
class MeanDepthLine;
|
||||||
class DiveReportedCeiling;
|
class DiveReportedCeiling;
|
||||||
class DiveTextItem;
|
class DiveTextItem;
|
||||||
|
@ -75,6 +76,7 @@ private:
|
||||||
QStateMachine *stateMachine;
|
QStateMachine *stateMachine;
|
||||||
int zoomLevel;
|
int zoomLevel;
|
||||||
DivePixmapItem *background ;
|
DivePixmapItem *background ;
|
||||||
|
ToolTipItem *toolTipItem;
|
||||||
// All those here should probably be merged into one structure,
|
// All those here should probably be merged into one structure,
|
||||||
// So it's esyer to replicate for more dives later.
|
// So it's esyer to replicate for more dives later.
|
||||||
// In the meantime, keep it here.
|
// In the meantime, keep it here.
|
||||||
|
|
Loading…
Add table
Reference in a new issue