QCodeEdit  2.2
Public Types | Public Member Functions
QDocumentSearch Class Reference

An helper class to perform search in document. More...

List of all members.

Public Types

enum  Option {
  WholeWords = 1, CaseSensitive = 2, RegExp = 4, Replace = 8,
  Prompt = 16, Silent = 32, HighlightAll = 64
}

Public Member Functions

 Q_DECLARE_FLAGS (Options, Option)
 QDocumentSearch (QEditor *e, const QString &f, Options opt, const QString &r=QString())
int currentMatchIndex () const
 Position of the current match among the indexed matches.
int indexedMatchCount () const
 Number of availables indexed matches.
QDocumentCursor match (int idx) const
QString searchText () const
void setSearchText (const QString &f)
 Set the search pattern.
Options options () const
bool hasOption (Option opt) const
 Test whether a given option is enabled.
void setOption (Option opt, bool on)
 Set a search option.
QString replaceText () const
void setReplaceText (const QString &r)
 Set the replacement text.
QDocumentCursor origin () const
void setOrigin (const QDocumentCursor &c)
 Set the cursor.
QDocumentCursor cursor () const
void setCursor (const QDocumentCursor &c)
 Set the cursor.
QDocumentCursor scope () const
void setScope (const QDocumentCursor &c)
 Set the search scope.
void next (bool backward, bool all=false)
 Perform a search.

Detailed Description

An helper class to perform search in document.

QDocumentSearch offer means to perform complex search in documents.


Member Function Documentation

QDocumentCursor QDocumentSearch::cursor ( ) const
Returns:
The current cursor position

This is useful to examine matches after performing a search.

int QDocumentSearch::indexedMatchCount ( ) const

Number of availables indexed matches.

Indexed matches are only available when the whole scope is searched, i.e when either the HighlightAll option is set to true or when next() is called with the all parameter set to true.

Referenced by next().

QDocumentCursor QDocumentSearch::match ( int  idx) const
Returns:
A cursor pointing to the n-th index match
Parameters:
idxindex of the match to lookup

The cursor returned, if valid, delimits the match through its selection.

void QDocumentSearch::next ( bool  backward,
bool  all = false 
)
QDocumentCursor QDocumentSearch::origin ( ) const
Returns:
The current cursor position

This is useful to examine matches after performing a search.

QString QDocumentSearch::replaceText ( ) const
Returns:
the replacement text
QDocumentCursor QDocumentSearch::scope ( ) const
Returns:
The scope of the search

An invalid cursor indicate that the scope is the whole document, otherwise the scope is the selection of the returned cursor.

QString QDocumentSearch::searchText ( ) const
Returns:
The search pattern
void QDocumentSearch::setCursor ( const QDocumentCursor c)

Set the cursor.

If the related option is set, search will start from that cursor position

void QDocumentSearch::setOption ( Option  opt,
bool  on 
)
void QDocumentSearch::setOrigin ( const QDocumentCursor c)

Set the cursor.

If the related option is set, search will start from that cursor position

This also changes the cursor()

References QDocumentPrivate::clearMatches().

void QDocumentSearch::setScope ( const QDocumentCursor c)

Set the search scope.

If the given cursor has no selection (a fortiori if it is invalid) then the scope is the whole document.

References QDocumentPrivate::clearMatches(), and QDocumentCursor::hasSelection().


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