Rather than serialising and de-serialising your item each time, you could
instead keep track of origin and destination *indexes* of the operation;
and then re-order the items accordingly.

For example, if you’ve got these items in your model.

item0
item1
item2
item3

And in your drag and drop operation, you take the item at index 0 (only
keeping track of the index in dropMimeData) and drop it at index 2 then you
might expect your model to look like this.

item1
item2
item0
item3

And once you’ve know that, you can either sort it manually to match or use
something like moveRow of QAbstractItemModel and have the model handle how
it should all end up.
​
It saves you the trouble of serialisation, at the cost of not being able to
drop it anywhere else, like a text editor, as the index doesn’t really mean
much on its own.
​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODo133mNBX2vmzaCFJ%3DO0AH5ndYmHXuMi94k2c6VyXV5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to