test binaries for Beta 5

Dirk Hohndel dirk at hohndel.org
Tue Aug 5 07:17:49 PDT 2014


On Tue, Aug 05, 2014 at 02:46:56PM +0200, Robert Helling wrote:
> 
> On 05.08.2014, at 13:55, Tomaz Canabrava <tcanabrava at kde.org> wrote:
> 
> Hi,
> > Good catch. This is just a matter of changing the connect line for the gf high to editfinished instead of value changed, can somebody do that for me? Im on the dive store trying to buy my wet suit now, só I dont have a computer. 
> > 
> > 
> there is a technical complication (which at the moment hinders me from
> simply trying it out: valueChanged(int) comes with the new value while
> editFinished() doesn’t. So the receiver of the signal (a slot of the
> DivePlannerPointsModel) has to get hold of the new value. Of course I
> can write a getter method in PlannerSettingsWidget to return that but in
> the short time I have now I could not figure out how to get hold of that
> widget (to call its method) from the DivePlannerPointsModel.

You have to have two slots. One that tracks the value (and in my case
updates things if the value seems safe), and one that forces the update if
the user leaves the field.

> What worries me more is that the docu of editingFinished says "This
> signal is emitted editing is finished. This happens when the spinbox
> loses focus and when enter is pressed.” 

Exactly, that's the point.

> To me this sounds (I admittedly did not try) like it is _not_ emitted
> when only the spinners are clicked (as the focus stays on the spin box).
> That would be very bad since we wouldn’t have the instant update of the
> profile/plan.

Yes, which is why I implemented it like this:

	connect(ui.gfhigh, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFHigh(int)));
	connect(ui.gflow, SIGNAL(valueChanged(int)), plannerModel, SLOT(setGFLow(int)));
	connect(ui.gfhigh, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFHigh()));
	connect(ui.gflow, SIGNAL(editingFinished()), plannerModel, SLOT(triggerGFLow()));

and then later

void DivePlannerPointsModel::setGFHigh(const int gfhigh)
{
	tempGFHigh = gfhigh;
	// GFHigh <= 34 can cause infinite deco at 6m - don't trigger a
	// recalculation
	// for smaller GFHigh unless the user explicitly leaves the field
	if (tempGFHigh > 34)
		triggerGFHigh();
}

void DivePlannerPointsModel::triggerGFHigh()
{
	if (diveplan.gfhigh != tempGFHigh) {
		diveplan.gfhigh = tempGFHigh;
		plannerModel->emitDataChanged();
	}
}

void DivePlannerPointsModel::setGFLow(const int ghflow)
{
	tempGFLow = ghflow;
	triggerGFLow();
}

void DivePlannerPointsModel::triggerGFLow()
{
	if (diveplan.gflow != tempGFLow) {
		diveplan.gflow = tempGFLow;
		plannerModel->emitDataChanged();
	}
}

This may not be super elegant, but I think it gets the job done and avoid
unneccessary "DataChanged()" signals in the process.

> In any case, I think the patch I sent earlier should be in place in any
> case since it stops subsurface becoming unresponsive when a too low
> value of GFhigh is entered (possibly with focus change). If Dirk does
> not like the new string, he should just comment out the printf to the
> dive notes. In that case the profile just turns red and the dive plan
> (which is invalid) disappears.

Worst case the warning ends up being English. We'll live.

/D


More information about the subsurface mailing list