Version: 9.15.0
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

A QTreeView class based searcher.

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::QtxTreeViewSearcher ( QTreeView view,
int  col = 0 
)

Constructor.

Parameters
viewtree view widget
colcolumn for which search to be performed (0 by default)
See also
setSearchColumn()

◆ ~QtxTreeViewSearcher()

QtxTreeViewSearcher::~QtxTreeViewSearcher ( )
virtual

Destructor.

Member Function Documentation

◆ compareIndices()

int QtxTreeViewSearcher::compareIndices ( const QModelIndex &  left,
const QModelIndex &  right 
)
private

Compare items.

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

◆ find()

bool QtxTreeViewSearcher::find ( const QString &  text,
QtxSearchTool st 
)
virtual

Start new search.

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

◆ findFirst()

bool QtxTreeViewSearcher::findFirst ( const QString &  text,
QtxSearchTool st 
)
virtual

Search first appropriate item.

Parameters
texttext to be found
stsearch tool widget
See also
find(), findNext(), findPrevious(), findLast()

Implements QtxSearchTool::Searcher.

References findItems(), and showItem().

◆ findItems()

QModelIndexList QtxTreeViewSearcher::findItems ( const QString &  text,
QtxSearchTool st 
)
private

Find all appropriate items.

Parameters
texttext to be found
stsearch tool widget

References matchFlags(), myColumn, and myView.

◆ findLast()

bool QtxTreeViewSearcher::findLast ( const QString &  text,
QtxSearchTool st 
)
virtual

Search last appropriate item.

Parameters
texttext to be found
stsearch tool widget
See also
find(), findNext(), findPrevious(), findFirst()

Implements QtxSearchTool::Searcher.

References findItems(), and showItem().

◆ findNearest()

QModelIndex QtxTreeViewSearcher::findNearest ( const QModelIndex &  index,
const QModelIndexList &  lst,
bool  direction 
)
private

Find model index from the list nearest to the specified index.

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

◆ findNext()

bool QtxTreeViewSearcher::findNext ( const QString &  text,
QtxSearchTool st 
)
virtual

Search next appropriate item.

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

◆ findPrevious()

bool QtxTreeViewSearcher::findPrevious ( const QString &  text,
QtxSearchTool st 
)
virtual

Search previous appropriate item.

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

◆ getId()

QString QtxTreeViewSearcher::getId ( const QModelIndex &  index)
private

Get unique item ID.

Parameters
indexmodel index
Returns
item ID

◆ matchFlags()

Qt::MatchFlags QtxTreeViewSearcher::matchFlags ( QtxSearchTool st) const
protectedvirtual

Get match flags to be used by the searcher.

Parameters
stsearch tool widget

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

◆ searchColumn()

int QtxTreeViewSearcher::searchColumn ( ) const

Get column for which search is performed.

Returns
column number
See also
setSearchColumn()

References myColumn.

◆ setSearchColumn()

void QtxTreeViewSearcher::setSearchColumn ( int  column)

Set column for which search should be performed.

Parameters
columncolumn number
See also
searchColumn()

References myColumn.

◆ showItem()

void QtxTreeViewSearcher::showItem ( const QModelIndex &  index)
private

Ensure the found item to become visible and selected.

Parameters
indexitem to be shown

References myIndex, and myView.

Member Data Documentation

◆ myColumn

int QtxTreeViewSearcher::myColumn
private

◆ myIndex

QPersistentModelIndex QtxTreeViewSearcher::myIndex
private

◆ myView

QTreeView* QtxTreeViewSearcher::myView
private

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