Version: 6.3.1
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

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.
virtual ~QtxTreeViewSearcher ()
 Destructor.
int searchColumn () const
 Get column for which search is performed.
void setSearchColumn (int)
 Set column for which search should be performed.
virtual bool find (const QString &, QtxSearchTool *)
 Start new search.
virtual bool findNext (const QString &, QtxSearchTool *)
 Search next appropriate item.
virtual bool findPrevious (const QString &, QtxSearchTool *)
 Search previous appropriate item.
virtual bool findFirst (const QString &, QtxSearchTool *)
 Search first appropriate item.
virtual bool findLast (const QString &, QtxSearchTool *)
 Search last appropriate item.

Protected Member Functions

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

Private Member Functions

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

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::searchColumn ( ) const
Returns:
column number
See also:
setSearchColumn()

References myColumn.

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

References myColumn.

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(), test_table.l, myView, and showItem().

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(), test_table.l, 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(), test_table.l, myIndex, 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().

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

Qt::MatchFlags QtxTreeViewSearcher::matchFlags ( QtxSearchTool st) const [protected, virtual]
Parameters:
stsearch tool widget

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

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

References matchFlags(), myColumn, and myView.

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

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

References myIndex, and myView.

QString QtxTreeViewSearcher::getId ( const QModelIndex &  index) [private]
Parameters:
indexmodel index
Returns:
item ID
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().


Field Documentation

QPersistentModelIndex QtxTreeViewSearcher.myIndex [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS