On Fri, Jan 2, 2015 at 9:35 PM, Linus Torvalds
<[email protected]> wrote:
>
> I'll take a look at the odd cylinder switch thing next.
Ok, I really can't make any sense of what the code tried to do, but it
was complicated and insane.
Rather than try to make sense of what it was doing digging into the
model data, the attached patch just does the sane thing, which makes
things work.
I don't have explicit cylinder numbers for the gas switch events - or
rather, I *do* have them, because it's what the EON Steel internally
uses, but the libdivecomputer interface with the crazy gasmix approach
doesn't allow me to pass those ones. So I've not tested that part, but
now the code is so trivial that I dare say it should work too. So if
you have an explicit cylinder number, the tooltip should now say
gaschange: EAN40 (cyl 2)
which means that it's switching to cylinder 2 (which is EAN40).
Without the explicit cylinder number, it's just "gaschange: EAN40"
like it was before.
Anyway, with this, my EON Steel data shows correctly, so my next email
will be the libdivecomputer patch to get gaschanges from the EON
Steel.
Linus
From 8b8f1f1ad7d03a6caa6fad3900dd6a749377e99e Mon Sep 17 00:00:00 2001
From: Linus Torvalds <[email protected]>
Date: Fri, 2 Jan 2015 22:09:01 -0800
Subject: [PATCH 2/2] 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 <[email protected]>
---
qt-ui/profile/diveeventitem.cpp | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index a9c3c3fd743f..4294dfb29589 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 {
--
2.2.1.212.gc5b9256
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface