Version: 6.3.1
Data Structures | Public Types | Public Slots | Public Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes

QtxSearchTool Class Reference

Context search tool. More...

#include <QtxSearchTool.h>

Inheritance diagram for QtxSearchTool:
Inheritance graph

Data Structures

class  Searcher
 Generic searcher class. More...

Public Types

enum  Controls {
  Search = 0x00000001, Next = 0x00000002, Prev = 0x00000004, First = 0x00000008,
  Last = 0x00000010, Close = 0x00000020, Case = 0x00000040, RegExp = 0x00000080,
  Wrap = 0x00000100, Basic = Search | Next | Prev | Close, Standard = Basic | First | Last, Modifiers = Case | RegExp | Wrap,
  All = Standard | Modifiers
}
 

Search tool controls.

More...
enum  Activator {
  None = 0x00000000, HotKey = 0x00000001, SlashKey = 0x00000002, StandardKey = 0x00000004,
  PrintKey = 0x00000008, Any = HotKey | SlashKey | StandardKey | PrintKey
}

Public Slots

virtual void find ()
 Activate search tool.
virtual void findNext ()
 Find next appropriate data.
virtual void findPrevious ()
 Find previous appropriate data.
virtual void findFirst ()
 Find first appropriate data.
virtual void findLast ()
 Find last appropriate data.

Public Member Functions

 QtxSearchTool (QWidget *, QWidget *=0, int=All)
 Constructor.
 QtxSearchTool (QWidget *, int=All)
 Constructor.
virtual ~QtxSearchTool ()
 Destructor.
QWidgetwatchedWidget () const
 Get watched widget.
void setWatchedWidget (QWidget *)
 Set watched widget.
Searchersearcher () const
 Get current searcher.
void setSearcher (Searcher *)
 Assign searcher.
int activators () const
 Get activators.
void setActivators (const int)
 Set activators.
int controls () const
 Get controls.
void setControls (const int)
 Set controls.
QList< QKeySequence > shortcuts () const
 Get shortcuts.
void setShortcuts (const QKeySequence &)
 Set shortcuts.
void setShortcuts (const QList< QKeySequence > &)
 Set shortcuts.
int addCustomWidget (QWidget *, int=-1)
 Add custom widget.
QWidgetcustomWidget (int) const
 Get custom widget by ID.
int customWidgetId (QWidget *) const
 Get custom widget ID.
bool isAutoHideEnabled () const
 Check if auto-hide of the tool widget is enabled.
void enableAutoHide (bool)
 Set/clear auto-hide option.
bool isCaseSensitive () const
 Get 'case sensitive search' option value.
bool isRegExpSearch () const
 Get 'regular expression search' option value.
bool isSearchWrapped () const
 Get 'search wrapping' option value.
void setCaseSensitive (bool)
 Set 'case sensitive search' option value.
void setRegExpSearch (bool)
 Set 'regular expression search' option value.
void setSearchWrapped (bool)
 Set 'search wrapping' option value.
virtual bool event (QEvent *)
 Customize event handling.
virtual bool eventFilter (QObject *, QEvent *)
 Filter events from the watched widget.

Private Types

enum  {
  fAny, fNext, fPrevious, fFirst,
  fLast
}
 

Find operation type.

More...
typedef QPointer< QShortcut > ShortcutPtr
typedef QList< ShortcutPtrShortcutList

Private Slots

void find (const QString &, int=fAny)
 Perform search.
void modifierSwitched ()
 Called when any search modifier is switched.

Private Member Functions

void init ()
 Initialize the search tool widget.
bool focused () const
 Check if any child widget has input focus.
void clearShortcuts ()
 Clear shortcuts.
void initShortcuts (const QList< QKeySequence > &)
 Install shortcuts.
void updateShortcuts ()
 Update shortcuts state.
void updateControls ()
 Update controls state.

Private Attributes

