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

Context search tool. More...

#include <QtxSearchTool.h>

Inheritance diagram for QtxSearchTool:
Inheritance graph

Classes

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. More...
 
virtual void findNext ()
 Find next appropriate data. More...
 
virtual void findPrevious ()
 Find previous appropriate data. More...
 
virtual void findFirst ()
 Find first appropriate data. More...
 
virtual void findLast ()
 Find last appropriate data. More...
 

Public Member Functions

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

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. More...
 
void modifierSwitched ()
 Called when any search modifier is switched. More...
 

Private Member Functions

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

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
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

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

Constructor & Destructor Documentation

QtxSearchTool::QtxSearchTool ( QWidget parent,
QWidget watched = 0,
int  controls = All,
Qt::Orientation  orientation = Qt::Vertical 
)

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,
Qt::Orientation  orientation = Qt::Vertical 
)

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

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

References myActivators.

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.

void QtxSearchTool::clearShortcuts ( )
private

References myShortcuts.

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

References myControls.

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.

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::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 ( )
virtualslot

Call this method to start new search.

References myAutoHideTimer, and myData.

void QtxSearchTool::findFirst ( )
virtualslot

Call this method to find the very first appropriate data.

References fFirst, find(), and myData.

void QtxSearchTool::findLast ( )
virtualslot

Call this method to find the very last appropriate data.

References find(), fLast, and myData.

void QtxSearchTool::findNext ( )
virtualslot

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

References find(), fNext, and myData.

void QtxSearchTool::findPrevious ( )
virtualslot

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

References find(), fPrevious, and myData.

bool QtxSearchTool::focused ( ) const
private
Returns
true if any child widget has input focus
void QtxSearchTool::initShortcuts ( const QList< QKeySequence > &  accels)
private
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.

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::modifierSwitched ( )
privateslot

References find(), and myData.

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

References mySearcher.

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

References myActivators, and updateShortcuts().

void QtxSearchTool::setCaseSensitive ( bool  on)
void QtxSearchTool::setControls ( const int  ctrls)
Parameters
ctrlscontrols to be displayed (ORed QtxSearchTool::Controls flags)
See Also
controls()

References myControls, and updateControls().

void QtxSearchTool::setRegExpSearch ( bool  on)
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, and s.

void QtxSearchTool::setSearchWrapped ( bool  on)
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().

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

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::updateControls ( )
private
void QtxSearchTool::updateShortcuts ( )
private
QWidget * QtxSearchTool::watchedWidget ( ) const
Returns
currently used watched widget
See Also
setWatchedWidget(), activators(), setActivators()

References myWatched.

Member Data Documentation

int QtxSearchTool::myActivators
private
bool QtxSearchTool::myAutoHideEnabled
private
QTimer* QtxSearchTool::myAutoHideTimer
private
QWidget* QtxSearchTool::myBtnWidget
private
QToolButton* QtxSearchTool::myClose
private
int QtxSearchTool::myControls
private
QLineEdit* QtxSearchTool::myData
private
QCheckBox* QtxSearchTool::myIsCaseSens
private
QCheckBox* QtxSearchTool::myIsRegExp
private
QWidget* QtxSearchTool::myModWidget
private
QToolButton* QtxSearchTool::myNext
private
QToolButton* QtxSearchTool::myPrev
private
Searcher* QtxSearchTool::mySearcher
private
ShortcutList QtxSearchTool::myShortcuts
private
QToolButton* QtxSearchTool::myToFirst
private
QToolButton* QtxSearchTool::myToLast
private
QWidget* QtxSearchTool::myWatched
private
QMap<int, QWidget*> QtxSearchTool::myWidgets
private
QCheckBox* QtxSearchTool::myWrap
private

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