summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-07-17 00:26:46 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-17 00:01:42 -0700
commit6d7a9b946634542dfa6b8649850ed87ba20c5db6 (patch)
tree8e5a94c3ea1e5a69fad05dc46e2455289d81b6d0 /qt-ui
parente69bb1879eaee2cb9119ee5e46204f5ecef6d157 (diff)
downloadsubsurface-6d7a9b946634542dfa6b8649850ed87ba20c5db6.tar.gz
Use plot_data cylinderindex instead of event data
For the info box, we can't use the event data, because its not 1:1 mapped to whats in the cylinder and what we actually switched to. Use the plot_data here we already calculated what we are switching to. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/diveeventitem.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index 55408dfdc..201b4890a 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -87,9 +87,15 @@ void DiveEventItem::setupToolTipString()
int type = internalEvent->type;
if (value) {
if (type == SAMPLE_EVENT_GASCHANGE || type == SAMPLE_EVENT_GASCHANGE2) {
- struct gasmix *g = get_gasmix_from_event(internalEvent);
+ QModelIndexList result = dataModel->match(dataModel->index(0, DivePlotDataModel::TIME), Qt::DisplayRole, internalEvent->time.seconds);
+ if (result.isEmpty()) {
+ Q_ASSERT("can't find a spot in the dataModel");
+ return;
+ }
+ // We need to look at row + 1, where the new gas is active to find what we are switching to.
+ int cylinder_idx = dataModel->data(dataModel->index(result.first().row() + 1, DivePlotDataModel::CYLINDERINDEX)).toInt();
name += ": ";
- name += gasname(g);
+ name += gasname(&current_dive->cylinder[cylinder_idx].gasmix);
} else if (type == SAMPLE_EVENT_PO2 && name == "SP change") {
name += QString(":%1").arg((double)value / 1000);
} else {