KViewSearchLine - searchline for iterview

Daniel Teske teske at squorn.de
Thu Aug 25 04:50:03 BST 2005

Hi all,

I've tried to write a KListViewSearchLine which leverages Qt4's 
model/view framework. 
The patch kviewsearchline.patch is my current state. It almost 
completely reimplements KListViewSearchLine.
AFAIK the only missing feature is that KListViewSearchLine tried to keep 
the current item in the view port.

I would like to have other people comment on the code and possible api improvments. (Currently it matches the KDE3 api.)

The class (currently named KViewSearchLine) works with both QTreeView 
and QListView and their derived classes QListWidget and QTreeWidget. 
Note: I haven't really tested anything beside QTreeView, but in typical programmer's
hubris, I belive that it works with them, too. 

The main effect of using the interview framework is:
It automatically updates the shown/hidden state of the items on
dataChanged(), rowsRemoved(), rowsInserted(), reset(), columnsInserted() and columnsRemoved() [1]

Note: The algorithms to decide if the parents of changed items need to be hidden/shown aren't optimized.
They aren't stupid, either, but there probably is room for improvment.

While using one class for both QListView an QTreeView looked like a good 
idea before I started, the actual implementation turned out to be 
complexer than expected. (Pratically all the code in KViewSearchLine deals with the QTreeView case.)
And as KViewSearchLine is intended as a possible base class, any unecessary complexity inside itemMatches() is bad.
I'm still undecided if that is reason enough to split the class into two distinct classes for QListView and QTreeView.
(Advice would be nice.)

There is one issue left, where I need help:
Is there any guarantee about the order in which slots are called? I rely on the order beeing the same as the order in which the slots were connected to the signal.

If you want to test the searchline appply keb-searchline.patch in kdebase/konqueror/keditbookmarks.

If you are intrested in using interview, you probably should visit:
I've written down some of the stranger things/bugs of the interview framework. (And I try to update it as I find new things.)

daniel teske

[1] Unfourtanely if after removing rows no children of a parent and the parent itself don't match and thus the parent is hid, you expose a Qt bug, which leads to a crash.
See http://www.squorn.de/kde/qtmodelview.html for details
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kviewsearchline.patch
Type: text/x-diff
Size: 33362 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050825/e6387d67/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keb-searchline.patch
Type: text/x-diff
Size: 2488 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050825/e6387d67/attachment-0001.patch>

More information about the kde-core-devel mailing list