Alessandro
11th April 2006, 20:22
Hi,
I have a model derived from QAbstractListModel (http://doc.trolltech.com/4.1/qabstractlistmodel.html) and a list view derived from QListView (http://doc.trolltech.com/4.1/qlistview.html). The models data(..) method needs to perform some calculation each time it returns a value. Since the view queries the data very often, I thought about some sort of cache in order to have that calculation only once per model index.
Instead of implementing the caching directly in the model, I thought to plug a proxy model (derived from QAbstractProxyModel (http://doc.trolltech.com/4.1/qabstractproxymodel.html)) between my model and my view. The proxy should then somehow cache the passed data in its data(..) method.
Now, here is my problem: Since the data(..) method is const, it has no write access to the class members, so it cannot write anything into a cache.
Has somone here already implemented a cache proxy and solved that problem? Or is there a better way to cache something between model and view?
Thank you,
Alessandro
I have a model derived from QAbstractListModel (http://doc.trolltech.com/4.1/qabstractlistmodel.html) and a list view derived from QListView (http://doc.trolltech.com/4.1/qlistview.html). The models data(..) method needs to perform some calculation each time it returns a value. Since the view queries the data very often, I thought about some sort of cache in order to have that calculation only once per model index.
Instead of implementing the caching directly in the model, I thought to plug a proxy model (derived from QAbstractProxyModel (http://doc.trolltech.com/4.1/qabstractproxymodel.html)) between my model and my view. The proxy should then somehow cache the passed data in its data(..) method.
Now, here is my problem: Since the data(..) method is const, it has no write access to the class members, so it cannot write anything into a cache.
Has somone here already implemented a cache proxy and solved that problem? Or is there a better way to cache something between model and view?
Thank you,
Alessandro