I finally started to implement the "Home" page of the interface today, based on my last reference design. While it hasn't been reviewed and approved by our designer yet, I figured I can at least write up the rss-parsing code and test my skills at Qt painting APIs.
The hardest part was to get the background picture properly displayed on the home page. On all other pages, the backgrounds are drawn on QTreeWidget, which is a single widget, so merely overriding paintEvent() did it. However, on the "Home" page there are multiple widgets (some QHtmlBrowsers, some panels, labels and such), some of which draw their own background, so painting on the lowest-level widget doesn't work, since the child widgets draw on top of the parent.
After numerous attempts and surfing around the net and Qt manual, the solution turned out to be rather simple ("everything is simple, once someone has told you how"):
- Set the background color role in child widget's palette to transparent.
- Install event filter for child widgets which draw their background.
- When the child widget draws it's background, repaint the parent widgets background on top of the child widgets background (remember - the background image is painted at ~30% transparency level).
- Let the child widget paint itself now.
This results in child widget's data being drawn clearly, but their background becomes transparent, showing the background image beneath.
Once that was in place, I used QXmlSimpleReader and QXmlDefaultHandler-derived parser to implement a simple rss reader. As it turns out, every rss feed I got my hands on has slightly different format and completely different date/time formatting system - I implemented support for three (this blog, RespectP2P and Slyck), and had to use different code for each of them. Oh well.
Since custom feeds will be possible in the future as well, I already implemented the stuff as generic classes, so we can easily add user-customizability later on.
Madcat, ZzZz