QCodeEdit
2.2
|
An helper class to perform search in document. More...
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. More... | |
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. More... | |
QString | replaceText () const |
void | setReplaceText (const QString &r) |
Set the replacement text. | |
QDocumentCursor | origin () const |
void | setOrigin (const QDocumentCursor &c) |
Set the cursor. More... | |
QDocumentCursor | cursor () const |
void | setCursor (const QDocumentCursor &c) |
Set the cursor. More... | |
QDocumentCursor | scope () const |
void | setScope (const QDocumentCursor &c) |
Set the search scope. More... | |
void | next (bool backward, bool all=false) |
Perform a search. More... | |
An helper class to perform search in document.
QDocumentSearch offer means to perform complex search in documents.
QDocumentCursor QDocumentSearch::cursor | ( | ) | const |
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.
QDocumentCursor QDocumentSearch::match | ( | int | idx | ) | const |
idx | index of the match to lookup |
The cursor returned, if valid, delimits the match through its selection.
void QDocumentSearch::next | ( | bool | backward, |
bool | all = false |
||
) |
Perform a search.
backward | whether to go backward or forward |
all | if true, the whole document will be searched first, all matches recorded and available for further navigation |
References hasOption(), QDocumentCursor::hasSelection(), QDocumentCursor::isNull(), QDocumentCursor::isValid(), QDocumentCursor::movePosition(), QDocumentCursor::selectionEnd(), and QDocumentCursor::selectionStart().
Referenced by QSearchReplacePanel::find(), and setOption().
QDocumentCursor QDocumentSearch::origin | ( | ) | const |
This is useful to examine matches after performing a search.
QString QDocumentSearch::replaceText | ( | ) | const |
QDocumentCursor QDocumentSearch::scope | ( | ) | const |
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 |
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 | ||
) |
Set a search option.
opt | option to set |
on | whether to enable the option |
References QDocument::addMatch(), QDocumentCursor::anchorColumnNumber(), QDocumentPrivate::clearMatches(), QDocument::clearMatches(), QDocumentCursor::columnNumber(), QDocument::flushMatches(), QDocument::formatFactory(), QDocument::formatScheme(), QDocument::getNextGroupId(), QFormatScheme::id(), QDocumentCursor::lineNumber(), and next().
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().