# class KTreeWidgetSearchLine

###

Module | kdeui
Namespace |
Class | KTreeWidgetSearchLine
Inherits | KLineEdit

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

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

### methods

- KTreeWidgetSearchLine (parent, treeWidget)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0
  treeWidget | QTreeWidget | 0

  Constructs a KTreeWidgetSearchLine with treeWidget being the QTreeWidget to be filtered.

  If treeWidget is null then the widget will be disabled until listviews are set with setTreeWidget(), setTreeWidgets() or added with addTreeWidget().

- KTreeWidgetSearchLine (parent, treeWidgets)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget |
  treeWidgets | QList<QTreeWidget |

  Constructs a KTreeWidgetSearchLine with treeWidgets being the list of pointers to QTreeWidgets to be filtered.

  If treeWidgets is empty then the widget will be disabled until listviews are set with setTreeWidget(), setTreeWidgets() or added with addTreeWidget().

- KTreeWidgetSearchLine (a0, a1)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0
  a1 | QTreeWidget | 0

- addTreeWidget (treeWidget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  treeWidget | QTreeWidget |

  Adds a QTreeWidget to the list of listviews filtered by this search line. If treeWidget is null then the widget will be disabled.

  See also treeWidget(), setTreeWidgets(), removeTreeWidget()

- canChooseColumnsCheck ( )

  returns bool

  Checks columns in all listviews and decides whether choosing columns to filter on makes any sense.

  Returns false if either of the following is true: * there are no listviews connected, * the listviews have different numbers of columns, * the listviews have only one column, * the listviews differ in column labels.

  Otherwise it returns true.

  See also setSearchColumns()

- caseSensitivity ( )

  returns Qt.CaseSensitivity

  Returns true if the search is case sensitive. This defaults to false.

  See also setCaseSensitive()

- connectTreeWidget (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QTreeWidget |

  Connects signals of this listview to the appropriate slots of the search line.

- contextMenuEvent (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QContextMenuEvent |

  Re-implemented for internal reasons. API not affected.

- disconnectTreeWidget (a0)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  a0 | QTreeWidget |

  Disconnects signals of a listviews from the search line.

- event (event)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  event | QEvent |

  Re-implemented for internal reasons. API not affected.

- hiddenChanged (a0, a1)

  returns Nothing
  SIGNAL ("hiddenChanged (QTreeWidgetItem*, bool)")

  Argument | Type | Default
  --- | --- | ---
  a0 | QTreeWidgetItem |
  a1 | bool |

  This signal is emitted whenever an item gets hidden or unhidden due to it not matching or matching the search string.

- itemMatches (item, pattern)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  item | QTreeWidgetItem |
  pattern | QString |

  Returns true if item matches the search pattern. This will be evaluated based on the value of caseSensitive(). This can be overridden in subclasses to implement more complicated matching schemes.

- keepParentsVisible ( )

  returns bool

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

  See also setKeepParentsVisible()

- removeTreeWidget (treeWidget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  treeWidget | QTreeWidget |

  Removes a QTreeWidget from the list of listviews filtered by this search line. Does nothing if treeWidget is 0 or is not filtered by the quick search line.

  See also listVew(), setTreeWidgets(), addTreeWidget()

- searchColumns ( )

  returns QList<int>

  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

- setCaseSensitivity (caseSensitivity)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  caseSensitivity | Qt.CaseSensitivity |

  Make the search case sensitive or case insensitive.

  See also caseSenstivity()

- setKeepParentsVisible (value)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  value | bool |

  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.

  setKeepParentsVisible(true) does not have the expected effect on items being added to or removed from the view while a search is active. When a new search starts afterwards the behavior will be normal.

  See also keepParentsVisible

- setSearchColumns (columns)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  columns | QList<int> |

  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. If listviews to be filtered have different numbers or labels of columns this method has no effect.

  See also searchColumns

- setTreeWidget (treeWidget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  treeWidget | QTreeWidget |

  Sets the QTreeWidget that is filtered by this search line, replacing any previously filtered listviews. If treeWidget is null then the widget will be disabled.

  See also treeWidget(), setTreeWidgets()

- setTreeWidgets (treeWidgets)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  treeWidgets | QList<QTreeWidget |

  Sets QTreeWidgets that are filtered by this search line, replacing any previously filtered listviews. If treeWidgets is empty then the widget will be disabled.

  See also treeWidgets(), addTreeWidget(), setTreeWidget()

- treeWidget ( )

  returns QTreeWidget

  Returns the listview that is currently filtered by the search. If there are multiple listviews filtered, it returns 0.

  See also setTreeWidget(), treeWidgets()

- treeWidgets ( )

  returns QList<QTreeWidget

  Returns the list of pointers to listviews that are currently filtered by the search.

  See also setTreeWidgets(), addTreeWidget(), treeWidget()

- updateSearch (pattern)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  pattern | QString | QString()

  Updates search to only make visible the items that match pattern. If s is null then the line edit's text will be used.

- updateSearch (treeWidget)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  treeWidget | QTreeWidget |

  Updates search to only make visible appropriate items in treeWidget. If treeWidget is null then nothing is done.