From 6a8d929876f5a8d0279d2a83248a5d7b59e0ae39 Mon Sep 17 00:00:00 2001 From: Lakshman Date: Tue, 8 Apr 2014 00:00:50 -0400 Subject: Feature to show or hide heart rate graph Adds new push button "HR" to the button bar on the dive profile to toggle display of heart rate. TODO: New icon for the heart rate button is needed. Fixes #485 Signed-off-by: Lakshman Anumolu Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 22 ++++++++++++++++++++++ qt-ui/profile/diveprofileitem.h | 5 +++++ qt-ui/profile/profilewidget2.cpp | 17 ++++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 2ffc7ec02..51d6a3f79 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -221,6 +221,7 @@ DiveHeartrateItem::DiveHeartrateItem() pen.setCosmetic(true); pen.setWidth(1); setPen(pen); + visible = true; } void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) @@ -297,6 +298,27 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->drawPolyline(polygon()); } +void DiveHeartrateItem::preferencesChanged() +{ + QSettings s; + s.beginGroup("TecDetails"); + setVisible(s.value(visibilityKey).toBool()); + if (s.value(visibilityKey).toBool()) + visible = true; + else + visible = false; +} + +void DiveHeartrateItem::setVisibilitySettingsKey(const QString &key) +{ + visibilityKey = key; +} + +bool DiveHeartrateItem::isVisible() +{ + return visible == true; +} + DiveTemperatureItem::DiveTemperatureItem() { QPen pen; diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 480776546..c7fa59841 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -100,9 +100,14 @@ public: DiveHeartrateItem(); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + virtual void preferencesChanged(); + void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey); + bool isVisible(); private: void createTextItem(int seconds, int hr); + QString visibilityKey; + bool visible; }; class DiveGasPressureItem : public AbstractProfilePolygonItem { diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 047634e15..95f8f49ee 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -193,6 +193,8 @@ void ProfileWidget2::setupItemOnScene() setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1); setupItem(temperatureItem, timeAxis, temperatureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1); setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1); + heartBeatItem->setVisibilitySettingsKey("hrgraph"); + heartBeatItem->preferencesChanged(); setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0); #define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \ @@ -400,11 +402,15 @@ void ProfileWidget2::plotDives(QList dives) temperatureAxis->setMinimum(pInfo.mintemp); temperatureAxis->setMaximum(pInfo.maxtemp); - if (pInfo.maxhr) { - heartBeatAxis->setMinimum(pInfo.minhr); - heartBeatAxis->setMaximum(pInfo.maxhr); - heartBeatAxis->updateTicks(); // this shows the ticks - heartBeatAxis->setVisible(true); + if (heartBeatItem->isVisible()) { + if (pInfo.maxhr) { + heartBeatAxis->setMinimum(pInfo.minhr); + heartBeatAxis->setMaximum(pInfo.maxhr); + heartBeatAxis->updateTicks(); // this shows the ticks + heartBeatAxis->setVisible(true); + } else { + heartBeatAxis->setVisible(false); + } } else { heartBeatAxis->setVisible(false); } @@ -656,6 +662,7 @@ void ProfileWidget2::setProfileState() temperatureAxis->setPos(itemPos.temperature.pos.on); heartBeatAxis->setPos(itemPos.heartBeat.pos.on); heartBeatAxis->setLine(itemPos.heartBeat.expanded); + heartBeatItem->setVisible(s.value("hrgraph").toBool()); meanDepth->setVisible(true); diveComputerText->setVisible(true); -- cgit v1.2.3-70-g09d2