Batch data prefetch in QAbstractItemModel
-
Hi.
I'm implementing a QListView with a model that gets its data from the network. When a listing is shown, it gets the entire dataset that will be used for the display role, since this is cheap. However, the decoration role is more expensive, so I want to only fetch those items that will be needed. I could do this inside the data() override, but it would be more efficient if I could know when the view is about to make a bunch of data() calls, so I can fetch all the information in a single network call. I'm not seeing any way to do this. Am I missing something, or is there really no way?
Thanks.
-
@Helios said in Batch data prefetch in QAbstractItemModel:
if I could know when the view is about to make a bunch of data() calls
You can't but there is a way around it, albeit not pretty.
Whendata
ormultiData
requires the decoration add this request to aQQueue
then have slot connected to aQTimer
that will check whether there is stuff in the queue and process it all at once.