QWidgetmyBtnWidget
QWidgetmyModWidget
QLineEditmyData
QToolButtonmyToFirst
QToolButtonmyToLast
QToolButtonmyNext
QToolButtonmyPrev
QToolButtonmyClose
QCheckBox * myIsCaseSens
QCheckBox * myIsRegExp
QCheckBox * myWrap
QWidgetmyWatched
SearchermySearcher
int myControls
int myActivators
ShortcutList myShortcuts
QTimer * myAutoHideTimer
bool myAutoHideEnabled
QMap< int, QWidget * > myWidgets

Detailed Description

The QtxSearchTool class implements a specific context search tool widget which can be embedded into any GUI element. It represents the usual dialog panel with the line edit box used to enter text to be searched and set of buttons, like "Find Next", "Find Previous", etc. In addition, the search modifiers like "Case sensitive search", "Wrap search" are provided.

Actually the class QtxSearchTool does not perform a serach itself - it is only the generic widget. To use this widget, you have to install a searcher depending on your needs. This should be a successor of the class QtxSearchTool.Searcher - it is the class which will perform actual search of the data in your widget according to the widget type.

For the current moment, only one standard searcher is implemented: it is the class QtxTreeViewSearcher, which can be used to search the text data in the tree view widget (QTreeView). See this class for more details.

The usual usage of the searcher widget is the following:

Note, that controls to be displayed by the search tool widget are passed as ORed flags to the widget's constructor. At any time, the available controls can be set/get with setControls() and controls() methods. By default, all widgets are displayed (see also QtxSearchTool.Controls enumeration).

The class QtxSearchTool also provides a way to add custom widgets - these widgets are displayed at the bottom area of the tool box. Use method addCustomWidget() to add custom widget to the search tool box. Your searcher class can use custom widgets to perform advanced search.

The class supports different ways of the activation, all of them can be switched on/off with setActivators() method. See QtxSearchTool.Activator enumeration for more details. By default, all methods are switched on: default hot key is <Ctrl><S> and standard key bindings are the platform dependent keyboard shortcuts. Shortcuts can be assigned with the setShortcuts() methods.


Member Typedef Documentation

typedef QPointer<QShortcut> QtxSearchTool.ShortcutPtr [private]

Member Enumeration Documentation

anonymous enum [private]
Enumerator:
fAny 

find any appropriate

fNext 

find next appropriate

fPrevious 

find previous appropriate

fFirst 

find first appropriate

fLast 

find last appropriate

Enumerator:
Search 

line edit field for searched text

Next 

'find next' button

Prev 

'find previous' button

First 

'find first' button

Last 

'find last' button

Close 

'close' button

Case 

'case sensitive search' check box

RegExp 

'regular expression' check box

Wrap 

'wrap search' check box

Basic 

basic controls: text field, "next", "prev" and "close" buttons

Standard 

standard controls: same as Basic plus "first" and "last" buttons

Modifiers 

search modifiers check boxes

All 

all controls

Enumerator:
None 

search tool can be activated programmatically only

HotKey 

search tool is activated by hot key

SlashKey 

search tool is activated by splash key ( / )

StandardKey 

search tool is activated by standard key combination (e.g. F3)

PrintKey 

search tool is activated when user types any print key

Any 

search tool is activated by any of above mentioned ways


Constructor & Destructor Documentation

QtxSearchTool::QtxSearchTool ( QWidget parent,
QWidget watched = 0,
int  controls = All 
)

Creates a search tool widget with parent widget parent and watched widget watched. The controls to be displayed can be passed via controls parameter. By default, all controls are displayed.

Parameters:
parentparent widget
watchedwatched widget
controlsORed controls flags (QtxSearchTool.Controls)
See also:
setWatchedWidget(), setControls()

References init().

QtxSearchTool::QtxSearchTool ( QWidget parent,
int  controls = All 
)

