I have a a model that is used to represent a media player's playlist. As part of this I need to be able to move items in the model (so that a user can re-order a playlist). In my model I call beginMoveRows()/endMoveRows() - and the selection apeears to update on screen (the moved rows keep their selected background). But if the user then shift-clicks elsewhere, the start of the selection appears to be where the original selection was. e.g.:


Moving tracks up:
  1. 10 tracks in play list, numbered 1 to 10
  2. Select 8 and 9
  3. Move to under track 3, so we now have 1, 2, 3, 8, 9, 4, 5, 6, 7, 10 (tracks 8 and 9 are still selected)
  4. Shift select track 10
  5. Tracks 8, 6, 7, and 10 are selected - but selection should be 8, 9, 4, 5, 6, 7, 10


Moving tracks down:
  1. 10 tracks in play list, numbered 1 to 10
  2. Select 2 and 3
  3. Move to under track 8, so we now have 1, 4, 5, 6, 7, 8, 2, 3, 9, 10 (tracks 2 and 3 are still selected)
  4. Shift select track 4
  5. Only tracks 4 and 2 are selected - but selection should be 4, 5, 6, 7, 8, 2, 3


Reading the QAbstractItemView docs, it states
If the user presses the Shift key while clicking on an item, all items between the current item and the clicked item are selected...
So it appears as if the current item is not being updated. I tried to connect to the rowsMoved() signal, and in the slot I checked both the view's, and selection's, current index - both appeared to be fine.

I have some code that attempts to save, and restore, the current index between updates - but this seems a bit too hacky to me. If possible I'dlike to remove this code, and do it properly!

What am I missing?

(The code is part of 'Cantata', which if you are interested you can download from http://kde-apps.org/content/show.php...content=147733)