• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KTreeWidgetSearchLine Class Reference

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

#include <ktreewidgetsearchline.h>

Inheritance diagram for KTreeWidgetSearchLine:
KLineEdit QLineEdit KCompletionBase

List of all members.

Public Slots

void addTreeWidget (QTreeWidget *treeWidget)
void removeTreeWidget (QTreeWidget *treeWidget)
void setCaseSensitivity (Qt::CaseSensitivity caseSensitivity)
void setKeepParentsVisible (bool value)
void setSearchColumns (const QList< int > &columns)
void setTreeWidget (QTreeWidget *treeWidget)
void setTreeWidgets (const QList< QTreeWidget * > &treeWidgets)
virtual void updateSearch (const QString &pattern=QString())

Signals

void hiddenChanged (QTreeWidgetItem *, bool)

Public Member Functions

Qt::CaseSensitivity caseSensitivity () const
bool keepParentsVisible () const
 KTreeWidgetSearchLine (QWidget *parent, const QList< QTreeWidget * > &treeWidgets)
 KTreeWidgetSearchLine (QWidget *parent=0, QTreeWidget *treeWidget=0)
QList< int > searchColumns () const
QTreeWidget * treeWidget () const
QList< QTreeWidget * > treeWidgets () const
virtual ~KTreeWidgetSearchLine ()

Protected Member Functions

virtual bool canChooseColumnsCheck ()
virtual void connectTreeWidget (QTreeWidget *)
virtual void contextMenuEvent (QContextMenuEvent *)
virtual void disconnectTreeWidget (QTreeWidget *)
virtual bool event (QEvent *event)
virtual bool itemMatches (const QTreeWidgetItem *item, const QString &pattern) const
virtual void updateSearch (QTreeWidget *treeWidget)

Properties

Qt::CaseSensitivity caseSensitity
bool keepParentsVisible

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.

Definition at line 38 of file ktreewidgetsearchline.h.


Constructor & Destructor Documentation

KTreeWidgetSearchLine::KTreeWidgetSearchLine ( QWidget *  parent = 0,
QTreeWidget *  treeWidget = 0 
) [explicit]

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

Definition at line 222 of file ktreewidgetsearchline.cpp.

KTreeWidgetSearchLine::KTreeWidgetSearchLine ( QWidget *  parent,
const QList< 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().

Definition at line 236 of file ktreewidgetsearchline.cpp.

KTreeWidgetSearchLine::~KTreeWidgetSearchLine (  )  [virtual]

Destroys the KTreeWidgetSearchLine.

Definition at line 247 of file ktreewidgetsearchline.cpp.


Member Function Documentation

void KTreeWidgetSearchLine::addTreeWidget ( QTreeWidget *  treeWidget  )  [slot]

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

Definition at line 288 of file ktreewidgetsearchline.cpp.

bool KTreeWidgetSearchLine::canChooseColumnsCheck (  )  [protected, virtual]

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

Definition at line 487 of file ktreewidgetsearchline.cpp.

Qt::CaseSensitivity KTreeWidgetSearchLine::caseSensitivity (  )  const

Returns true if the search is case sensitive.

This defaults to false.

See also:
setCaseSensitive()

Definition at line 252 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::connectTreeWidget ( QTreeWidget *  treeWidget  )  [protected, virtual]

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

Definition at line 469 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::contextMenuEvent ( QContextMenuEvent *  event  )  [protected, virtual]

Re-implemented for internal reasons.

API not affected.

Reimplemented from KLineEdit.

Definition at line 418 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::disconnectTreeWidget ( QTreeWidget *  treeWidget  )  [protected, virtual]

Disconnects signals of a listviews from the search line.

Definition at line 478 of file ktreewidgetsearchline.cpp.

bool KTreeWidgetSearchLine::event ( QEvent *  event  )  [protected, virtual]

Re-implemented for internal reasons.

API not affected.

Reimplemented from KLineEdit.

Definition at line 526 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::hiddenChanged ( QTreeWidgetItem *  ,
bool   
) [signal]

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

bool KTreeWidgetSearchLine::itemMatches ( const QTreeWidgetItem *  item,
const QString &  pattern 
) const [protected, virtual]

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.

Definition at line 392 of file ktreewidgetsearchline.cpp.

bool KTreeWidgetSearchLine::keepParentsVisible (  )  const

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

See also:
setKeepParentsVisible()
void KTreeWidgetSearchLine::removeTreeWidget ( QTreeWidget *  treeWidget  )  [slot]

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

Definition at line 300 of file ktreewidgetsearchline.cpp.

QList< int > KTreeWidgetSearchLine::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 257 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::setCaseSensitivity ( Qt::CaseSensitivity  caseSensitivity  )  [slot]

Make the search case sensitive or case insensitive.

See also:
caseSenstivity()

Definition at line 345 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::setKeepParentsVisible ( bool  value  )  [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.

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

Definition at line 353 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::setSearchColumns ( const QList< 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. If listviews to be filtered have different numbers or labels of columns this method has no effect.

See also:
searchColumns

Definition at line 361 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::setTreeWidget ( QTreeWidget *  treeWidget  )  [slot]

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

Definition at line 367 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::setTreeWidgets ( const QList< QTreeWidget * > &  treeWidgets  )  [slot]

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

Definition at line 373 of file ktreewidgetsearchline.cpp.

QTreeWidget * KTreeWidgetSearchLine::treeWidget (  )  const

Returns the listview that is currently filtered by the search.

If there are multiple listviews filtered, it returns 0.

See also:
setTreeWidget(), treeWidgets()

Definition at line 270 of file ktreewidgetsearchline.cpp.

QList< QTreeWidget * > KTreeWidgetSearchLine::treeWidgets (  )  const

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

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

Definition at line 278 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::updateSearch ( QTreeWidget *  treeWidget  )  [protected, virtual]

Updates search to only make visible appropriate items in treeWidget.

If treeWidget is null then nothing is done.

Definition at line 324 of file ktreewidgetsearchline.cpp.

void KTreeWidgetSearchLine::updateSearch ( const QString &  pattern = QString()  )  [virtual, slot]

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

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

Definition at line 316 of file ktreewidgetsearchline.cpp.


Property Documentation

Qt::CaseSensitivity KTreeWidgetSearchLine::caseSensitity [read, write]

Definition at line 42 of file ktreewidgetsearchline.h.

bool KTreeWidgetSearchLine::keepParentsVisible [read, write]

Definition at line 43 of file ktreewidgetsearchline.h.


The documentation for this class was generated from the following files:
  • ktreewidgetsearchline.h
  • ktreewidgetsearchline.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal