KDE 4.9 PyKDE API Reference

- KDE's Python API

# KTreeWidgetSearchLine Class Reference

`from PyKDE4.kdeui import *`

Inherits: KLineEdit → QLineEdit → QWidget → QObject

## Detailed Description

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.

## Signals

| hiddenChanged (QTreeWidgetItem a0, bool a1)

## Methods

| __init__ (self, QWidget parent=0, QTreeWidget treeWidget=0)
| __init__ (self, QWidget parent, [QTreeWidget] treeWidgets)
| addTreeWidget (self, QTreeWidget treeWidget)
bool | canChooseColumnsCheck (self)
Qt::CaseSensitivity | caseSensitivity (self)
| connectTreeWidget (self, QTreeWidget a0)
| contextMenuEvent (self, QContextMenuEvent a0)
| disconnectTreeWidget (self, QTreeWidget a0)
bool | event (self, QEvent event)
bool | itemMatches (self, QTreeWidgetItem item, QString pattern)
bool | keepParentsVisible (self)
| removeTreeWidget (self, QTreeWidget treeWidget)
[int] | searchColumns (self)
| setCaseSensitivity (self, Qt::CaseSensitivity caseSensitivity)
| setKeepParentsVisible (self, bool value)
| setSearchColumns (self, [int] columns)
| setTreeWidget (self, QTreeWidget treeWidget)
| setTreeWidgets (self, [QTreeWidget] treeWidgets)
QTreeWidget | treeWidget (self)
[QTreeWidget] | treeWidgets (self)
| updateSearch (self, QString pattern=QString())
| updateSearch (self, QTreeWidget treeWidget)

## Signal Documentation

hiddenChanged | ( | QTreeWidgetItem | a0,
|  | bool | a1
| ) |  |  |

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

Signal syntax:
  `QObject.connect(source, SIGNAL("hiddenChanged(QTreeWidgetItem*, bool)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0,
|  | QTreeWidget | treeWidget=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().

__init__ | ( | self, |
|  | QWidget | parent,
|  | [QTreeWidget] | treeWidgets
| ) |  |  |

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().

addTreeWidget | ( | self, |
|  | QTreeWidget | treeWidget
| ) |  |  |

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()

bool canChooseColumnsCheck | ( |  | self ) |

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()

Qt::CaseSensitivity caseSensitivity | ( |  | self ) |

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

See also:
  setCaseSensitive()

connectTreeWidget | ( | self, |
|  | QTreeWidget | a0
| ) |  |  |

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

contextMenuEvent | ( | self, |
|  | QContextMenuEvent | a0
| ) |  |  |

Re-implemented for internal reasons. API not affected.

disconnectTreeWidget | ( | self, |
|  | QTreeWidget | a0
| ) |  |  |

Disconnects signals of a listviews from the search line.

bool event | ( | self, |
|  | QEvent | event
| ) |  |  |

Re-implemented for internal reasons. API not affected.

bool itemMatches | ( | self, |
|  | QTreeWidgetItem | item,
|  | QString | pattern
| ) |  |  |

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.

bool keepParentsVisible | ( |  | self ) |

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

See also:
  setKeepParentsVisible()

removeTreeWidget | ( | self, |
|  | QTreeWidget | treeWidget
| ) |  |  |

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()

[int] searchColumns | ( |  | self ) |

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 | ( | self, |
|  | Qt::CaseSensitivity | caseSensitivity
| ) |  |  |

Make the search case sensitive or case insensitive.

See also:
  caseSenstivity()

setKeepParentsVisible | ( | self, |
|  | bool | value
| ) |  |  |

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.

Warning:
  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 | ( | self, |
|  | [int] | columns
| ) |  |  |

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 | ( | self, |
|  | QTreeWidget | treeWidget
| ) |  |  |

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 | ( | self, |
|  | [QTreeWidget] | treeWidgets
| ) |  |  |

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()

QTreeWidget treeWidget | ( |  | self ) |

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

See also:
  setTreeWidget(), treeWidgets()

[QTreeWidget] treeWidgets | ( |  | self ) |

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

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

updateSearch | ( | self, |
|  | QString | pattern=QString()
| ) |  |  |

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

updateSearch | ( | self, |
|  | QTreeWidget | treeWidget
| ) |  |  |

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