summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2015-01-02 22:09:01 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-02 22:43:21 -0800
commit9a4cafd0f10b36fd25bda6ce67106557f389dcff (patch)
tree1620fe5202ac6abad1ecd93c17a73461dcb810d9 /qt-ui/profile
parentc2b076548d9dcf0dc71c34e416214604eb76e7f9 (diff)
downloadsubsurface-9a4cafd0f10b36fd25bda6ce67106557f389dcff.tar.gz
Fix gaschange tooltip information
The code tried to look up the cylinder index from the Qt data models, which was not only horribly confusing, but was also buggy. I think the index ends up being off by one when the first cylinder change is hidden (because it's at the beginning of the dive), but I can't make heads or tails of that crazy code, so there might be something else going on. Just remove all the crazy code, and use the event data directly. Which gas the gasmix and the (potential) explicit cylinder index already. It's much more straightforward, and it just automatically gets the right end result whether some other event is hidden or not. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/diveeventitem.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index a9c3c3fd7..4294dfb29 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -101,15 +101,12 @@ void DiveEventItem::setupToolTipString()
int type = internalEvent->type;
if (value) {
if (event_is_gaschange(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(&displayed_dive.cylinder[cylinder_idx].gasmix);
+ name += gasname(&internalEvent->gas.mix);
+
+ /* Do we have an explicit cylinder index? Show it. */
+ if (internalEvent->gas.index >= 0)
+ name += QString(" (cyl %1)").arg(internalEvent->gas.index);
} else if (type == SAMPLE_EVENT_PO2 && name == "SP change") {
name += QString(":%1").arg((double)value / 1000);
} else {