KListViewSearchLine Class Reference

`#include <klistviewsearchline.h>`

Inheritance diagram for KListViewSearchLine:

## Public Slots

virtual void | updateSearch (const QString &s=QString::null)
void | setCaseSensitive (bool cs)
void | setKeepParentsVisible (bool v)
void | setSearchColumns (const QValueList< int > &columns)
void | setListView (KListView *lv)
Public Slots inherited from KLineEdit
virtual void | setReadOnly (bool)
void | rotateText (KCompletionBase::KeyBindingType type)
virtual void | setCompletedText (const QString &)
void | setCompletedItems (const QStringList &items)
void | setCompletedItems (const QStringList &items, bool autoSuggest)
virtual void | clear ()
void | setSqueezedText (const QString &text)
virtual void | setText (const QString &)

## Public Member Functions

| KListViewSearchLine (QWidget *parent=0, KListView *listView=0, const char *name=0)
| KListViewSearchLine (QWidget *parent, const char *name)
virtual | ~KListViewSearchLine ()
bool | caseSensitive () const
QValueList< int > | searchColumns () const
bool | keepParentsVisible () const
KListView * | listView () const
Public Member Functions inherited from KLineEdit
| KLineEdit (const QString &string, QWidget *parent, const char *name=0)
| KLineEdit (QWidget *parent=0, const char *name=0)
virtual | ~KLineEdit ()
void | setURL (const KURL &url)
void | cursorAtEnd ()
virtual void | setCompletionMode (KGlobalSettings::Completion mode)
virtual void | setContextMenuEnabled (bool showMenu)
bool | isContextMenuEnabled () const
void | setURLDropsEnabled (bool enable)
bool | isURLDropsEnabled () const
void | setTrapReturnKey (bool trap)
bool | trapReturnKey () const
virtual bool | eventFilter (QObject *, QEvent *)
KCompletionBox * | completionBox (bool create=true)
virtual void | setCompletionObject (KCompletion *, bool hsig=true)
virtual void | copy () const
void | setEnableSqueezedText (bool enable)
bool | isSqueezedTextEnabled () const
QString | originalText () const
void | setCompletionBox (KCompletionBox *box)
void | setClickMessage (const QString &msg)
QString | clickMessage () const
Public Member Functions inherited from KCompletionBase
KCompletion * | completionObject (bool hsig=true)
virtual void | setHandleSignals (bool handle)
bool | isCompletionObjectAutoDeleted () const
void | setAutoDeleteCompletionObject (bool autoDelete)
void | setEnableSignals (bool enable)
bool | handleSignals () const
bool | emitSignals () const
KGlobalSettings::Completion | completionMode () const
bool | setKeyBinding (KeyBindingType item, const KShortcut &key)
const KShortcut & | getKeyBinding (KeyBindingType item) const
void | useGlobalKeyBindings ()
virtual void | setCompletedText (const QString &text)=0
virtual void | setCompletedItems (const QStringList &items)=0
KCompletion * | compObj () const

## Protected Slots

void | queueSearch (const QString &search)
void | activateSearch ()
Protected Slots inherited from KLineEdit
virtual void | makeCompletion (const QString &)
void | slotAboutToShow ()
void | slotCancelled ()
void | userCancelled (const QString &cancelText)

## Protected Member Functions

virtual bool | itemMatches (const QListViewItem *item, const QString &s) const
virtual QPopupMenu * | createPopupMenu ()
Protected Member Functions inherited from KLineEdit
virtual void | resizeEvent (QResizeEvent *)
virtual void | keyPressEvent (QKeyEvent *)
virtual void | mousePressEvent (QMouseEvent *)
virtual void | mouseDoubleClickEvent (QMouseEvent *)
virtual void | mouseReleaseEvent (QMouseEvent *)
virtual void | contextMenuEvent (QContextMenuEvent *)
virtual void | drawContents (QPainter *p)
virtual void | dropEvent (QDropEvent *)
virtual void | setCompletedText (const QString &, bool)
void | setUserSelection (bool userSelection)
virtual void | create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
virtual void | focusInEvent (QFocusEvent *)
virtual void | focusOutEvent (QFocusEvent *)
bool | autoSuggest () const
virtual void | virtual_hook (int id, void *data)
Protected Member Functions inherited from KCompletionBase
KeyBindingMap | getKeyBindings () const
void | setDelegate (KCompletionBase *delegate)
KCompletionBase * | delegate () const

## Additional Inherited Members

Public Types inherited from KCompletionBase
enum | KeyBindingType
Signals inherited from KLineEdit
void | completionBoxActivated (const QString &)
void | returnPressed (const QString &)
void | completion (const QString &)
void | substringCompletion (const QString &)
void | textRotation (KCompletionBase::KeyBindingType)
void | completionModeChanged (KGlobalSettings::Completion)
void | aboutToShowContextMenu (QPopupMenu *p)
Properties inherited from KLineEdit
bool | contextMenuEnabled
bool | urlDropsEnabled
bool | trapEnterKeyEvent
bool | enableSqueezedText
QString | clickMessage

## Detailed Description

This class makes it easy to add a search line for filtering the items in a listview based on a simple text search.

No changes to the application other than instantiating this class with an appropriate KListView should be needed.

