Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxTreeViewSearcher Class Reference

A QTreeView class based searcher. More...

#include <QtxSearchTool.h>

Inheritance diagram for QtxTreeViewSearcher:
Inheritance graph

Public Member Functions

 QtxTreeViewSearcher (QTreeView *, int=0)
 Constructor. More...
 
virtual ~QtxTreeViewSearcher ()
 Destructor. More...
 
int searchColumn () const
 Get column for which search is performed. More...
 
void setSearchColumn (int)
 Set column for which search should be performed. More...
 
virtual bool find (const QString &, QtxSearchTool *)
 Start new search. More...
 
virtual bool findNext (const QString &, QtxSearchTool *)
 Search next appropriate item. More...
 
virtual bool findPrevious (const QString &, QtxSearchTool *)
 Search previous appropriate item. More...
 
virtual bool findFirst (const QString &, QtxSearchTool *)
 Search first appropriate item. More...
 
virtual bool findLast (const QString &, QtxSearchTool *)
 Search last appropriate item. More...
 
- Public Member Functions inherited from QtxSearchTool::Searcher
 Searcher ()
 Constructor. More...
 
virtual ~Searcher ()
 Destructor. More...
 

Protected Member Functions

virtual Qt::MatchFlags matchFlags (QtxSearchTool *) const
 Get match flags to be used by the searcher. More...
 

Private Member Functions

QModelIndexList findItems (const QString &, QtxSearchTool *)
 Find all appropriate items. More...
 
QModelIndex findNearest (const QModelIndex &, const QModelIndexList &, bool)
 Find model index from the list nearest to the specified index. More...
 
void showItem (const QModelIndex &)
 Ensure the found item to become visible and selected. More...
 
QString getId (const QModelIndex &)
 Get unique item ID. More...
 
int compareIndices (const QModelIndex &, const QModelIndex &)
 Compare items. More...
 

Private Attributes

QTreeViewmyView
 
int myColumn
 
QPersistentModelIndex myIndex
 

Detailed Description

The class QtxTreeViewSearcher can be used to find the items in the QTreeView widget.

The column for which data should be searched can be get/set with the searchColumn(), setSearchColumn() methods. By default, column 0 is used.

Constructor & Destructor Documentation

QtxTreeViewSearcher::QtxTreeViewSearcher ( QTreeView view,
int  col = 0 
)
Parameters
viewtree view widget
colcolumn for which search to be performed (0 by default)
See Also
setSearchColumn()
QtxTreeViewSearcher::~QtxTreeViewSearcher ( )
virtual

Member Function Documentation

int QtxTreeViewSearcher::compareIndices ( const QModelIndex &  left,
const QModelIndex &  right 
)
private
Parameters
leftfirst model index to be compared
rightlast model index to be compared
Returns
0 if items are equal, negative value if left item is less than right one and positive value otherwise

References getId().

bool QtxTreeViewSearcher::find ( const QString &  text,
QtxSearchTool st 
)
virtual
Parameters
texttext to be found
stsearch tool widget
See Also
findNext(), findPrevious(), findFirst(), findLast()

Implements QtxSearchTool::Searcher.

References findItems(), findNearest(), QtxSearchTool::isSearchWrapped(), myView, and showItem().

bool QtxTreeViewSearcher::findFirst ( const QString &  text,
QtxSearchTool st 
)
virtual
Parameters
texttext to be found
stsearch tool widget
See Also
find(), findNext(), findPrevious(), findLast()

Implements QtxSearchTool::Searcher.

References findItems(), and showItem().

QModelIndexList QtxTreeViewSearcher::findItems ( const QString &  text,
QtxSearchTool st 
)
private
Parameters
texttext to be found
stsearch tool widget

References matchFlags(), myColumn, myView, and s.

bool QtxTreeViewSearcher::findLast ( const QString &  text,
QtxSearchTool st 
)
virtual
Parameters
texttext to be found
stsearch tool widget
See Also
find(), findNext(), findPrevious(), findFirst()

Implements QtxSearchTool::Searcher.

References findItems(), and showItem().

QModelIndex QtxTreeViewSearcher::findNearest ( const QModelIndex &  index,
const QModelIndexList &  lst,
bool  direction 
)
private
Parameters
indexmodel index for which a nearest item is searched
lstlist of model indices
directionif true find next appropriate item, otherwise find privious appropriate item

References compareIndices().

bool QtxTreeViewSearcher::findNext ( const QString &  text,
QtxSearchTool st 
)
virtual
Parameters
texttext to be found
stsearch tool widget
See Also
find(), findPrevious(), findFirst(), findLast()

Implements QtxSearchTool::Searcher.

References findItems(), findNearest(), QtxSearchTool::isSearchWrapped(), myIndex, myView, and showItem().

bool QtxTreeViewSearcher::findPrevious ( const QString &  text,
QtxSearchTool st 
)
virtual
Parameters
texttext to be found
stsearch tool widget
See Also
find(), findNext(), findFirst(), findLast()

Implements QtxSearchTool::Searcher.

References findItems(), findNearest(), QtxSearchTool::isSearchWrapped(), myIndex, myView, and showItem().

QString QtxTreeViewSearcher::getId ( const QModelIndex &  index)
private
Parameters
indexmodel index
Returns
item ID
Qt::MatchFlags QtxTreeViewSearcher::matchFlags ( QtxSearchTool st) const
protectedvirtual
Parameters
stsearch tool widget

References QtxSearchTool::isCaseSensitive(), and QtxSearchTool::isRegExpSearch().

int QtxTreeViewSearcher::searchColumn ( ) const
Returns
column number
See Also
setSearchColumn()

References myColumn.

void QtxTreeViewSearcher::setSearchColumn ( int  column)
Parameters
columncolumn number
See Also
searchColumn()

References myColumn.

void QtxTreeViewSearcher::showItem ( const QModelIndex &  index)
private
Parameters
indexitem to be shown

References myIndex, and myView.

Member Data Documentation

int QtxTreeViewSearcher::myColumn
private
QPersistentModelIndex QtxTreeViewSearcher::myIndex
private
QTreeView* QtxTreeViewSearcher::myView
private

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