Model/View... where to store the data? (was Re: GDB/MI (Was: Embedded development)

Adam Treat treat at
Wed Sep 14 16:26:04 UTC 2005

On Wednesday 14 September 2005 10:08 am, Roberto Raggi wrote:
> Hi Adam,
> On Wednesday 14 September 2005 08:50, Adam Treat wrote:
> > What do you mean the model doesn't store data?  To my mind that is
> > exactly what it does?  Did you mean that the _view_ doesn't store data? 
> > Or do we have a problem of communication?
> no!! QAbstractItemModel provides _only_ an API to associate data with
> indexes. The data are not stored in the model. If you want you can store
> your data in the model (like we do in KDevItemModel) but you're not forced
> to do it(and actually it's wrong-ish :-).

Ok, I see we have a problem of communication.  Actually, KDevItemModel doesn't 
store it's own data.  That is given to KDevItemCollection which is not a 
subclass of an Qt class.  KDevItem stores a reference to the root 
KDevItemCollection ;)

This is as it should be I imagine.

> Suppose you have existing data (e.g. a QStringList). Well.. you don't store
> the string list in the model. The thing you do with the QStringListModel is
> to describe how "the string at position (i)" is associated with QModelIndex
> "index"). This is a pretty cool feature!! Thanks to it we can implement
> things like the QProxyModel that takes a model and trasform it into
> something else, or KFilterModel (in kdevelop/lib/util) that takes a model
> and filters it(of course without duplicating the data)!!!
>  In general you have
>   - existing data (e.g. class MyStorage)
>   - the model that compute the indexes from the data (e.g. MyStorageModel:
> QAbstractModel with a reference to MyStorage)
>   - views and delegates

So, we can store the data outside the model in some arbitrary class.  But the 
point is __we certainly do not want to store it in the view__!

Now, a question to make sure we are on the same page:

I have a class in my documentmodel called KDevFileItem which subclasses 
KDevItemCollection.  This class stores the URL reference for the file.

Is this correct?  Again, KDevItemCollection subclasses no Qt class and it does 
store the data for KDevItemModel.


> ciao robe
> _______________________________________________
> KDevelop-devel mailing list
> KDevelop-devel at

I'm running a Marathon in December!
HELP ME SAVE LIVES and Donate Today!

More information about the KDevelop-devel mailing list