From cde9bc0de9f4b7684336ef7209f47a47c8b751ba Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 22 Jan 2014 19:22:07 -0200 Subject: [PATCH] Make the tissues be preferences-aware. This patch adds a new class DiveCalculatedTissue that's preferences aware. It knows when to show or hide itself. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 12 ++++++++++++ qt-ui/profile/diveprofileitem.h | 7 +++++++ qt-ui/profile/profilewidget2.cpp | 2 +- qt-ui/profile/profilewidget2.h | 3 ++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index e740640e2..0768f38f6 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -388,6 +388,18 @@ void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsI QGraphicsPolygonItem::paint(painter, option, widget); } +DiveCalculatedTissue::DiveCalculatedTissue() +{ + preferencesChanged(); +} + +void DiveCalculatedTissue::preferencesChanged() +{ + QSettings s; + s.beginGroup("TecDetails"); + setVisible(s.value("calcalltissues").toBool()); +} + void DiveReportedCeiling::modelDataChanged() { if (!hAxis || !vAxis || !dataModel || hDataColumn == -1 || vDataColumn == -1) diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 272ee0821..c6c5b19e3 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -103,6 +103,13 @@ public: virtual void preferencesChanged(); }; +class DiveCalculatedTissue : public DiveCalculatedCeiling { + Q_OBJECT +public: + DiveCalculatedTissue(); + void preferencesChanged(); +}; + class MeanDepthLine : public DiveLineItem { Q_OBJECT public: diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index fd579a5c4..3451ddf40 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -388,7 +388,7 @@ void ProfileWidget2::plotDives(QList dives) qDeleteAll(allTissues); allTissues.clear(); for(int i = 0; i < 16; i++){ - DiveCalculatedCeiling *tissueItem = new DiveCalculatedCeiling(); + DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(); tissueItem->setHorizontalAxis(timeAxis); tissueItem->setVerticalAxis(profileYAxis); tissueItem->setModel(dataModel); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 780a9b2a7..c20a3f333 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -36,6 +36,7 @@ struct plot_info; struct DiveGasPressureItem; struct DiveCalculatedCeiling; struct DiveReportedCeiling; +struct DiveCalculatedTissue; class ProfileWidget2 : public QGraphicsView { Q_OBJECT @@ -88,7 +89,7 @@ private: QList eventItems; DiveTextItem *diveComputerText; DiveCalculatedCeiling *diveCeiling; - QList allTissues; + QList allTissues; DiveReportedCeiling *reportedCeiling; };