On 17.11.06 18:00:42, Matt Chambers wrote:
> I actually went ahead and made the changes I needed to move the data into the
> model. Instead of just
> replacing the data entirely, I have a loop for updating and inserting, and
> one
> for deleting. Updating
> existing data works great, adding/removing is where I'm having issues.
>
> My data is based off ElementTree. The first thing I do is create a
> dictionary
> that maps each element, to
> its parent, and its row:
>
> {
> <Element 'g' at 0xf6bfeae8>: (<Element 'payload' at 0xf6bfe8d8>, 0),
> <Element 'e' at 0xf6bfe938>: (<Element 'g' at 0xf6bfeae8>, 0),
> <Element 'e' at 0xf6bfeb90>: (<Element 'g' at 0xf6bfeae8>, 1),
> <Element 'e' at 0xf6bfeba8>: (<Element 'g' at 0xf6bfeae8>, 2),
> <Element 'e' at 0xf6bfebc0>: (<Element 'g' at 0xf6bfeae8>, 3)
> }
>
> I can detect if one of these elements is not in the new ElementTree, but, how
> do I get the info needed
> to call beginRemoveRows( QModelIndex parent, int row, int col). I can get
> the
> row,col no problem,
> but how can I get the deleted items parent QModelIndex?
Well, you have to have some mapping from Element back to a proper index,
i.e. you need a way to get the index for an Element in the tree. Then
you can call parent() on that index.
Andreas
--
You will be singled out for promotion in your work.
_______________________________________________
PyKDE mailing list [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde