[PATCH] Use plot_data cylinderindex instead of event data

Anton Lundin glance at acc.umu.se
Wed Jul 16 23:15:16 PDT 2014


On 16 July, 2014 - Dirk Hohndel wrote:

> On Thu, Jul 17, 2014 at 12:26:46AM +0200, Anton Lundin wrote:
> > 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.
> 
> I'm curious - is this fixing a bug? Why the change?
> 

Yepp, this is a bug. Open dives/test20.xml and look at the dialog box,
it will talk about EAN12 and air before this patch, and 12/70 and 21/30
after this patch.

For the whole discussion, see "Usage of gaschange event data"
<20140716212232.GA20212 at kennedy.acc.umu.se>

//Anton

> > diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
> > index 55408df..201b489 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 {

-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list