KSortFilterProxyModel
Stephen Kelly
steveire at gmail.com
Mon Jul 20 12:58:39 BST 2009
Aaron J. Seigo wrote:
> On Tuesday 30 June 2009, John Tapsell wrote:
>> I added a KSortFilterProxyModel to kdelibs/kdeui/itemviews that
>> inherits QSortFilterProxyModel and provides a way to allow
>> KFilterProxySearchLine to work on trees. So it allows you to add a
>> Search box to a QTreeView with a model.
>
> great, i think we have a couple places we can use that in plasma as well.
> but quick question: did this go through any API review?
>
Hi,
I've just had a look.
The filtering behaviour seems a bit odd to me.
Considering a tree like this:
A
B
- C
- - D
- - - E
- - - - F
- G
- H
- - I
- - - J
If you try to match 'J', you'll get 'B' and everything under it including D,
E, F, right? Not what I'd expect. It's even more wierd if you start match
with a start index other than row 0.
I think what you might want to use is KDescendantsProxyModel. I've been
using a predecessor of it in the KJots Link dialog for about a year for
matching books and pages in a tree. It turns the tree into a flat list which
you can then match against and get the hits you want.
If this class is going to stick around, the name KSortFilterProxyModel isn't
the best, because that implies that it's the class you should always use in
KDE apps where otherwise a QSortFilterProxyModel would be used. This is
something dfaure brought up with me when I tried to do something similar
(which also had no effect by default.) Not sure if it's a big deal. Maybe
KTreeFilterProxyModel?
Finally, I think you have the wrong copyright in the .cpp file.
All the best,
Steve.
More information about the kde-core-devel
mailing list