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. | |
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. |
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 |
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 QDocument::addMatch(), QDocumentCursor::anchorColumnNumber(), QDocumentCursor::beginEditBlock(), QDocumentCursor::columnNumber(), QDocumentCursor::document(), QDocumentCursor::endEditBlock(), QDocument::formatFactory(), QDocument::formatScheme(), QDocument::getNextGroupId(), hasOption(), QDocumentCursor::hasSelection(), QFormatScheme::id(), indexedMatchCount(), QDocumentCursor::insertText(), QDocumentCursor::isNull(), QDocumentCursor::isValid(), QDocumentCursor::line(), QDocumentCursor::lineNumber(), QDocumentCursor::movePosition(), QDocumentCursor::removeSelectedText(), QDocumentCursor::selection(), QDocumentCursor::selectionEnd(), QDocumentCursor::selectionStart(), QDocumentCursor::setColumnNumber(), and QDocumentLine::text().
Referenced by 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().