Creates a search tool widget with parent widget parent. Parameter parent is also used to set watched widget. The controls to be displayed can be passed via controls parameter. By default, all controls are displayed.

Parameters:
parentparent widget
controlsORed controls flags (QtxSearchTool.Controls)
See also:
setWatchedWidget(), setControls()

References init().

QtxSearchTool::~QtxSearchTool ( ) [virtual]

References clearShortcuts(), and mySearcher.


Member Function Documentation

QWidget * QtxSearchTool::watchedWidget ( ) const
Returns:
currently used watched widget
See also:
setWatchedWidget(), activators(), setActivators()

References myWatched.

void QtxSearchTool::setWatchedWidget ( QWidget watched)

Watched widget is that one for which shortcut bindings are set. When this widget has focus and any hot key binbding is pressed by the user, the search tool box is activated. The same occurs if slash key is pressed and QtxSearchTool.SlashKey activator is enabled. If the QtxSearchTool.PrintKey activator is enabled, the tool box is activated if any printed key is pressed by the user.

Parameters:
watcheda widget to be watched by the search tool
See also:
watchedWidget(), activators(), setActivators()

References initShortcuts(), myWatched, and shortcuts().

QtxSearchTool::Searcher * QtxSearchTool::searcher ( ) const
Returns:
currently set searcher (QtxSearchTool.Searcher)
See also:
setSearcher()

References mySearcher.

void QtxSearchTool::setSearcher ( QtxSearchTool::Searcher s)

Note: the search tool takes ownership to the searcher and destroys it when deleted.

Parameters:
ssearcher to be used (QtxSearchTool.Searcher)
See also:
searcher()

References mySearcher.

int QtxSearchTool::activators ( ) const
Returns:
activators currently enabled (ORed QtxSearchTool.Activator flags)
See also:
setActivators()

References myActivators.

void QtxSearchTool::setActivators ( const int  flags)
Parameters:
flagsset activators to be used (ORed QtxSearchTool.Activator flags)
See also:
activators()

References myActivators, and updateShortcuts().

int QtxSearchTool::controls ( ) const
Returns:
controls currently enabled (ORed QtxSearchTool.Controls flags)
See also:
setControls()

References myControls.

void QtxSearchTool::setControls ( const int  ctrls)
Parameters:
ctrlscontrols to be displayed (ORed QtxSearchTool.Controls flags)
See also:
controls()

References myControls, and updateControls().

QList< QKeySequence > QtxSearchTool::shortcuts ( ) const

Note: the standard bindings are not include to the resulting list.

Returns:
list of shortcuts bindings currently set
See also:
setShortcuts()

References myShortcuts.

void QtxSearchTool::setShortcuts ( const QKeySequence &  accel)
Parameters:
accelshortcut binding(s) to be used
See also:
shortcuts()
void QtxSearchTool::setShortcuts ( const QList< QKeySequence > &  accels)
Parameters:
accelshortcut bindings to be used
See also:
shortcuts()

References initShortcuts().

int QtxSearchTool::addCustomWidget ( QWidget w,
int  id = -1 
)
Parameters:
wcustom widget to be added
idwidget unique ID to be used (if < 0, automatically assigned)
Returns:
widget unique ID
See also:
customWidget(), customWidgetId()

References myWidgets.

QWidget * QtxSearchTool::customWidget ( int  id) const
Parameters:
idwidget ID
Returns:
custom widget or 0 if not found
See also:
addCustomWidget(), customWidgetId()

References myWidgets.

int QtxSearchTool::customWidgetId ( QWidget w) const
Parameters:
wcustom widget
Returns:
custom widget ID or -1 if widget does not belong to the search tool
See also:
addCustomWidget(), customWidget()

References myWidgets.

bool QtxSearchTool::isAutoHideEnabled ( ) const

By default, the search tool widget is automatically hidden after 10 seconds of idle (only if watched widget has input focus).

Returns:
true if auto-hide option is set
See also:
enableAutoHide()

