So we've started to writing it from scratch (almost).
The first thing to do: extract usefull classes from userbox.h/userbox.cpp to its own files.
Second thing to do: write new widget.
- ContactsListWidget based on QListView - part of Qt4 Model/View framework.
- ContactsModel to feed data from ContactsManager to the new widget
- ContactsModelProxy to sort and filter contacts beetwen ContactsModel and ContactsListWidgets
- ContactsListWidgetDelegate to paint contacts with icons description
I can say that this whole Model/View thing totally kicks ass. Most of the work is done by Qt: we don't have to care about sorting (with its performance when many contacts change status in one time) - we only provide compare function and signals triggered when something changes on ContactsManager.
Also the refreshing code in old UserBox was not very easy to follow - there was methods like refresh(), refreshLater(), refreshAll(), refreshAllLater() and complicated structures that allowed to avoid refreshing list if not neccessary. I'm glad we could remove all that code and just belive that Qt will do it better than us ;)
For each ContactsListWidget in Kadu there is exactly one ContactsListWidgetDelegate object that paints items on list. In Kadu 0.6.6 for each item on each UserBox there was one KaduListBoxPixmap. So I hope our memory ussage is a little bit lower that before (I'll do some measurements after we have 0.6.6 out). Painting code is almost the same - the only difference is description handling. Qt4 provides QTextDocument that we now use for that - Kadu 0.6.5 had custom (and long) code to compute description height and to paint it wrapped. It is another thing that Qt is doing for us now.
But it is not done yet:
- sorting does not works as good as it should (random contacts are not-sorted)
- filtering not yet implemented
- support for only one column (maybe it will be possible to have more columns, i don't know yet)
- drag&drop not yet implemented
- background images not yet implemented