[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Member Functions | List of all members
KLFSearchable Class Referenceabstract

An interface for objects that can be I-searched with a KLFSearchBar. More...

#include <klfsearchbar.h>

Inheritance diagram for KLFSearchable:
Inheritance graph
[legend]

Public Member Functions

 KLFSearchable ()
 
virtual ~KLFSearchable ()
 
virtual bool searchFind (const QString &queryString, bool forward)=0
 Find the first occurence of a query string. More...
 
bool searchFind (const QString &queryString)
 Find the first occurence of a query string. More...
 
virtual bool searchFindNext (bool forward)=0
 Find next or previous occurence of query string. More...
 
virtual void searchAbort ()=0
 Abort I-Search. More...
 

Detailed Description

An interface for objects that can be I-searched with a KLFSearchBar.

This class is the base skeleton interface for displays that will be targets for I-searches. There are three functions to reimplement:

* virtual bool searchFind(const QString& queryString, bool forward);
* virtual bool searchFindNext(bool forward);
* virtual void searchAbort();
*

That have to actually perform the search.

It is not uncommon for the display widget itself to inherit also from a KLFSearchable. See KLFAbstractLibView and KLFLibDefautlView for an example (in klfapp library).

This class is pretty low-level search (you have to manually walk all items, remember the query string for future find-next operations, etc.). For a higher-level search implementation, see KLFIteratorSearchable (which itself is a KLFSearchable object and can also be used as target for KLFSearchBar).

Definition at line 62 of file klfsearchbar.h.

Constructor & Destructor Documentation

KLFSearchable::KLFSearchable ( )

Definition at line 39 of file klfsearchbar.cpp.

KLFSearchable::~KLFSearchable ( )
virtual

Definition at line 42 of file klfsearchbar.cpp.

References QList::size().

Member Function Documentation

virtual void KLFSearchable::searchAbort ( )
pure virtual

Abort I-Search.

The behavior depends on the object/data being searched. This could be reimplemented for example to return to the beginning of the list, or to the position where the user was at the beginning of the search.

Implemented in KLFIteratorSearchable< Iter >, and KLFSearchableProxy.

Referenced by KLFSearchBar::abortSearch(), and KLFSearchableProxy::searchAbort().

virtual bool KLFSearchable::searchFind ( const QString queryString,
bool  forward 
)
pure virtual

Find the first occurence of a query string.

This function has to be reimplemented to find the first occurence of the string queryString, searching from top of the displayed information if forward is TRUE, or reverse from end of display of FALSE.

The reimplementation should call from time to time

qApp->processEvents()

to keep the GUI from freezing in long searches.

Note
If the reimplementation implements the above suggestion, note that the slot searchAbort() may be called during that time! It is best to take that into account and provide a means to stop the search if that is the case.

Implemented in KLFIteratorSearchable< Iter >, and KLFSearchableProxy.

Referenced by KLFSearchBar::find(), and KLFSearchableProxy::searchFind().

bool KLFSearchable::searchFind ( const QString queryString)
inline

Find the first occurence of a query string.

This function is provided for calling convenience. Subclasses should reimplement searchFind(const QString&, bool) instead.

This function directly calls searchFind(const QString& bool) with the forward argument set to TRUE.

Definition at line 90 of file klfsearchbar.h.

References searchFind().

Referenced by searchFind().

virtual bool KLFSearchable::searchFindNext ( bool  forward)
pure virtual

Find next or previous occurence of query string.

This function has to be reimplemented to find the next occurence of the query string given by a previous call to searchFind(). The search must be performed in the direction given by forward (see searchFind()).

It is up to the sub-class to remember the query string and the current match location.

This function should also call the applications's processEvents() to keep the GUI from freezing. See documentation in searchFind().

Implemented in KLFIteratorSearchable< Iter >, and KLFSearchableProxy.

Referenced by KLFSearchBar::findNext(), and KLFSearchableProxy::searchFindNext().


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

Generated by doxygen 1.8.5