References myAutoHideEnabled.

void QtxSearchTool::enableAutoHide ( bool  enable)

By default, the search tool widget is automatically hidden after 10 seconds of idle (only if watched widget has input focus).

Parameters:
enablenew option state
See also:
isAutoHideEnabled()

References focused(), myAutoHideEnabled, and myAutoHideTimer.

bool QtxSearchTool::isCaseSensitive ( ) const

This method returns true if 'case sensitive search' control is enabled and switched on.

Returns:
true if case sensitive search is performed
See also:
isRegExpSearch(), isSearchWrapped(), setControls()
setCaseSensitive(), setRegExpSearch(), setSearchWrapped()

References Case, myControls, and myIsCaseSens.

bool QtxSearchTool::isRegExpSearch ( ) const

This method returns true if 'regular expression search' control is enabled and switched on.

Returns:
true if regular expression search is performed
See also:
isCaseSensitive(), isSearchWrapped(), setControls()
setCaseSensitive(), setRegExpSearch(), setSearchWrapped()

References myControls, myIsRegExp, and RegExp.

bool QtxSearchTool::isSearchWrapped ( ) const

This method returns true if 'wrap search' control is enabled and switched on.

Returns:
true if search wrapping is enabled
See also:
isCaseSensitive(), isRegExpSearch(), setControls()
setCaseSensitive(), setRegExpSearch(), setSearchWrapped()

References myControls, myWrap, and Wrap.

void QtxSearchTool::setCaseSensitive ( bool  on)
void QtxSearchTool::setRegExpSearch ( bool  on)
void QtxSearchTool::setSearchWrapped ( bool  on)
bool QtxSearchTool::event ( QEvent e) [virtual]
Parameters:
eevent
Returns:
true if event has been handled

References myWatched, and updateShortcuts().

bool QtxSearchTool::eventFilter ( QObject o,
QEvent e 
) [virtual]
Parameters:
oobject
eevent
Returns:
true if further event processing should be stopped

References find(), findNext(), focused(), isAutoHideEnabled(), myActivators, myAutoHideTimer, myData, myWatched, PrintKey, and SlashKey.

void QtxSearchTool::find ( ) [virtual, slot]

Call this method to start new search.

References myAutoHideTimer, and myData.

void QtxSearchTool::findNext ( ) [virtual, slot]

Call this method to repeat the search in the forward direction.

References find(), fNext, and myData.

void QtxSearchTool::findPrevious ( ) [virtual, slot]

Call this method to repeat the search in the backward direction.

References find(), fPrevious, and myData.

void QtxSearchTool::findFirst ( ) [virtual, slot]

Call this method to find the very first appropriate data.

References fFirst, find(), and myData.

void QtxSearchTool::findLast ( ) [virtual, slot]

Call this method to find the very last appropriate data.

References find(), fLast, and myData.

void QtxSearchTool::find ( const QString &  what,
int  where = fAny 
) [private, slot]
void QtxSearchTool::modifierSwitched ( ) [private, slot]

References find(), and myData.

void QtxSearchTool::init ( ) [private]
bool QtxSearchTool::focused ( ) const [private]
Returns:
true if any child widget has input focus
void QtxSearchTool::clearShortcuts ( ) [private]

References myShortcuts.

void QtxSearchTool::initShortcuts ( const QList< QKeySequence > &  accels) [private]
void QtxSearchTool::updateShortcuts ( ) [private]
void QtxSearchTool::updateControls ( ) [private]

Field Documentation

QCheckBox* QtxSearchTool.myIsCaseSens [private]
QCheckBox* QtxSearchTool.myIsRegExp [private]
QCheckBox* QtxSearchTool.myWrap [private]
int QtxSearchTool.myControls [private]
QTimer* QtxSearchTool.myAutoHideTimer [private]
QMap<int, QWidget*> QtxSearchTool.myWidgets [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