[PyKDE] QAbstractItemView Question

Matt Chambers chambers at imageworks.com
Sat Nov 18 02:00:42 GMT 2006


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?

Matt

> Why not just avoid calling reset?  If you use beginInsertRows, layoutChanged, 
> or whatever is needed, then the selection will be maintained automatically.
>
> Matt
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20061118/91347628/attachment.html


More information about the PyQt mailing list