To address the position of the temperature graph on the dive profile window how about allowing the user to move the graph out of the way?
-- John Van Ostrand At large on sabbatical
From 34050397276fe9d6a8885ee4f8a379cb458fd282 Mon Sep 17 00:00:00 2001 From: John Van Ostrand <j...@vanostrand.com> Date: Fri, 21 Nov 2014 10:34:18 -0500 Subject: [PATCH] Make temperature line user moveable. One way to address bu 717, where temperature line obscures dive profile. Signed-off-by: John Van Ostrand <j...@vanostrand.com> --- qt-ui/profile/diveprofileitem.cpp | 31 +++++++++++++++++++++++++++++++ qt-ui/profile/diveprofileitem.h | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 038987f..1ce5a6d 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -20,6 +20,7 @@ #include <QApplication> #include <QGraphicsItem> #include <QSettings> +#include <QGraphicsSceneMouseEvent> AbstractProfilePolygonItem::AbstractProfilePolygonItem() : QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1) { @@ -495,6 +496,7 @@ DiveTemperatureItem::DiveTemperatureItem() pen.setCosmetic(true); pen.setWidth(2); setPen(pen); + setCursor(Qt::OpenHandCursor); } void DiveTemperatureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) @@ -568,6 +570,35 @@ void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte painter->restore(); } +void DiveTemperatureItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) +{ + if (e->button() != Qt::LeftButton) + return; + + QPen p = pen(); + p.setStyle(Qt::SolidLine); + setPen(p); + setCursor(Qt::OpenHandCursor); +} + +void DiveTemperatureItem::mousePressEvent(QGraphicsSceneMouseEvent *e) +{ + if (e->button() != Qt::LeftButton) + return; + + QPen p = pen(); + p.setStyle(Qt::DashLine); + setPen(p); + setCursor(Qt::ClosedHandCursor); + moveStartY = e->scenePos().y() - y(); +} + +void DiveTemperatureItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) +{ + qreal ypos = e->scenePos().y(); + setY(ypos - moveStartY); +} + void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { // We don't have enougth data to calculate things, quit. diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 1bdf4b3..0ca83de 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -93,6 +93,11 @@ public: private: void createTextItem(int seconds, int mkelvin); +protected: + qreal moveStartY; + void mousePressEvent(QGraphicsSceneMouseEvent *e); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *e); + void mouseMoveEvent(QGraphicsSceneMouseEvent *e); }; class DiveHeartrateItem : public AbstractProfilePolygonItem { -- 1.8.3.1
_______________________________________________ subsurface mailing list subsurface@subsurface-divelog.org http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface