Say "hello" to categorization on list views

Rafael Fernández López ereslibre at gmail.com
Mon Feb 19 19:15:36 GMT 2007


2007/2/19, Aaron J. Seigo <aseigo at kde.org>:
>
> On February 18, 2007, Rafael Fernández López wrote:
> > As some users (and myself too) missed the categorization powerful tool
> for
> > Konqueror/Dolphin and similars, I've started a bit on it. This new class
> > (attached) is right now locally at kdeui/itemviews. The idea is that the
> > list view, should inherit from this class, and of course, rewrite the
> > method. This particularly is useful on the new class I'm writing:
> > KListView. KListView will give all the benefits for drawing categorized
> > items in the viewport, so a new list view that wants to add own
> > categorization, the only thing have to do is inherit KListView and
> rewrite
> > this method. As easy as that. On paintEvent() method at KListView, the
> > model() will be asked if it is really a QSortFilterProxyModel. If so, it
> > will ask this method with the corresponding
> > QSortFilterProxyModel::sortRole() method.
>
> sounds like a lot of subclassing, particularly if there are N different
> views
> that subclass KItemCategorization (KItemCategorizer?) as then one would
> need
> to subclass each listview for each type of categorization (or have one
> categorizer that does all kinds of categorizations?)


The main idea is that:

class KListView
    : public QListView
    , public KItemCategorization

so another list views that want to change the categorization will inherit
from KListView (where the method is virtual, and returns a QString() by
default), and override that method.

would it be cleaner to simply expect one to sub-class KItemCategorization
> and
> have a setCategorizer(const KItemCategorization& categorizer) method in
> the
> listviews? that way one could write categorizers for each type of data set
> (e.g. one for photos vs one for eBooks or whatever) as desired and re-use
> them with whatever listviews support that categorization. this prevents
> destroying and creating listviews just to change the categorization and
> would
> allow greater re-use of categorization code.
>
> one could also have setCategorizer take a pointer instead of a reference
> and
> take ownership of the object if that's easier ... though pointers are a
> bit
> uglier, they can be easier to test for and "clear" (pass in 0)..
>
> also, the screenshot you provided is from windows. do you have a shot of
> it
> working in kde? (just curious =)


I haven't written paintEvent to take in count this yet. I have to start it
when have a bit more time (by the end of this week). This needs some
thinking too, for having in count right-to-left languages.


Bye,
Rafael Fernández López.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070219/eacb1846/attachment.htm>


More information about the kde-core-devel mailing list