why do we have a root item for DiveItem

Dirk Hohndel dirk at hohndel.org
Thu Apr 25 14:00:19 PDT 2013


On Thu, 2013-04-25 at 17:27 -0300, Tomaz Canabrava wrote:
> All models in Qt, by design, starts with an empty 'root' item that
> holds all the items - in the case of list and table models, and holds
> all first nodes, in the case of tree models (our case). 
> 
> This 'root' item by no means requires it to be of the same type of its
> children. 
> 
> But if the underlying model of the subsurface datastructures are
> already tree like, there's no need for items at all. 
> 
> We need only a way to find the parent node from a children, and given
> a children see if they have children's. 
> 
> From what I see on subsurface the dive list has just one depth
> relationship, seems easy to make it. 

Just remember, Subsurface has this oddity:

Trip
   Dive
   Dive
   Dive
Trip
   Dive
Dive (!!!) <- dives can be at the top level
Dive
Trip
   Dive

And then when you sort by any other column, the trips disappear and all
you get is dives.

Over lunch I tried to call model->sort(0, Qt:DescendingOrder), hoping
this would do what I thought it would do (reorder the list). Clearly I
was wrong :-)

The other thing I played with was making on_actionClose_triggered() do
the right thing (i.e. BEFORE it frees all the dives in the table
actually remove them from the model... I couldn't get that to work,
either.

30 minutes spent. Actual progress ZERO.

Hooray for Qt/C++ :-)

/D



More information about the subsurface mailing list