mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
bf4144a012
commit
bd5cc109f0
1 changed files with 5 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue