how to manage QGraphicsScene

Jeff Mitchell kde-dev at emailgoeshere.com
Sat Jul 21 08:10:23 CEST 2007


On Friday 20 July 2007, Ian Monroe wrote:
> So currently PlaylistNS::Model just has a Meta::TrackList of tracks,
> which it inserts, removes etc. directly. This is neat because when you
> drag stuff from the collection browser it can insert stuff directly
> into the TrackList at essentially no cost.
>
> But I'm needing to add some playlist specific data to the Tracks or
> otherwise associate the data with them. The issue is that currently
> the Delegate creates QGraphicScene's, adds shit to them, paints them
> and then destroys the QGraphicsScene. This is a bit wasteful and is
> also why I think editing the text currently doesn't work even when I
> set it to on (hopefully it doesn't rely on a QGraphicsView...).
>
> So I could...
> *Subclass Meta::Track, make a PlaylistNS::Item, with a new ->scene()
> method that makes a new scene if there isn't one already or just
> returns the existing one. But I don't think I could morph a bunch of
> Meta::TrackPtr's into this new object (unless we start using Ruby).
> *Have PlaylistNS::Item not derive from anything, just have it with a
> Meta::TrackPtr data member and a QGraphicsScene member. Then keep a
> list of this.
> *Have a new specialized list type which keeps in sync two separate
> QLists of QGraphicsScenes and Meta::TrackPtr's.
>
> I'm leaning towards the last solution, but I was wondering if anyone
> had another idea.

Not having followed the playlist code closely, can you explain why all this 
QGraphicsScene stuff is necessary at all?  I imagine it's for painting the 
playlist items, but in that case you'd have one scene and not a bunch that 
you destroy.  Or am I missing something here?

--Jeff


More information about the Amarok-devel mailing list