You are here

Status of QGraphicScenes and Delegates

In yesterday's blog I talked about my issue of wanting to use (animated) GraphicsView's in an Interview system for Amarok's playlist. Ivan ?uki? pointed me to a 2006 Trolltech Developer Days presentation about Advanced Item View. The presenter did show a pretty brute force way of doing animations in delegates, by just firing a timer every 40 ms. I tried this out two different ways.

First was similar to how he did it, firing a timer. It was not to my great surprise that this resulted in 30% CPU time for just one row needing to be animated, and it went up from there as additional rows were added It actually still looked and reacted fine though, so before I noticed the CPU usage I was feeling like I had cracked the case. :-)

Then I tried it by connecting (indirectly, since I had to translate a QGraphicsScene into a QModelIndex) QGraphicsScene::sceneRectChanged to QAbstractItemView::update. However this didn't work. Apparently QGraphicsScene doesn't consider a flashing cursor as a scene change worth mentioning?

So now I'm basically back to where I was. Except the presentation did hold out another possibility of subclassing QAbstractItemView and then doing setViewport. This is what he did for the QGLWidget views that he made (instead of just writing a view from scratch). However its not quite clear to me what the QAbstractItemView provides when you override the viewport. More importantly none of the examples had scrolling, so they just painted the whole area all the time. And figuring that out is the biggest issue with perhaps using a QGraphicsView (whether by itself or as a viewport of a QAbstractItemView.)

More Playlist Details

Benjamin Meyer had a few questions about the playlist that I'll address here:
  • I think Ben you know what the playlist does. :-) The user queues up music to listen to and can also edit their tags.
  • I see no reason for multiple views.
  • Animations - yes. I don't know if I'll have time to do cool animations this summer, but I do want to have a framework in place where someone could implement nifty animations easily.
  • Editing - currently the reason I want to get animations to work. Users can do some basic bulk tag editing using the playlist.
  • As far as what the playlist looks like, its the thing on the right in Nikolaj's most recent blog. In the future we want to do more complicated things such as grouping tracks from the same albums together.
    • Each row is a single cell, so the entire row is drawn in a single delegate paint. So the view itself is a fairly basic subclass of QListView.