If you want the clear button and the search label, you should take a look at the KListViewSearchLineWidget

Note
  { When iterating over items in the KListView, make sure that the iterator only includes visible items (for example, by adding QListViewItemIterator::Visible to the iterator flags). Otherwise, actions (such as deletion) may be taken on items that have been hidden by the search function. }

Since
  3.3

Definition at line 47 of file klistviewsearchline.h.

## Constructor & Destructor Documentation

KListViewSearchLine::KListViewSearchLine | ( | QWidget * | parent = `0`,
|  | KListView * | listView = `0`,
|  | const char * | name = `0`
| ) |  |

Constructs a KListViewSearchLine with listView being the KListView to be filtered.

If listView is null then the widget will be disabled until a listview is set with setListView().

Definition at line 59 of file klistviewsearchline.cpp.

KListViewSearchLine::KListViewSearchLine | ( | QWidget * | parent,
|  | const char * | name
| ) |  |

Constructs a KListViewSearchLine without any KListView to filter.

The KListView object has to be set later with setListView().

Definition at line 80 of file klistviewsearchline.cpp.

KListViewSearchLine::~KListViewSearchLine | ( |  | ) |

virtual

Destroys the KListViewSearchLine.

Definition at line 93 of file klistviewsearchline.cpp.

## Member Function Documentation

void KListViewSearchLine::activateSearch | ( |  | ) |

protected slot

When the timer started with queueSearch() expires this slot is called.

If there has been another timer started then this slot does nothing. However if there are no other pending searches this starts the list view search.

See also
  queueSearch()

Definition at line 291 of file klistviewsearchline.cpp.

bool KListViewSearchLine::caseSensitive | ( |  | ) | const

Returns true if the search is case sensitive.

This defaults to false.

See also
  setCaseSensitive()

Definition at line 98 of file klistviewsearchline.cpp.

QPopupMenu * KListViewSearchLine::createPopupMenu | ( |  | ) |

protected virtual

Re-implemented for internal reasons.

API not affected.

See QLineEdit::mousePressEvent().

Reimplemented from KLineEdit.

Definition at line 234 of file klistviewsearchline.cpp.

bool KListViewSearchLine::itemMatches | ( | const QListViewItem * | item,
|  | const QString & | s
| ) |  | const

protected virtual

Returns true if item matches the search s.

This will be evaluated based on the value of caseSensitive(). This can be overridden in subclasses to implement more complicated matching schemes.

Definition at line 205 of file klistviewsearchline.cpp.

bool KListViewSearchLine::keepParentsVisible | ( |  | ) | const

If this is true (the default) then the parents of matched items will also be shown.

See also
  setKeepParentsVisible()

Definition at line 108 of file klistviewsearchline.cpp.

KListView * KListViewSearchLine::listView | ( |  | ) | const

Returns the listview that is currently filtered by the search.

See also
  setListView()

Definition at line 113 of file klistviewsearchline.cpp.

void KListViewSearchLine::queueSearch | ( | const QString & | search | ) |

protected slot

When keys are pressed a new search string is created and a timer is activated.

The most recent search is activated when this timer runs out if another key has not yet been pressed.

This method makes

Parameters

  search | the most recent search and starts the timer.

Together with activateSearch() this makes it such that searches are not started until there is a short break in the users typing.

See also
  activateSearch()

Definition at line 284 of file klistviewsearchline.cpp.

QValueList< int > KListViewSearchLine::searchColumns | ( |  | ) | const

Returns the current list of columns that will be searched.

If the returned list is empty all visible columns will be searched.

See also
  setSearchColumns

Definition at line 103 of file klistviewsearchline.cpp.

void KListViewSearchLine::setCaseSensitive | ( | bool | cs | ) |

slot

Make the search case sensitive or case insensitive.

See also
  caseSenstive()

Definition at line 163 of file klistviewsearchline.cpp.

void KListViewSearchLine::setKeepParentsVisible | ( | bool | v | ) |

slot

When a search is active on a list that's organized into a tree view if a parent or ancesestor of an item is does not match the search then it will be hidden and as such so too will any children that match.

If this is set to true (the default) then the parents of matching items will be shown.

See also
  keepParentsVisible

Definition at line 168 of file klistviewsearchline.cpp.

void KListViewSearchLine::setListView | ( | KListView * | lv | ) |

slot

Sets the KListView that is filtered by this search line.

If lv is null then the widget will be disabled.

See also
  listView()

Definition at line 178 of file klistviewsearchline.cpp.

void KListViewSearchLine::setSearchColumns | ( | const QValueList< int > & | columns | ) |

slot

Sets the list of columns to be searched.

The default is to search all, visible columns which can be restored by passing columns as an empty list.

See also
  searchColumns

Definition at line 173 of file klistviewsearchline.cpp.

void KListViewSearchLine::updateSearch | ( | const QString & | s = `QString::null` | ) |

virtual slot

Updates search to only make visible the items that match s.

If s is null then the line edit's text will be used.

Definition at line 122 of file klistviewsearchline.cpp.

The documentation for this class was generated from the following files:

- klistviewsearchline.h
- klistviewsearchline.cpp

KDE Home | KDE Accessibility Home | Description of Access Keys