mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Code cleanup: HeartRate item was doing insane things
This simplifies so much of the code that we were using to control the visibility of the HeartRate. now things are much saner. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
65eefe7b59
commit
607d450cd6
3 changed files with 9 additions and 30 deletions
|
@ -254,7 +254,7 @@ DiveHeartrateItem::DiveHeartrateItem()
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
pen.setWidth(1);
|
pen.setWidth(1);
|
||||||
setPen(pen);
|
setPen(pen);
|
||||||
visible = true;
|
settingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
|
@ -335,20 +335,7 @@ void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
|
|
||||||
void DiveHeartrateItem::settingsChanged()
|
void DiveHeartrateItem::settingsChanged()
|
||||||
{
|
{
|
||||||
QSettings s;
|
setVisible(prefs.hrgraph);
|
||||||
s.beginGroup("TecDetails");
|
|
||||||
visible = s.value(visibilityKey).toBool();
|
|
||||||
setVisible(visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveHeartrateItem::setVisibilitySettingsKey(const QString &key)
|
|
||||||
{
|
|
||||||
visibilityKey = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DiveHeartrateItem::isVisible()
|
|
||||||
{
|
|
||||||
return visible == true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveTemperatureItem::DiveTemperatureItem()
|
DiveTemperatureItem::DiveTemperatureItem()
|
||||||
|
|
|
@ -102,13 +102,9 @@ public:
|
||||||
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
virtual void settingsChanged();
|
virtual void settingsChanged();
|
||||||
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
|
|
||||||
bool isVisible();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createTextItem(int seconds, int hr);
|
void createTextItem(int seconds, int hr);
|
||||||
QString visibilityKey;
|
QString visibilityKey;
|
||||||
bool visible;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiveGasPressureItem : public AbstractProfilePolygonItem {
|
class DiveGasPressureItem : public AbstractProfilePolygonItem {
|
||||||
|
|
|
@ -222,8 +222,6 @@ void ProfileWidget2::setupItemOnScene()
|
||||||
setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
|
setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
|
||||||
setupItem(temperatureItem, timeAxis, temperatureAxis, 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);
|
setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1);
|
||||||
heartBeatItem->setVisibilitySettingsKey("hrgraph");
|
|
||||||
heartBeatItem->settingsChanged();
|
|
||||||
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
|
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
|
||||||
|
|
||||||
#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \
|
#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \
|
||||||
|
@ -452,18 +450,16 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
||||||
temperatureAxis->setMinimum(pInfo.mintemp);
|
temperatureAxis->setMinimum(pInfo.mintemp);
|
||||||
temperatureAxis->setMaximum(pInfo.maxtemp);
|
temperatureAxis->setMaximum(pInfo.maxtemp);
|
||||||
|
|
||||||
if (heartBeatItem->isVisible()) {
|
|
||||||
if (pInfo.maxhr) {
|
if (pInfo.maxhr) {
|
||||||
heartBeatAxis->setMinimum(pInfo.minhr);
|
heartBeatAxis->setMinimum(pInfo.minhr);
|
||||||
heartBeatAxis->setMaximum(pInfo.maxhr);
|
heartBeatAxis->setMaximum(pInfo.maxhr);
|
||||||
heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks
|
heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks
|
||||||
heartBeatAxis->setVisible(true);
|
heartBeatAxis->setVisible(true);
|
||||||
} else {
|
|
||||||
heartBeatAxis->setVisible(false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
heartBeatAxis->setVisible(false);
|
heartBeatAxis->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeAxis->setMaximum(maxtime);
|
timeAxis->setMaximum(maxtime);
|
||||||
int i, incr;
|
int i, incr;
|
||||||
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
|
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
|
||||||
|
|
Loading…
Add table
Reference in a new issue