[PyQt] PyQt createIndex question

Doug Nichols doug16 at gmail.com
Sun Sep 14 16:12:09 BST 2008


The only thing I mean by this that the data I'm displaying as a tree is in a
database that can and will be updated from multiple locations and will
change frequently.  The tree view is alphabetized and so the 3 row may
become the 5 row and so the index row value will frequently be outdated.  In
addition to this, the leaves of the tree are frequently associated with
multiple trunks.  Basically picture the leaf as a song and the trunk as the
artist.  Several songs have multiple artists and are listed under all of
them in the tree.  Therefore, I can't just assume the first artist listed is
always the artist of the song.  Therefore, the initial solution I had was to
store the artist item, the row the artist was in, and the song in a tuple.
I would then check the current row of the artist and compare it to the old
row and if it was different, then signal a layout change.  The same for the
song row which is already included in the index.  Not a perfect DB change
detection system, but would work for now.  Therefore, I would probably store
that tuple in the dictionary and retrieve it based on the id in the
internalptr of the index and clear the database whenever I issue a layout
change.

Thanks,
Doug

On Sun, Sep 14, 2008 at 9:27 AM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 14.09.08 09:01:49, Doug Nichols wrote:
> > Yea, but the C++ equivalent also doesn't do GC, I was reling on the
> Python
> > GC to do my memory management for me. Bad/Lazy programming style.
>
> Well ideally you shouldn't need to care.
>
> > I'll look into the dictionary concept.  I just need to determine when
> > to clear the dictionary, because the Indices created were thrown away.
> > I assume it would be whenever a layoutChanged() signal is emitted?
>
> I'm not sure what you mean here. What I meant was for each item you have
> in your model, you keep a map of a unique identifier (for example
> obtained via id()) and that "item" (data structure of your data). And
> let the model index carry that number instead of some data-pointer. And
> of course your model should know when some of its underlying data is
> being removed. layoutChanged is meant for things like the view or
> selection model to get notified when your models underlying data changed
> significantly.
>
> Andreas
>
> --
> Future looks spotty.  You will spill soup in late evening.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Doug Nichols
doug16 at gmail.com
http://dnwnichols.home.comcast.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080914/05463c2d/attachment.html


More information about the PyQt mailing list