PDA

View Full Version : 1 large model dataset, 3 filter proxies, how to trigger layoutChanged selectively?



rglennie
20th July 2017, 16:08
The model has a large data set of datetime values (spanning several months). Each of the three filter proxies has a small date range (one day, one week and one month) that each uses in filterAcceptsRow() to filter and update three different windows

Currently when I modify a narrow date range in the model and emit layoutChanged(), all three filter proxies respond and re-layout which is noticeably slow. This is wasteful when one or more of them of them are well outside the range modified. I tried to send a custom signal instead with the modified date range and in each proxy trigger layoutChanged manually if the modified range/proxy range overlap, but that doesn't work.

I also tried using dataChanged( startIndex, endIndex ) but it did not prevent out-of-range proxies from updating. I think dataChanged() applies when the data changed is a subset of the filter proxy range, not out of range altogether.

I've done a lot of searching and found no ideas so far. Anyone else worked with this problem?

Santosh Reddy
21st July 2017, 12:10
Firstly what do you mean by "...narrow date range..." if just data values change then you should be using dataChanged() and not layoutChanged(), and if data structure / layout is changing then use layoutChanged() but read the Qt Docs, it clearly specifies the requirement to emit layoutAboutToBeChanged() and others steps to follow, not sure if you did those. Also double check startIndex and endIndex of dataChanged() signal, it is not much difficult to get them wrong. Further emiting layoutChanged() surely should trigger all the views and corresponding proxy models to refresh, as the term itself means "layout has changed", old layout is not valid. I would suggest to check dataChanged() indexes again.