aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-02-14 21:17:31 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-14 21:50:05 -0800
commitbd5cc109f0ad0b16ac0d5402a60268331cfdf2b9 (patch)
tree57bbb9734e9934691dda3c69c8898e8dcdfae47c
parentbf4144a012c5f44bab5dfa13dbe94676d1786634 (diff)
downloadsubsurface-bd5cc109f0ad0b16ac0d5402a60268331cfdf2b9.tar.gz
Show the last temperature on the graph.
The code shamelessy copied from the old profile introduced a bug where the old temperature was not correctly shown. I'v added a new member to the class that will store the last valid temperature, and use that to calculate if there's a reason or not to display it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/diveprofileitem.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index 0b1d32a4e..7246309bf 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -227,7 +227,7 @@ DiveTemperatureItem::DiveTemperatureItem()
void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
{
- int last = -300, last_printed_temp = 0, sec = 0;
+ int last = -300, last_printed_temp = 0, sec = 0, last_valid_temp = 0;
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
return;
@@ -240,6 +240,7 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
int mkelvin = dataModel->index(i, vDataColumn).data().toInt();
if (!mkelvin)
continue;
+ last_valid_temp = mkelvin;
sec = dataModel->index(i, hDataColumn).data().toInt();
QPointF point( hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin));
poly.append(point);
@@ -262,10 +263,9 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
/* it would be nice to print the end temperature, if it's
* different or if the last temperature print has been more
* than a quarter of the dive back */
- int last_temperature = dataModel->data(dataModel->index(dataModel->rowCount()-1, DivePlotDataModel::TEMPERATURE)).toInt();
- if (last_temperature > 200000 &&
- ((abs(last_temperature - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75))) {
- createTextItem(sec, last_temperature);
+ if (last_valid_temp > 200000 &&
+ ((abs(last_valid_temp - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75))) {
+ createTextItem(sec, last_valid_temp);
}
}