Skip to content
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

Moving items in ListModel source handled incorrectly #75

Open
mirukana opened this issue Apr 10, 2020 · 4 comments
Open

Moving items in ListModel source handled incorrectly #75

mirukana opened this issue Apr 10, 2020 · 4 comments

Comments

@mirukana
Copy link

I'm using a ListModel as sourceModel, and I need to sort my model's data from my backend which calls ListModel.move(), so I want to use SortFilterProxyModel purely for filtering.

The SortFilterProxyModel gets reset whenever a movement happens, which causes all delegates to be constantly deleted-recreated and breaks any ListView.move transition... what causes this behavior?

Here's a sample code that demonstrates the problem.

@oKcerG
Copy link
Owner

oKcerG commented Apr 10, 2020

Hello,

Unfortunately the issue is caused by the base class QSortFilterProxyModel emitting a layoutChanged each time the the source model emits a rowMoved : https://code.woboq.org/qt5/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp.html#_ZN28QSortFilterProxyModelPrivate18_q_sourceRowsMovedERK11QModelIndexiiS2_i

I'm afraid this can't be fixed easily.
Refactoring SortFilterProxyModel to not inherit from QSortFilterProxyModel is seriously considered and is the way forward for this lib, but I have yet to begin this task and can not give you a time frame for when it'll be done.

@iberiozko
Copy link

iberiozko commented Apr 10, 2020 via email

@mirukana
Copy link
Author

Thanks for the answers.
I don't know much C++, so I'll ask: isn't it possible to override that function, or to simply disconnect the signal that calls it?

@iberiozko
Copy link

iberiozko commented Apr 14, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants