Plasma
KTreeViewSearchLine Class Reference
#include <ktreeviewsearchline.h>

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 QTreeViews should be needed.
Definition at line 38 of file ktreeviewsearchline.h.
Public Slots | |
void | addTreeView (QTreeView *treeView) |
void | removeTreeView (QTreeView *treeView) |
void | setCaseSensitivity (Qt::CaseSensitivity caseSensitivity) |
void | setKeepParentsVisible (bool value) |
void | setSearchColumns (const QList< int > &columns) |
void | setTreeView (QTreeView *treeView) |
void | setTreeViews (const QList< QTreeView * > &treeViews) |
virtual void | updateSearch (const QString &pattern=QString()) |
Public Member Functions | |
Qt::CaseSensitivity | caseSensitivity () const |
bool | keepParentsVisible () const |
KTreeViewSearchLine (QWidget *parent, const QList< QTreeView * > &treeViews) | |
KTreeViewSearchLine (QWidget *parent=0, QTreeView *treeView=0) | |
QList< int > | searchColumns () const |
QTreeView * | treeView () const |
QList< QTreeView * > | treeViews () const |
virtual | ~KTreeViewSearchLine () |
Protected Slots | |
void | activateSearch () |
void | queueSearch (const QString &search) |
Protected Member Functions | |
virtual bool | canChooseColumnsCheck () |
virtual void | connectTreeView (QTreeView *) |
virtual void | contextMenuEvent (QContextMenuEvent *) |
virtual void | disconnectTreeView (QTreeView *) |
virtual bool | itemMatches (const QModelIndex &item, int row, const QString &pattern) const |
virtual void | updateSearch (QTreeView *treeView) |
Properties | |
Qt::CaseSensitivity | caseSensitity |
bool | keepParentsVisible |
Constructor & Destructor Documentation
KTreeViewSearchLine::KTreeViewSearchLine | ( | QWidget * | parent = 0 , |
|
QTreeView * | treeView = 0 | |||
) | [explicit] |
Constructs a KTreeViewSearchLine with treeView being the QTreeView to be filtered.
If treeView is null then the widget will be disabled until listviews are set with setTreeView(), setTreeViews() or added with addTreeView().
Definition at line 211 of file ktreeviewsearchline.cpp.
KTreeViewSearchLine::KTreeViewSearchLine | ( | QWidget * | parent, | |
const QList< QTreeView * > & | treeViews | |||
) |
Constructs a KTreeViewSearchLine with treeViews being the list of pointers to QTreeViews to be filtered.
If treeViews is empty then the widget will be disabled until listviews are set with setTreeView(), setTreeViews() or added with addTreeView().
Definition at line 225 of file ktreeviewsearchline.cpp.
KTreeViewSearchLine::~KTreeViewSearchLine | ( | ) | [virtual] |
Member Function Documentation
void KTreeViewSearchLine::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 533 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::addTreeView | ( | QTreeView * | treeView | ) | [slot] |
Adds a QTreeView to the list of listviews filtered by this search line.
If treeView is null then the widget will be disabled.
- See also:
- treeView(), setTreeViews(), removeTreeView()
Definition at line 277 of file ktreeviewsearchline.cpp.
bool KTreeViewSearchLine::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 482 of file ktreeviewsearchline.cpp.
Qt::CaseSensitivity KTreeViewSearchLine::caseSensitivity | ( | ) | const |
Returns true if the search is case sensitive.
This defaults to false.
- See also:
- setCaseSensitive()
Definition at line 241 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::connectTreeView | ( | QTreeView * | treeView | ) | [protected, virtual] |
Connects signals of this listview to the appropriate slots of the search line.
Definition at line 464 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::contextMenuEvent | ( | QContextMenuEvent * | event | ) | [protected, virtual] |
Re-implemented for internal reasons.
API not affected.
Definition at line 413 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::disconnectTreeView | ( | QTreeView * | treeView | ) | [protected, virtual] |
Disconnects signals of a listviews from the search line.
Definition at line 473 of file ktreeviewsearchline.cpp.
bool KTreeViewSearchLine::itemMatches | ( | const QModelIndex & | item, | |
int | row, | |||
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 384 of file ktreeviewsearchline.cpp.
bool KTreeViewSearchLine::keepParentsVisible | ( | ) | const |
If this is true (the default) then the parents of matched items will also be shown.
- See also:
- setKeepParentsVisible()
void KTreeViewSearchLine::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.
- See also:
- activateSearch()
Definition at line 525 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::removeTreeView | ( | QTreeView * | treeView | ) | [slot] |
Removes a QTreeView from the list of listviews filtered by this search line.
Does nothing if treeView is 0 or is not filtered by the quick search line.
- See also:
- listVew(), setTreeView(), addTreeView()
Definition at line 289 of file ktreeviewsearchline.cpp.
QList< int > KTreeViewSearchLine::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 246 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::setCaseSensitivity | ( | Qt::CaseSensitivity | caseSensitivity | ) | [slot] |
Make the search case sensitive or case insensitive.
- See also:
- caseSenstivity()
Definition at line 337 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::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.
- See also:
- keepParentsVisible
Definition at line 345 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::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 353 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::setTreeView | ( | QTreeView * | treeView | ) | [slot] |
Sets the QTreeView that is filtered by this search line, replacing any previously filtered listviews.
If treeView is null then the widget will be disabled.
- See also:
- treeView(), setTreeViews()
Definition at line 359 of file ktreeviewsearchline.cpp.
Sets QTreeViews that are filtered by this search line, replacing any previously filtered listviews.
If treeViews is empty then the widget will be disabled.
- See also:
- treeViews(), addTreeView(), setTreeView()
Definition at line 365 of file ktreeviewsearchline.cpp.
QTreeView * KTreeViewSearchLine::treeView | ( | ) | const |
Returns the listview that is currently filtered by the search.
If there are multiple listviews filtered, it returns 0.
- See also:
- setTreeView(), treeView()
Definition at line 259 of file ktreeviewsearchline.cpp.
Returns the list of pointers to listviews that are currently filtered by the search.
- See also:
- setTreeViews(), addTreeView(), treeView()
Definition at line 267 of file ktreeviewsearchline.cpp.
void KTreeViewSearchLine::updateSearch | ( | QTreeView * | treeView | ) | [protected, virtual] |
Updates search to only make visible appropriate items in treeView.
If treeView is null then nothing is done.
Definition at line 313 of file ktreeviewsearchline.cpp.
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 305 of file ktreeviewsearchline.cpp.
Property Documentation
Qt::CaseSensitivity KTreeViewSearchLine::caseSensitity [read, write] |
Definition at line 42 of file ktreeviewsearchline.h.
bool KTreeViewSearchLine::keepParentsVisible [read, write] |
Definition at line 43 of file ktreeviewsearchline.h.
The documentation for this class was generated from the following files: