[Qt5-feedback] Moving itemmodels to QtCore

Jason H scorp1us at yahoo.com
Fri Jul 1 19:01:27 CEST 2011


________________________________
From: Stephen Kelly <steveire at gmail.com>
To: qt5-feedback at qt.nokia.com
Sent: Friday, July 1, 2011 8:27 AM
Subject: Re: [Qt5-feedback] Moving itemmodels to QtCore

lars.knoll at nokia.com wrote:

> On 7/1/11 2:02 PM, "ext Stephen Kelly" <steveire at gmail.com> wrote:
> 
...
I've heard this several times, but so far no one has said anything about 
trees, which are important.

Yes it's possible to make new classes which don't have that nasty 
QModelIndex for tables and lists. Go ahead and make those new classes if you 
want. 

But to replace the existing models you'll need to think about trees too. So 
far I haven't seen any trolls consider that at all. Do you want to design a 
new class for that too or use the existing tested and known code?

Cheers,

Steve.
_______________________________________________

I've been calling for a standard model for some time. And at its heart is has to be a tree model. Really, everything should be able to use this model. The only time a QList is needed is for static contents ("Male", "Female", "Other") and really that is only for simplicity's sake.  I do have a confession to make and that is I never learned  how to use a tree model because the model indexes were too abstract for me to make sense of! It's really held me back. But here I am pushing for an even more abstract model - one that can be used in XML (tree) as well as databases (grid) as well as GUI controls (list, grid, tree). 

I once got to use a nice recursive map class from one of the creators of Qxt. It was essentially a QMap-derived class with an added value() member which could be an additional map. For my implementation, my keys were all quint32s, (with a optional quint32->QString item name dictionary) so my keys could be array indexes or item IDs. 

Then all serialization was done as:
begin(); //begin serialization)
item(ID1, VALUE); // basic method to write item and value
push(); //add new child map
item(ID2 or index ,VALUE); // basic method to write item and value (ID1 would be known to be an array or not. Index if array or ID2 if not)
pop(); //return to parent map
end(); //end serialization

Once we have a general-purpose tree model, we can make converting and manipulating data so much easier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110701/2fd9cc4b/attachment.html 


More information about the Qt5-feedback mailing list