Subject: why do we have a root item for DiveItem

Thiago Macieira thiago at macieira.org
Thu Apr 25 15:10:07 PDT 2013


On quinta-feira, 25 de abril de 2013 20.20.31, Amit Chaudhuri wrote:
> Dirk,
> 
> A root item is required for the model's hierarchy.  Each item in a model
> (derived from QAbstractItemModel) can be uniquely specified by a
> combination of row, column and parent params.  In this case, the root item
> is the parent of all top level items in the tree.

A root item is required, but is it required that the root item have a valid 
DiveItem*?

>From what I can tell, the root item is required right now only to know what 
children it has. And besides, the list of dives and trips are stored somewhere 
else, so we don't actually have to keep a link to it in a model item.

And this root item is special anyway. It's neither a dive nor a trip, it's 
just the top of the tree.

By the way, can't we have a tree with no root? I.e., a list of items with a 
QModelIndex() as parent?

> Lists and Tables don't need the parent parameter in the same way that Trees
> do.  This will matter a bit more when we add support for Trips.  Then we
> will have the possibility that a Dive might have a Trip (rather than the
> invisible rootItem) as parent.  Whether we need the default ctor for this
> is not 100% clear to me.  We might be able to use the other one and specify
> suitable values to that.  Possibly a question for one of the others, or I
> need to play or research some detail.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130425/d20210d5/attachment.sig>


More information about the subsurface mailing list