diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2016-01-25 16:49:51 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-25 13:04:16 -0800 |
commit | 2d9613956618105030611f7c785d7dbdd5c5c672 (patch) | |
tree | 134c6d07daf9b37244ce06ff194f83c74d8cead6 /profile-widget | |
parent | 2c5fad73e8939409639548571dcb942e6b2cb792 (diff) | |
download | subsurface-2d9613956618105030611f7c785d7dbdd5c5c672.tar.gz |
Changed quite a few shorts to bool on the c++ implementtion
The shorts where being used on the preferences since a long
while and we cannot just simply change them to bool since this
could break the preferences files, so work around that by
changing them to booleans, since it's the correct type for a
true / false answer.
Also, move some plot curves to the new settings style
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/divecartesianaxis.cpp | 1 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.cpp | 45 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.h | 7 |
3 files changed, 22 insertions, 31 deletions
diff --git a/profile-widget/divecartesianaxis.cpp b/profile-widget/divecartesianaxis.cpp index 41d6bc3e4..2c3b7fe79 100644 --- a/profile-widget/divecartesianaxis.cpp +++ b/profile-widget/divecartesianaxis.cpp @@ -1,6 +1,7 @@ #include "divecartesianaxis.h" #include "divetextitem.h" #include "helpers.h" +#include <subsurface-qt/SettingsObjectWrapper.h> #ifndef SUBSURFACE_MOBILE #include "preferences/preferencesdialog.h" #endif diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index b7729bda1..f567801ce 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -10,6 +10,7 @@ #endif #include "diveplannermodel.h" #include "helpers.h" +#include <subsurface-qt/SettingsObjectWrapper.h> #include "libdivecomputer/parser.h" #include "profilewidget2.h" @@ -27,6 +28,11 @@ void AbstractProfilePolygonItem::settingsChanged() { } +void AbstractProfilePolygonItem::setVisible(bool visible) +{ + QGraphicsPolygonItem::setVisible(visible); +} + void AbstractProfilePolygonItem::setHorizontalAxis(DiveCartesianAxis *horizontal) { hAxis = horizontal; @@ -255,7 +261,7 @@ DiveHeartrateItem::DiveHeartrateItem() pen.setCosmetic(true); pen.setWidth(1); setPen(pen); - settingsChanged(); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::hrgraphChanged, this, &DiveHeartrateItem::setVisible); } void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) @@ -334,11 +340,6 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->restore(); } -void DiveHeartrateItem::settingsChanged() -{ - setVisible(prefs.hrgraph); -} - DivePercentageItem::DivePercentageItem(int i) { QPen pen; @@ -383,11 +384,7 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->setPen(pen()); painter->drawPolyline(polygon()); painter->restore(); -} - -void DivePercentageItem::settingsChanged() -{ - setVisible(prefs.percentagegraph); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::percentageGraphChanged, this, &DivePercentageItem::setVisible); } DiveAmbPressureItem::DiveAmbPressureItem() @@ -432,11 +429,7 @@ void DiveAmbPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte painter->setPen(pen()); painter->drawPolyline(polygon()); painter->restore(); -} - -void DiveAmbPressureItem::settingsChanged() -{ - setVisible(prefs.percentagegraph); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::percentageGraphChanged, this, &DiveAmbPressureItem::setVisible); } DiveGFLineItem::DiveGFLineItem() @@ -481,11 +474,7 @@ void DiveGFLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op painter->setPen(pen()); painter->drawPolyline(polygon()); painter->restore(); -} - -void DiveGFLineItem::settingsChanged() -{ - setVisible(prefs.percentagegraph); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::percentageGraphChanged, this, &DiveAmbPressureItem::setVisible); } DiveTemperatureItem::DiveTemperatureItem() @@ -610,11 +599,7 @@ void DiveMeanDepthItem::paint(QPainter *painter, const QStyleOptionGraphicsItem painter->setPen(pen()); painter->drawPolyline(polygon()); painter->restore(); -} - -void DiveMeanDepthItem::settingsChanged() -{ - setVisible(prefs.show_average_depth); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::showAverageDepthChanged, this, &DiveAmbPressureItem::setVisible); } void DiveMeanDepthItem::createTextItem() { @@ -838,6 +823,14 @@ void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsI DiveCalculatedTissue::DiveCalculatedTissue(ProfileWidget2 *widget) : DiveCalculatedCeiling(widget) { settingsChanged(); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::calcalltissuesChanged, this, &DiveCalculatedTissue::setVisible); + connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::calcceilingChanged, this, &DiveCalculatedTissue::setVisible); +} + +void DiveCalculatedTissue::setVisible(bool visible) +{ + Q_UNUSED(visible); + settingsChanged(); } void DiveCalculatedTissue::settingsChanged() diff --git a/profile-widget/diveprofileitem.h b/profile-widget/diveprofileitem.h index 8f9a56f6e..ce60b41c3 100644 --- a/profile-widget/diveprofileitem.h +++ b/profile-widget/diveprofileitem.h @@ -49,6 +49,7 @@ slots: virtual void settingsChanged(); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void modelDataRemoved(const QModelIndex &parent, int from, int to); + void setVisible(bool visible); protected: /* when the model emits a 'datachanged' signal, this method below should be used to check if the @@ -91,7 +92,6 @@ public: DiveMeanDepthItem(); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - virtual void settingsChanged(); private: void createTextItem(); @@ -116,7 +116,6 @@ public: DiveHeartrateItem(); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - virtual void settingsChanged(); private: void createTextItem(int seconds, int hr); @@ -129,7 +128,6 @@ public: DivePercentageItem(int i); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - virtual void settingsChanged(); private: QString visibilityKey; @@ -141,7 +139,6 @@ public: DiveAmbPressureItem(); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - virtual void settingsChanged(); private: QString visibilityKey; @@ -153,7 +150,6 @@ public: DiveGFLineItem(); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - virtual void settingsChanged(); private: QString visibilityKey; @@ -205,6 +201,7 @@ class DiveCalculatedTissue : public DiveCalculatedCeiling { Q_OBJECT public: DiveCalculatedTissue(ProfileWidget2 *profileWidget); + void setVisible(bool visible); virtual void settingsChanged(); }; |