Context search tool. More...
#include <QtxSearchTool.h>
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... | |
QWidget * | watchedWidget () const |
Get watched widget. More... | |
void | setWatchedWidget (QWidget *) |
Set watched widget. More... | |
Searcher * | searcher () 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... | |
QWidget * | customWidget (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< ShortcutPtr > | ShortcutList |
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 | |
QWidget * | myBtnWidget |
QWidget * | myModWidget |
QLineEdit * | myData |
QToolButton * | myToFirst |
QToolButton * | myToLast |
QToolButton * | myNext |
QToolButton * | myPrev |
QToolButton * | myClose |
QCheckBox * | myIsCaseSens |
QCheckBox * | myIsRegExp |
QCheckBox * | myWrap |
QWidget * | myWatched |
Searcher * | mySearcher |
int | myControls |
int | myActivators |
ShortcutList | myShortcuts |
QTimer * | myAutoHideTimer |
bool | myAutoHideEnabled |
QMap< int, QWidget * > | myWidgets |
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.
|
private |
|
private |
|
private |
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.
parent | parent widget |
watched | watched widget |
controls | ORed controls flags (QtxSearchTool::Controls) |
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.
parent | parent widget |
controls | ORed controls flags (QtxSearchTool::Controls) |
References init().
|
virtual |
References clearShortcuts(), and mySearcher.
int QtxSearchTool::activators | ( | ) | const |
References myActivators.
int QtxSearchTool::addCustomWidget | ( | QWidget * | w, |
int | id = -1 |
||
) |
w | custom widget to be added |
id | widget unique ID to be used (if < 0, automatically assigned) |
References myWidgets.
|
private |
References myShortcuts.
int QtxSearchTool::controls | ( | ) | const |
References myControls.
QWidget * QtxSearchTool::customWidget | ( | int | id | ) | const |
id | widget ID |
References myWidgets.
int QtxSearchTool::customWidgetId | ( | QWidget * | w | ) | const |
w | custom widget |
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).
enable | new option state |
References focused(), myAutoHideEnabled, and myAutoHideTimer.
|
virtual |
e | event |
true
if event has been handled References myWatched, and updateShortcuts().
o | object |
e | event |
true
if further event processing should be stopped References find(), findNext(), focused(), isAutoHideEnabled(), myActivators, myAutoHideTimer, myData, myWatched, PrintKey, and SlashKey.
|
virtualslot |
Call this method to start new search.
References myAutoHideTimer, and myData.
what | text to be searched |
where | search flags |
References OCCViewer::color(), fAny, fFirst, QtxSearchTool::Searcher::find(), QtxSearchTool::Searcher::findFirst(), QtxSearchTool::Searcher::findLast(), QtxSearchTool::Searcher::findNext(), QtxSearchTool::Searcher::findPrevious(), fLast, fNext, focused(), fPrevious, highlightColor, myAutoHideEnabled, myAutoHideTimer, myData, and mySearcher.
|
virtualslot |
|
virtualslot |
|
virtualslot |
|
virtualslot |
|
private |
true
if any child widget has input focus
|
private |
References Any, close_xpm, find(), findFirst(), findLast(), findNext(), findPrevious(), first_xpm, last_xpm, modifierSwitched(), myBtnWidget, myClose, myData, myIsCaseSens, myIsRegExp, myModWidget, myNext, myPrev, myToFirst, myToLast, myWatched, myWrap, next_xpm, prev_xpm, setActivators(), setShortcuts(), setWatchedWidget(), updateControls(), Vertical, and wrapWidget().
accels | shortcuts list |
References clearShortcuts(), DefaultAutoHideDelay, VTK::Find(), find(), findNext(), findPrevious(), myAutoHideTimer, myShortcuts, myWatched, and updateShortcuts().
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).
true
if auto-hide option is set References myAutoHideEnabled.
bool QtxSearchTool::isCaseSensitive | ( | ) | const |
This method returns true
if 'case sensitive search' control is enabled and switched on.
true
if case sensitive search is performed References Case, myControls, and myIsCaseSens.
bool QtxSearchTool::isRegExpSearch | ( | ) | const |
This method returns true
if 'regular expression search' control is enabled and switched on.
true
if regular expression search is performed References myControls, myIsRegExp, and RegExp.
bool QtxSearchTool::isSearchWrapped | ( | ) | const |
This method returns true
if 'wrap search' control is enabled and switched on.
true
if search wrapping is enabled References myControls, myWrap, and Wrap.
QtxSearchTool::Searcher * QtxSearchTool::searcher | ( | ) | const |
References mySearcher.
void QtxSearchTool::setActivators | ( | const int | flags | ) |
flags | set activators to be used (ORed QtxSearchTool::Activator flags) |
References myActivators, and updateShortcuts().
void QtxSearchTool::setCaseSensitive | ( | bool | on | ) |
on | new option state |
References Case, myControls, and myIsCaseSens.
void QtxSearchTool::setControls | ( | const int | ctrls | ) |
ctrls | controls to be displayed (ORed QtxSearchTool::Controls flags) |
References myControls, and updateControls().
void QtxSearchTool::setRegExpSearch | ( | bool | on | ) |
on | new option state |
References myControls, myIsRegExp, and RegExp.
void QtxSearchTool::setSearcher | ( | QtxSearchTool::Searcher * | s | ) |
Note: the search tool takes ownership to the searcher and destroys it when deleted.
s | searcher to be used (QtxSearchTool::Searcher) |
References mySearcher, and s.
void QtxSearchTool::setSearchWrapped | ( | bool | on | ) |
on | new option state |
References myControls, myWrap, and Wrap.
void QtxSearchTool::setShortcuts | ( | const QKeySequence & | accel | ) |
accel | shortcut binding(s) to be used |
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.
watched | a widget to be watched by the search tool |
References initShortcuts(), myWatched, and shortcuts().
QList< QKeySequence > QtxSearchTool::shortcuts | ( | ) | const |
Note: the standard bindings are not include to the resulting list.
References myShortcuts.
|
private |
References Case, Close, First, Last, Modifiers, myBtnWidget, myClose, myControls, myData, myIsCaseSens, myIsRegExp, myModWidget, myNext, myPrev, myToFirst, myToLast, myWrap, Next, Prev, RegExp, Search, Standard, and Wrap.
|
private |
References HotKey, myActivators, myShortcuts, and StandardKey.
QWidget * QtxSearchTool::watchedWidget | ( | ) | const |
References myWatched.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |