[PATCH] Amend divetrip model to use int units

Dirk Hohndel dirk at hohndel.org
Thu Apr 25 06:20:36 PDT 2013


On Thu, 2013-04-25 at 07:56 +0100, Amit Chaudhuri wrote:
> Ah. I can see I only got part of the picture...thanks for the clear
> explanations.
> 
> 
> It leaves me with the "how do I..?" if I try and change diveItem to
> use depth_t directly.  Here goes:
> 
> 
> When I create the empty root item for the model I use a default
> constructor call.  
> 
> rootItem = new DiveItem;
> 
> 
> And to get that to work I tried this...
> 
> 
> explicit DiveItem(): number(0), dateTime(QString()), seconds(0),
> depth({0}) .....
> 
> ^^^
> 
> 
> This creates a compiler warning: extended initializer lists only
> available with -std=c++11 or -std=gnu++11 [enabled by default] when I
> wrap the value I want to put into the depth_t struct in braces
> 
> 
> If I drop the curly braces I get a warning that boils down to a
> missing constructor depth_t::depth_t().
> 
> 
> So I guess my question is "what's the best way to pass the simple
> subsurface units to a member initialisation list?"
> 
> And if the answer to that question is "don't" then how would you like
> to see default constructors handle this without using member
> initialisation lists?

The answer is "pull the latest Qt branch and look where we are".

I took your changes and then added on top of them to show how this could
be done. And then Thiago, Alberto and Henrik came up with ideas to make
it less insane :-)

(I'll push out that last patch from Henrik in a minute)

/D




More information about the subsurface mailing list