oKcerG / SortFilterProxyModel

A nicely exposed QSortFilterProxyModel for QML
MIT License
298 stars 101 forks source link

Moving items in ListModel source handled incorrectly #75

Open mirukana opened 4 years ago

mirukana commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Have a nice day :)

The problem is, oKcerG did not have a chance to implement the case.

All events like OnChanging. beforeSOMETING, *afterSOMETHING – are not implemented yet.

You shaulh try it yourself... With my pleasure, // Ivan

From: miruka [mailto:notifications@github.com] Sent: Friday, April 10, 2020 2:39 PM To: oKcerG/SortFilterProxyModel Cc: Subscribed Subject: [oKcerG/SortFilterProxyModel] Moving items in ListModel source handled incorrectly (#75)

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?

https://github.com/mirukana/sortfilterproxy-move-problem/blob/master/src/Window.qml Here's a sample code that demonstrates the problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, https://github.com/oKcerG/SortFilterProxyModel/issues/75 view it on GitHub, or https://github.com/notifications/unsubscribe-auth/ACB5ZUNWXOVHLH4TK7INKRTRL4AMRANCNFSM4MFMW53A unsubscribe. https://github.com/notifications/beacon/ACB5ZUJMY4W6NB5LY5G7U6DRL4AMRA5CNFSM4MFMW53KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4I5CMZHQ.gif

mirukana commented 4 years ago

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 commented 4 years ago

Hello. Beriozko Ivan is on contact…

Please, use this mailing-list for conversation, that works really good.

For orther cases, shaulth thau contact me via email, me shall be pleased to describe the case.

Luks.

From: miruka [mailto:notifications@github.com] Sent: Friday, April 10, 2020 2:39 PMPle To: oKcerG/SortFilterProxyModel Cc: Subscribed Subject: [oKcerG/SortFilterProxyModel] Moving items in ListModel source handled incorrectly (#75)

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 https://github.com/mirukana/sortfilterproxy-move-problem/blob/master/src/Window.qml 's a sample code that demonstrates the problem.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oKcerG/SortFilterProxyModel/issues/75 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACB5ZUNWXOVHLH4TK7INKRTRL4AMRANCNFSM4MFMW53A . https://github.com/notifications/beacon/ACB5ZUJMY4W6NB5LY5G7U6DRL4AMRA5CNFSM4MFMW53KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4I5CMZHQ.gif