-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sortproxymodel: check if source model is a proxy model #31
Conversation
Doesn't this rather mean that KSortFilterProxyModel forgets to emit modelReset in its own setSourceModel? It's supposed to tell the world if its own source model changes.... |
I'm actually testing it with a custom proxy model that simply subclassed KDToolBox/qt/model_view/sortProxyModel/sortproxymodel.cpp Lines 133 to 135 in e3fd152
|
Then the bug is that |
Currently, when using
If we call |
Oh, just realized, did you mean treat |
I don't really know. I actually don't know anything about |
Above is a simple test program for the issue that I want to address. (the code is plainly for testing purpose so it's still sort of messy)
|
if the source model is a proxy model, the source model's source model might be changed and our sortproxymodel won't get notified. This might happen when we try to pass a QML-based proxy model as source model, like KItemModel.KSortFilterProxyModel for example.
Patch updated, now we rely on |
@dfaure-kdab sorry for the ping, could you check if the updated patch is fine to merge? |
As I said, @AndreSomers will be the one to approve this, as the maintainer of sortproxymodel. |
Thank you for your contribution; sorry for not responding to your contribution sooner. Unfortunately, I think your approach is fundamentally flawed. I don't think it is reasonable to assume that after a model reset we conceptually have the same items in the model if we have the same number of rows. Of course, the SortProxyModel should indeed listen to the modelReset signals, but it should do so with emiting it's own modelAboutToReset and then after the source model send modelReset, it should just completely re-build the internal model and not attempt to emit moves. I would welcome If you are dealing with input data that doesn't fundamentally change but gets updated by just dumping a new batch (which is often handled by just doing a model reset), you may need to look at updateableModel. This model is designed to handle situations like that and will actually go over the data to figure out what changed instead of just resetting the model. Putting a SortProxyModel on top of that should then work. |
if the source model is a proxy model, the source model's source model might be changed and our SortProxyModel won't get notified. This might happen when we try to pass a QML-based proxy model as source model, like KDE Framework's
KItemModel.KSortFilterProxyModel
for example.