I'm trying to use beginMoveRows / endMoveRows to make persistent indexes stick, but sometimes expanded state flags / persistent indexes are duplicated, where they should not be.
There is quite a lot of code, so I'll go through what I think I have told the machine to do:
There is a method, sortChildrenOf(item) which does all the magic.
- Find children from item and call sortChildrenOf with each child as a parameter
- save old order
- quickSort children
- find differences in old order and the new
- for each difference:
- beingMoveRows
- apply change
- endMoveRows
Everything works perfectly when there are 2 levels, but when I input a "long" tree of data, persistent indexes get corrupted.
The data in the tree is updated from network, but the actual update is done in the gui thread.
Is there some precise order I should do stuff in? Might I have forgotten to inherit some method that causes this?
I'v got these methods implemented: - data - flags - getItem - index - parent - setData
Edit: forgot to mention, i got emit layoutAboutToBeChanged and emit layoutChanged before and after the main sortChildrenOf call.