Fix partial pressure graph thresholds

Since we only store things in the preferences if they are different from
the default, the existing code that simply compared with the settings
value didn't work when people used the defaults.

We now compare to the actual preference at runtime which should address
that.

Fixes #731

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-11-01 09:22:07 -07:00
parent f0cee72444
commit 89e7cae854
3 changed files with 9 additions and 9 deletions

View file

@ -833,14 +833,14 @@ void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const
alertPolygons.clear(); alertPolygons.clear();
QSettings s; QSettings s;
s.beginGroup("TecDetails"); s.beginGroup("TecDetails");
double threshould = s.value(threshouldKey).toDouble(); double threshold = *thresholdPtr;
bool inAlertFragment = false; bool inAlertFragment = false;
for (int i = 0; i < dataModel->rowCount(); i++, entry++) { for (int i = 0; i < dataModel->rowCount(); i++, entry++) {
double value = dataModel->index(i, vDataColumn).data().toDouble(); double value = dataModel->index(i, vDataColumn).data().toDouble();
int time = dataModel->index(i, hDataColumn).data().toInt(); int time = dataModel->index(i, hDataColumn).data().toInt();
QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value)); QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
poly.push_back(point); poly.push_back(point);
if (value >= threshould) { if (value >= threshold) {
if (inAlertFragment) { if (inAlertFragment) {
alertPolygons.back().push_back(point); alertPolygons.back().push_back(point);
} else { } else {
@ -873,9 +873,9 @@ void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphics
painter->restore(); painter->restore();
} }
void PartialPressureGasItem::setThreshouldSettingsKey(const QString &threshouldSettingsKey) void PartialPressureGasItem::setThreshouldSettingsKey(double *prefPointer)
{ {
threshouldKey = threshouldSettingsKey; thresholdPtr = prefPointer;
} }
PartialPressureGasItem::PartialPressureGasItem() PartialPressureGasItem::PartialPressureGasItem()

View file

@ -211,13 +211,13 @@ public:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
virtual void settingsChanged(); virtual void settingsChanged();
void setThreshouldSettingsKey(const QString &threshouldSettingsKey); void setThreshouldSettingsKey(double *prefPointer);
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey); void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
void setColors(const QColor &normalColor, const QColor &alertColor); void setColors(const QColor &normalColor, const QColor &alertColor);
private: private:
QVector<QPolygonF> alertPolygons; QVector<QPolygonF> alertPolygons;
QString threshouldKey; double *thresholdPtr;
QString visibilityKey; QString visibilityKey;
QColor normalColor; QColor normalColor;
QColor alertColor; QColor alertColor;

View file

@ -272,9 +272,9 @@ void ProfileWidget2::setupItemOnScene()
ITEM->settingsChanged(); \ ITEM->settingsChanged(); \
ITEM->setZValue(99); ITEM->setZValue(99);
CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, "pn2threshold", "pn2graph"); CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, &prefs.pp_graphs.pn2_threshold, "pn2graph");
CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, "phethreshold", "phegraph"); CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, &prefs.pp_graphs.phe_threshold, "phegraph");
CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, "po2threshold", "po2graph"); CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "po2graph");
#undef CREATE_PP_GAS #undef CREATE_PP_GAS
temperatureAxis->setTextVisible(false); temperatureAxis->setTextVisible(false);