forked from qt-creator/qt-creator
Move find flags from IFindSupport to more accessible place.
For later use in IFindFilter.
This commit is contained in:
@@ -72,9 +72,9 @@ public:
|
||||
~BinEditorFind() {}
|
||||
|
||||
bool supportsReplace() const { return false; }
|
||||
IFindSupport::FindFlags supportedFindFlags() const
|
||||
Find::FindFlags supportedFindFlags() const
|
||||
{
|
||||
return IFindSupport::FindBackward | IFindSupport::FindCaseSensitively;
|
||||
return Find::FindBackward | Find::FindCaseSensitively;
|
||||
}
|
||||
|
||||
void resetIncrementalSearch()
|
||||
@@ -87,16 +87,16 @@ public:
|
||||
QString completedFindString() const { return QString(); }
|
||||
|
||||
|
||||
int find(const QByteArray &pattern, int pos, Find::IFindSupport::FindFlags findFlags) {
|
||||
int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags) {
|
||||
if (pattern.isEmpty()) {
|
||||
m_editor->setCursorPosition(pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
return m_editor->find(pattern, pos, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
return m_editor->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
|
||||
Result findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) {
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags) {
|
||||
QByteArray pattern = txt.toLatin1();
|
||||
if (pattern != m_lastPattern)
|
||||
resetIncrementalSearch(); // Because we don't search for nibbles.
|
||||
@@ -109,13 +109,13 @@ public:
|
||||
Result result;
|
||||
if (found >= 0) {
|
||||
result = Found;
|
||||
m_editor->highlightSearchResults(pattern, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
m_editor->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
m_contPos = -1;
|
||||
} else {
|
||||
if (found == -2) {
|
||||
result = NotYetFound;
|
||||
m_contPos +=
|
||||
findFlags & Find::IFindSupport::FindBackward
|
||||
findFlags & Find::FindBackward
|
||||
? -BinEditor::SearchStride : BinEditor::SearchStride;
|
||||
} else {
|
||||
result = NotFound;
|
||||
@@ -126,12 +126,12 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
Result findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) {
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags) {
|
||||
QByteArray pattern = txt.toLatin1();
|
||||
bool wasReset = (m_incrementalStartPos < 0);
|
||||
if (m_contPos == -1) {
|
||||
m_contPos = m_editor->cursorPosition();
|
||||
if (findFlags & Find::IFindSupport::FindBackward)
|
||||
if (findFlags & Find::FindBackward)
|
||||
m_contPos = m_editor->selectionStart()-1;
|
||||
}
|
||||
int found = find(pattern, m_contPos, findFlags);
|
||||
@@ -141,10 +141,10 @@ public:
|
||||
m_incrementalStartPos = found;
|
||||
m_contPos = -1;
|
||||
if (wasReset)
|
||||
m_editor->highlightSearchResults(pattern, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
m_editor->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
} else if (found == -2) {
|
||||
result = NotYetFound;
|
||||
m_contPos += findFlags & Find::IFindSupport::FindBackward
|
||||
m_contPos += findFlags & Find::FindBackward
|
||||
? -BinEditor::SearchStride : BinEditor::SearchStride;
|
||||
} else {
|
||||
result = NotFound;
|
||||
@@ -155,11 +155,11 @@ public:
|
||||
}
|
||||
|
||||
void replace(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags) { }
|
||||
Find::FindFlags) { }
|
||||
bool replaceStep(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags) { return false;}
|
||||
Find::FindFlags) { return false;}
|
||||
int replaceAll(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags) { return 0; }
|
||||
Find::FindFlags) { return 0; }
|
||||
|
||||
private:
|
||||
BinEditor *m_editor;
|
||||
|
||||
@@ -81,10 +81,10 @@ bool BaseTextFind::supportsReplace() const
|
||||
return !isReadOnly();
|
||||
}
|
||||
|
||||
IFindSupport::FindFlags BaseTextFind::supportedFindFlags() const
|
||||
Find::FindFlags BaseTextFind::supportedFindFlags() const
|
||||
{
|
||||
return IFindSupport::FindBackward | IFindSupport::FindCaseSensitively
|
||||
| IFindSupport::FindRegularExpression | IFindSupport::FindWholeWords;
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindRegularExpression | Find::FindWholeWords;
|
||||
}
|
||||
|
||||
void BaseTextFind::resetIncrementalSearch()
|
||||
@@ -131,7 +131,7 @@ QString BaseTextFind::completedFindString() const
|
||||
return cursor.selectedText();
|
||||
}
|
||||
|
||||
IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
if (m_incrementalStartPos < 0)
|
||||
@@ -145,7 +145,7 @@ IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, IFindSupp
|
||||
return found ? Found : NotFound;
|
||||
}
|
||||
|
||||
IFindSupport::Result BaseTextFind::findStep(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result BaseTextFind::findStep(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
bool found = find(txt, findFlags, textCursor());
|
||||
if (found)
|
||||
@@ -154,40 +154,40 @@ IFindSupport::Result BaseTextFind::findStep(const QString &txt, IFindSupport::Fi
|
||||
}
|
||||
|
||||
void BaseTextFind::replace(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = replaceInternal(before, after, findFlags);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
QTextCursor BaseTextFind::replaceInternal(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
bool usesRegExp = (findFlags & IFindSupport::FindRegularExpression);
|
||||
bool usesRegExp = (findFlags & Find::FindRegularExpression);
|
||||
QRegExp regexp(before,
|
||||
(findFlags & IFindSupport::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
(findFlags & Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
usesRegExp ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
|
||||
if (regexp.exactMatch(cursor.selectedText())) {
|
||||
QString realAfter = usesRegExp ? Utils::expandRegExpReplacement(after, regexp.capturedTexts()) : after;
|
||||
int start = cursor.selectionStart();
|
||||
cursor.insertText(realAfter);
|
||||
if ((findFlags&IFindSupport::FindBackward) != 0)
|
||||
if ((findFlags&Find::FindBackward) != 0)
|
||||
cursor.setPosition(start);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
bool BaseTextFind::replaceStep(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = replaceInternal(before, after, findFlags);
|
||||
return find(before, findFlags, cursor);
|
||||
}
|
||||
|
||||
int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTextCursor editCursor = textCursor();
|
||||
if (!m_findScopeStart.isNull())
|
||||
@@ -196,11 +196,11 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
editCursor.movePosition(QTextCursor::Start);
|
||||
editCursor.beginEditBlock();
|
||||
int count = 0;
|
||||
bool usesRegExp = (findFlags & IFindSupport::FindRegularExpression);
|
||||
bool usesRegExp = (findFlags & Find::FindRegularExpression);
|
||||
QRegExp regexp(before);
|
||||
regexp.setPatternSyntax(usesRegExp ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
regexp.setCaseSensitivity((findFlags & IFindSupport::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, editCursor, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
regexp.setCaseSensitivity((findFlags & Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, editCursor, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
while (!found.isNull() && found.selectionStart() < found.selectionEnd()
|
||||
&& inScope(found.selectionStart(), found.selectionEnd())) {
|
||||
++count;
|
||||
@@ -209,14 +209,14 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
regexp.exactMatch(found.selectedText());
|
||||
QString realAfter = usesRegExp ? Utils::expandRegExpReplacement(after, regexp.capturedTexts()) : after;
|
||||
editCursor.insertText(realAfter);
|
||||
found = findOne(regexp, editCursor, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, editCursor, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
editCursor.endEditBlock();
|
||||
return count;
|
||||
}
|
||||
|
||||
bool BaseTextFind::find(const QString &txt,
|
||||
IFindSupport::FindFlags findFlags,
|
||||
Find::FindFlags findFlags,
|
||||
QTextCursor start)
|
||||
{
|
||||
if (txt.isEmpty()) {
|
||||
@@ -224,19 +224,19 @@ bool BaseTextFind::find(const QString &txt,
|
||||
return true;
|
||||
}
|
||||
QRegExp regexp(txt);
|
||||
regexp.setPatternSyntax((findFlags&IFindSupport::FindRegularExpression) ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
regexp.setCaseSensitivity((findFlags&IFindSupport::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
regexp.setPatternSyntax((findFlags&Find::FindRegularExpression) ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
regexp.setCaseSensitivity((findFlags&Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, start, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
|
||||
if (!m_findScopeStart.isNull()) {
|
||||
|
||||
// scoped
|
||||
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd())) {
|
||||
if ((findFlags&IFindSupport::FindBackward) == 0)
|
||||
if ((findFlags&Find::FindBackward) == 0)
|
||||
start.setPosition(m_findScopeStart.position());
|
||||
else
|
||||
start.setPosition(m_findScopeEnd.position());
|
||||
found = findOne(regexp, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, start, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd()))
|
||||
return false;
|
||||
}
|
||||
@@ -244,11 +244,11 @@ bool BaseTextFind::find(const QString &txt,
|
||||
|
||||
// entire document
|
||||
if (found.isNull()) {
|
||||
if ((findFlags&IFindSupport::FindBackward) == 0)
|
||||
if ((findFlags&Find::FindBackward) == 0)
|
||||
start.movePosition(QTextCursor::Start);
|
||||
else
|
||||
start.movePosition(QTextCursor::End);
|
||||
found = findOne(regexp, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, start, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
if (found.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,34 +52,34 @@ public:
|
||||
BaseTextFind(QTextEdit *editor);
|
||||
|
||||
bool supportsReplace() const;
|
||||
IFindSupport::FindFlags supportedFindFlags() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
void resetIncrementalSearch();
|
||||
void clearResults();
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
Result findIncremental(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
|
||||
signals:
|
||||
void highlightAll(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
void highlightAll(const QString &txt, Find::FindFlags findFlags);
|
||||
void findScopeChanged(const QTextCursor &start, const QTextCursor &end, int verticalBlockSelection);
|
||||
|
||||
private:
|
||||
bool find(const QString &txt,
|
||||
IFindSupport::FindFlags findFlags,
|
||||
Find::FindFlags findFlags,
|
||||
QTextCursor start);
|
||||
QTextCursor replaceInternal(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
|
||||
QTextCursor textCursor() const;
|
||||
void setTextCursor(const QTextCursor&);
|
||||
|
||||
@@ -82,7 +82,7 @@ bool CurrentDocumentFind::supportsReplace() const
|
||||
return m_currentFind->supportsReplace();
|
||||
}
|
||||
|
||||
IFindSupport::FindFlags CurrentDocumentFind::supportedFindFlags() const
|
||||
Find::FindFlags CurrentDocumentFind::supportedFindFlags() const
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
return m_currentFind->supportedFindFlags();
|
||||
@@ -100,40 +100,40 @@ QString CurrentDocumentFind::completedFindString() const
|
||||
return m_currentFind->completedFindString();
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::highlightAll(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
void CurrentDocumentFind::highlightAll(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->highlightAll(txt, findFlags);
|
||||
}
|
||||
|
||||
IFindSupport::Result CurrentDocumentFind::findIncremental(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result CurrentDocumentFind::findIncremental(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
return m_currentFind->findIncremental(txt, findFlags);
|
||||
}
|
||||
|
||||
IFindSupport::Result CurrentDocumentFind::findStep(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result CurrentDocumentFind::findStep(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
return m_currentFind->findStep(txt, findFlags);
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::replace(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->replace(before, after, findFlags);
|
||||
}
|
||||
|
||||
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return false);
|
||||
return m_currentFind->replaceStep(before, after, findFlags);
|
||||
}
|
||||
|
||||
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
return m_currentFind->replaceAll(before, after, findFlags);
|
||||
|
||||
@@ -47,21 +47,21 @@ public:
|
||||
void resetIncrementalSearch();
|
||||
void clearResults();
|
||||
bool supportsReplace() const;
|
||||
IFindSupport::FindFlags supportedFindFlags() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
bool candidateIsEnabled() const;
|
||||
void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
IFindSupport::Result findIncremental(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
IFindSupport::Result findStep(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
void highlightAll(const QString &txt, Find::FindFlags findFlags);
|
||||
IFindSupport::Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
IFindSupport::Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags);
|
||||
Find::FindFlags findFlags);
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
void acceptCandidate();
|
||||
|
||||
@@ -361,6 +361,17 @@ QStringListModel *FindPlugin::replaceCompletionModel() const
|
||||
return d->m_replaceCompletionModel;
|
||||
}
|
||||
|
||||
QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
|
||||
{
|
||||
QTextDocument::FindFlags textDocFlags;
|
||||
if (flags & Find::FindBackward)
|
||||
textDocFlags |= QTextDocument::FindBackward;
|
||||
if (flags & Find::FindCaseSensitively)
|
||||
textDocFlags |= QTextDocument::FindCaseSensitively;
|
||||
if (flags & Find::FindWholeWords)
|
||||
textDocFlags |= QTextDocument::FindWholeWords;
|
||||
return textDocFlags;
|
||||
}
|
||||
|
||||
} // namespace Find
|
||||
|
||||
|
||||
@@ -383,13 +383,13 @@ void FindToolBar::invokeClearResults()
|
||||
|
||||
void FindToolBar::invokeFindNext()
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, false);
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
invokeFindStep();
|
||||
}
|
||||
|
||||
void FindToolBar::invokeFindPrevious()
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, true);
|
||||
setFindFlag(Find::FindBackward, true);
|
||||
invokeFindStep();
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ QString FindToolBar::getReplaceText()
|
||||
void FindToolBar::setFindText(const QString &text)
|
||||
{
|
||||
disconnect(m_ui.findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(invokeFindIncremental()));
|
||||
if (hasFindFlag(IFindSupport::FindRegularExpression))
|
||||
if (hasFindFlag(Find::FindRegularExpression))
|
||||
m_ui.findEdit->setText(QRegExp::escape(text));
|
||||
else
|
||||
m_ui.findEdit->setText(text);
|
||||
@@ -448,7 +448,7 @@ void FindToolBar::invokeFindIncremental()
|
||||
|
||||
void FindToolBar::invokeReplace()
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, false);
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||
m_plugin->updateFindCompletion(getFindText());
|
||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||
@@ -458,13 +458,13 @@ void FindToolBar::invokeReplace()
|
||||
|
||||
void FindToolBar::invokeReplaceNext()
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, false);
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
invokeReplaceStep();
|
||||
}
|
||||
|
||||
void FindToolBar::invokeReplacePrevious()
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, true);
|
||||
setFindFlag(Find::FindBackward, true);
|
||||
invokeReplaceStep();
|
||||
}
|
||||
|
||||
@@ -524,10 +524,10 @@ void FindToolBar::findFlagsChanged()
|
||||
|
||||
void FindToolBar::updateIcons()
|
||||
{
|
||||
IFindSupport::FindFlags effectiveFlags = effectiveFindFlags();
|
||||
bool casesensitive = effectiveFlags & IFindSupport::FindCaseSensitively;
|
||||
bool wholewords = effectiveFlags & IFindSupport::FindWholeWords;
|
||||
bool regexp = effectiveFlags & IFindSupport::FindRegularExpression;
|
||||
Find::FindFlags effectiveFlags = effectiveFindFlags();
|
||||
bool casesensitive = effectiveFlags & Find::FindCaseSensitively;
|
||||
bool wholewords = effectiveFlags & Find::FindWholeWords;
|
||||
bool regexp = effectiveFlags & Find::FindRegularExpression;
|
||||
int width = 0;
|
||||
if (casesensitive) width += 6;
|
||||
if (wholewords) width += 6;
|
||||
@@ -557,33 +557,33 @@ void FindToolBar::updateIcons()
|
||||
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left, pixmap);
|
||||
}
|
||||
|
||||
IFindSupport::FindFlags FindToolBar::effectiveFindFlags()
|
||||
Find::FindFlags FindToolBar::effectiveFindFlags()
|
||||
{
|
||||
IFindSupport::FindFlags supportedFlags;
|
||||
Find::FindFlags supportedFlags;
|
||||
if (m_currentDocumentFind->isEnabled())
|
||||
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||
else
|
||||
supportedFlags = (IFindSupport::FindFlags)0xFFFFFF;
|
||||
supportedFlags = (Find::FindFlags)0xFFFFFF;
|
||||
return supportedFlags & m_findFlags;
|
||||
}
|
||||
|
||||
void FindToolBar::updateFlagMenus()
|
||||
{
|
||||
bool wholeOnly = ((m_findFlags & IFindSupport::FindWholeWords));
|
||||
bool sensitive = ((m_findFlags & IFindSupport::FindCaseSensitively));
|
||||
bool regexp = ((m_findFlags & IFindSupport::FindRegularExpression));
|
||||
bool wholeOnly = ((m_findFlags & Find::FindWholeWords));
|
||||
bool sensitive = ((m_findFlags & Find::FindCaseSensitively));
|
||||
bool regexp = ((m_findFlags & Find::FindRegularExpression));
|
||||
if (m_wholeWordAction->isChecked() != wholeOnly)
|
||||
m_wholeWordAction->setChecked(wholeOnly);
|
||||
if (m_caseSensitiveAction->isChecked() != sensitive)
|
||||
m_caseSensitiveAction->setChecked(sensitive);
|
||||
if (m_regularExpressionAction->isChecked() != regexp)
|
||||
m_regularExpressionAction->setChecked(regexp);
|
||||
IFindSupport::FindFlags supportedFlags;
|
||||
Find::FindFlags supportedFlags;
|
||||
if (m_currentDocumentFind->isEnabled())
|
||||
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||
m_wholeWordAction->setEnabled(supportedFlags & IFindSupport::FindWholeWords);
|
||||
m_caseSensitiveAction->setEnabled(supportedFlags & IFindSupport::FindCaseSensitively);
|
||||
m_regularExpressionAction->setEnabled(supportedFlags & IFindSupport::FindRegularExpression);
|
||||
m_wholeWordAction->setEnabled(supportedFlags & Find::FindWholeWords);
|
||||
m_caseSensitiveAction->setEnabled(supportedFlags & Find::FindCaseSensitively);
|
||||
m_regularExpressionAction->setEnabled(supportedFlags & Find::FindRegularExpression);
|
||||
}
|
||||
|
||||
bool FindToolBar::setFocusToCurrentFindSupport()
|
||||
@@ -660,10 +660,10 @@ void FindToolBar::writeSettings()
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("Find");
|
||||
settings->beginGroup("FindToolBar");
|
||||
settings->setValue("Backward", QVariant((m_findFlags & IFindSupport::FindBackward) != 0));
|
||||
settings->setValue("CaseSensitively", QVariant((m_findFlags & IFindSupport::FindCaseSensitively) != 0));
|
||||
settings->setValue("WholeWords", QVariant((m_findFlags & IFindSupport::FindWholeWords) != 0));
|
||||
settings->setValue("RegularExpression", QVariant((m_findFlags & IFindSupport::FindRegularExpression) != 0));
|
||||
settings->setValue("Backward", QVariant((m_findFlags & Find::FindBackward) != 0));
|
||||
settings->setValue("CaseSensitively", QVariant((m_findFlags & Find::FindCaseSensitively) != 0));
|
||||
settings->setValue("WholeWords", QVariant((m_findFlags & Find::FindWholeWords) != 0));
|
||||
settings->setValue("RegularExpression", QVariant((m_findFlags & Find::FindRegularExpression) != 0));
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
}
|
||||
@@ -673,15 +673,15 @@ void FindToolBar::readSettings()
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("Find");
|
||||
settings->beginGroup("FindToolBar");
|
||||
IFindSupport::FindFlags flags;
|
||||
Find::FindFlags flags;
|
||||
if (settings->value("Backward", false).toBool())
|
||||
flags |= IFindSupport::FindBackward;
|
||||
flags |= Find::FindBackward;
|
||||
if (settings->value("CaseSensitively", false).toBool())
|
||||
flags |= IFindSupport::FindCaseSensitively;
|
||||
flags |= Find::FindCaseSensitively;
|
||||
if (settings->value("WholeWords", false).toBool())
|
||||
flags |= IFindSupport::FindWholeWords;
|
||||
flags |= Find::FindWholeWords;
|
||||
if (settings->value("RegularExpression", false).toBool())
|
||||
flags |= IFindSupport::FindRegularExpression;
|
||||
flags |= Find::FindRegularExpression;
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
m_findFlags = flags;
|
||||
@@ -693,7 +693,7 @@ void FindToolBar::setUseFakeVim(bool on)
|
||||
m_useFakeVim = on;
|
||||
}
|
||||
|
||||
void FindToolBar::setFindFlag(IFindSupport::FindFlag flag, bool enabled)
|
||||
void FindToolBar::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||
{
|
||||
bool hasFlag = hasFindFlag(flag);
|
||||
if ((hasFlag && enabled) || (!hasFlag && !enabled))
|
||||
@@ -702,31 +702,31 @@ void FindToolBar::setFindFlag(IFindSupport::FindFlag flag, bool enabled)
|
||||
m_findFlags |= flag;
|
||||
else
|
||||
m_findFlags &= ~flag;
|
||||
if (flag != IFindSupport::FindBackward)
|
||||
if (flag != Find::FindBackward)
|
||||
findFlagsChanged();
|
||||
}
|
||||
|
||||
bool FindToolBar::hasFindFlag(IFindSupport::FindFlag flag)
|
||||
bool FindToolBar::hasFindFlag(Find::FindFlag flag)
|
||||
{
|
||||
return m_findFlags & flag;
|
||||
}
|
||||
|
||||
void FindToolBar::setCaseSensitive(bool sensitive)
|
||||
{
|
||||
setFindFlag(IFindSupport::FindCaseSensitively, sensitive);
|
||||
setFindFlag(Find::FindCaseSensitively, sensitive);
|
||||
}
|
||||
|
||||
void FindToolBar::setWholeWord(bool wholeOnly)
|
||||
{
|
||||
setFindFlag(IFindSupport::FindWholeWords, wholeOnly);
|
||||
setFindFlag(Find::FindWholeWords, wholeOnly);
|
||||
}
|
||||
|
||||
void FindToolBar::setRegularExpressions(bool regexp)
|
||||
{
|
||||
setFindFlag(IFindSupport::FindRegularExpression, regexp);
|
||||
setFindFlag(Find::FindRegularExpression, regexp);
|
||||
}
|
||||
|
||||
void FindToolBar::setBackward(bool backward)
|
||||
{
|
||||
setFindFlag(IFindSupport::FindBackward, backward);
|
||||
setFindFlag(Find::FindBackward, backward);
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ private:
|
||||
void installEventFilters();
|
||||
void invokeClearResults();
|
||||
bool setFocusToCurrentFindSupport();
|
||||
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(IFindSupport::FindFlag flag);
|
||||
IFindSupport::FindFlags effectiveFindFlags();
|
||||
void setFindFlag(Find::FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(Find::FindFlag flag);
|
||||
Find::FindFlags effectiveFindFlags();
|
||||
Core::FindToolBarPlaceHolder *findToolBarPlaceHolder() const;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
QAction *m_caseSensitiveAction;
|
||||
QAction *m_wholeWordAction;
|
||||
QAction *m_regularExpressionAction;
|
||||
IFindSupport::FindFlags m_findFlags;
|
||||
Find::FindFlags m_findFlags;
|
||||
|
||||
QPixmap m_casesensitiveIcon;
|
||||
QPixmap m_regexpIcon;
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#define IFINDSUPPORT_H
|
||||
|
||||
#include "find_global.h"
|
||||
#include "textfindconstants.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QTextDocument>
|
||||
@@ -42,14 +44,6 @@ class FIND_EXPORT IFindSupport : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum FindFlag {
|
||||
FindBackward = 0x01,
|
||||
FindCaseSensitively = 0x02,
|
||||
FindWholeWords = 0x04,
|
||||
FindRegularExpression = 0x08
|
||||
};
|
||||
Q_DECLARE_FLAGS(FindFlags, FindFlag)
|
||||
|
||||
enum Result { Found, NotFound, NotYetFound };
|
||||
|
||||
IFindSupport() : QObject(0) {}
|
||||
@@ -75,18 +69,6 @@ public:
|
||||
virtual void defineFindScope(){}
|
||||
virtual void clearFindScope(){}
|
||||
|
||||
static QTextDocument::FindFlags textDocumentFlagsForFindFlags(IFindSupport::FindFlags flags)
|
||||
{
|
||||
QTextDocument::FindFlags textDocFlags;
|
||||
if (flags&IFindSupport::FindBackward)
|
||||
textDocFlags |= QTextDocument::FindBackward;
|
||||
if (flags&IFindSupport::FindCaseSensitively)
|
||||
textDocFlags |= QTextDocument::FindCaseSensitively;
|
||||
if (flags&IFindSupport::FindWholeWords)
|
||||
textDocFlags |= QTextDocument::FindWholeWords;
|
||||
return textDocFlags;
|
||||
}
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
@@ -95,6 +77,4 @@ inline void IFindSupport::highlightAll(const QString &, FindFlags) {}
|
||||
|
||||
} // namespace Find
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Find::IFindSupport::FindFlags)
|
||||
|
||||
#endif // IFINDSUPPORT_H
|
||||
|
||||
@@ -90,10 +90,10 @@ namespace Internal {
|
||||
|
||||
bool supportsReplace() const { return false; }
|
||||
|
||||
IFindSupport::FindFlags supportedFindFlags() const
|
||||
Find::FindFlags supportedFindFlags() const
|
||||
{
|
||||
return IFindSupport::FindBackward | IFindSupport::FindCaseSensitively
|
||||
| IFindSupport::FindRegularExpression | IFindSupport::FindWholeWords;
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindRegularExpression | Find::FindWholeWords;
|
||||
}
|
||||
|
||||
void resetIncrementalSearch()
|
||||
@@ -113,14 +113,14 @@ namespace Internal {
|
||||
return QString();
|
||||
}
|
||||
|
||||
void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
void highlightAll(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
Q_UNUSED(txt)
|
||||
Q_UNUSED(findFlags)
|
||||
return;
|
||||
}
|
||||
|
||||
IFindSupport::Result findIncremental(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result findIncremental(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
if (!m_incrementalFindStart.isValid())
|
||||
m_incrementalFindStart = m_view->currentIndex();
|
||||
@@ -128,7 +128,7 @@ namespace Internal {
|
||||
return find(txt, findFlags);
|
||||
}
|
||||
|
||||
IFindSupport::Result findStep(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result findStep(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
IFindSupport::Result result = find(txt, findFlags);
|
||||
if (result == IFindSupport::Found)
|
||||
@@ -136,19 +136,19 @@ namespace Internal {
|
||||
return result;
|
||||
}
|
||||
|
||||
IFindSupport::Result find(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||
IFindSupport::Result find(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
if (txt.isEmpty())
|
||||
return IFindSupport::NotFound;
|
||||
QModelIndex index;
|
||||
if (findFlags & IFindSupport::FindRegularExpression) {
|
||||
bool sensitive = (findFlags & IFindSupport::FindCaseSensitively);
|
||||
if (findFlags & Find::FindRegularExpression) {
|
||||
bool sensitive = (findFlags & Find::FindCaseSensitively);
|
||||
index = m_view->model()->find(QRegExp(txt, (sensitive ? Qt::CaseSensitive : Qt::CaseInsensitive)),
|
||||
m_view->currentIndex(),
|
||||
IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
} else {
|
||||
index = m_view->model()->find(txt, m_view->currentIndex(),
|
||||
IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||
Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
if (index.isValid()) {
|
||||
m_view->setCurrentIndex(index);
|
||||
@@ -161,7 +161,7 @@ namespace Internal {
|
||||
}
|
||||
|
||||
void replace(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
Q_UNUSED(before)
|
||||
Q_UNUSED(after)
|
||||
@@ -169,7 +169,7 @@ namespace Internal {
|
||||
}
|
||||
|
||||
bool replaceStep(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
Q_UNUSED(before)
|
||||
Q_UNUSED(after)
|
||||
@@ -178,7 +178,7 @@ namespace Internal {
|
||||
}
|
||||
|
||||
int replaceAll(const QString &before, const QString &after,
|
||||
IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
Q_UNUSED(before)
|
||||
Q_UNUSED(after)
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
#ifndef TEXTFINDCONSTANTS_H
|
||||
#define TEXTFINDCONSTANTS_H
|
||||
|
||||
#include "find_global.h"
|
||||
|
||||
#include <QtCore/QFlags>
|
||||
#include <QtGui/QTextDocument>
|
||||
|
||||
namespace Find {
|
||||
namespace Constants {
|
||||
|
||||
@@ -56,6 +61,20 @@ const char * const REGULAR_EXPRESSIONS="Find.RegularExpressions";
|
||||
const char * const TASK_SEARCH = "Find.Task.Search";
|
||||
|
||||
} // namespace Constants
|
||||
|
||||
enum FindFlag {
|
||||
FindBackward = 0x01,
|
||||
FindCaseSensitively = 0x02,
|
||||
FindWholeWords = 0x04,
|
||||
FindRegularExpression = 0x08
|
||||
};
|
||||
Q_DECLARE_FLAGS(FindFlags, FindFlag)
|
||||
|
||||
// defined in findplugin.cpp
|
||||
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
|
||||
|
||||
} // namespace Find
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Find::FindFlags)
|
||||
|
||||
#endif // TEXTFINDCONSTANTS_H
|
||||
|
||||
@@ -162,7 +162,7 @@ void CentralWidget::setCurrentPage(HelpViewer *page)
|
||||
emit currentViewerChanged();
|
||||
}
|
||||
|
||||
bool CentralWidget::find(const QString &txt, Find::IFindSupport::FindFlags flags,
|
||||
bool CentralWidget::find(const QString &txt, Find::FindFlags flags,
|
||||
bool incremental)
|
||||
{
|
||||
return currentHelpViewer()->findText(txt, flags, incremental, false);
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
int currentIndex() const;
|
||||
void setCurrentPage(HelpViewer *page);
|
||||
|
||||
bool find(const QString &txt, Find::IFindSupport::FindFlags findFlags,
|
||||
bool find(const QString &txt, Find::FindFlags findFlags,
|
||||
bool incremental);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -48,10 +48,10 @@ bool HelpFindSupport::isEnabled() const
|
||||
return true;
|
||||
}
|
||||
|
||||
Find::IFindSupport::FindFlags HelpFindSupport::supportedFindFlags() const
|
||||
Find::FindFlags HelpFindSupport::supportedFindFlags() const
|
||||
{
|
||||
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
|
||||
| Find::IFindSupport::FindWholeWords;
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindWholeWords;
|
||||
}
|
||||
|
||||
QString HelpFindSupport::currentFindString() const
|
||||
@@ -69,15 +69,15 @@ QString HelpFindSupport::completedFindString() const
|
||||
}
|
||||
|
||||
Find::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
|
||||
Find::IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_centralWidget, return NotFound);
|
||||
findFlags &= ~Find::IFindSupport::FindBackward;
|
||||
findFlags &= ~Find::FindBackward;
|
||||
return m_centralWidget->find(txt, findFlags, true) ? Found : NotFound;
|
||||
}
|
||||
|
||||
Find::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
|
||||
Find::IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_centralWidget, return NotFound);
|
||||
return m_centralWidget->find(txt, findFlags, false) ? Found : NotFound;
|
||||
@@ -90,10 +90,10 @@ HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
||||
{
|
||||
}
|
||||
|
||||
Find::IFindSupport::FindFlags HelpViewerFindSupport::supportedFindFlags() const
|
||||
Find::FindFlags HelpViewerFindSupport::supportedFindFlags() const
|
||||
{
|
||||
return Find::IFindSupport::FindBackward | Find::IFindSupport::FindCaseSensitively
|
||||
| Find::IFindSupport::FindWholeWords;
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindWholeWords;
|
||||
}
|
||||
|
||||
QString HelpViewerFindSupport::currentFindString() const
|
||||
@@ -103,22 +103,22 @@ QString HelpViewerFindSupport::currentFindString() const
|
||||
}
|
||||
|
||||
Find::IFindSupport::Result HelpViewerFindSupport::findIncremental(const QString &txt,
|
||||
Find::IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_viewer, return NotFound);
|
||||
findFlags &= ~Find::IFindSupport::FindBackward;
|
||||
findFlags &= ~Find::FindBackward;
|
||||
return find(txt, findFlags, true) ? Found : NotFound;
|
||||
}
|
||||
|
||||
Find::IFindSupport::Result HelpViewerFindSupport::findStep(const QString &txt,
|
||||
Find::IFindSupport::FindFlags findFlags)
|
||||
Find::FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_viewer, return NotFound);
|
||||
return find(txt, findFlags, false) ? Found : NotFound;
|
||||
}
|
||||
|
||||
bool HelpViewerFindSupport::find(const QString &txt,
|
||||
Find::IFindSupport::FindFlags findFlags, bool incremental)
|
||||
Find::FindFlags findFlags, bool incremental)
|
||||
{
|
||||
QTC_ASSERT(m_viewer, return false);
|
||||
return m_viewer->findText(txt, findFlags, incremental, false);
|
||||
|
||||
@@ -49,24 +49,24 @@ public:
|
||||
|
||||
bool isEnabled() const;
|
||||
bool supportsReplace() const { return false; }
|
||||
IFindSupport::FindFlags supportedFindFlags() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
|
||||
void resetIncrementalSearch() {}
|
||||
void clearResults() {}
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
Result findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
void replace(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { }
|
||||
Find::FindFlags ) { }
|
||||
bool replaceStep(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { return false; }
|
||||
Find::FindFlags ) { return false; }
|
||||
int replaceAll(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { return 0; }
|
||||
Find::FindFlags ) { return 0; }
|
||||
|
||||
private:
|
||||
bool find(const QString &ttf, Find::IFindSupport::FindFlags findFlags, bool incremental);
|
||||
bool find(const QString &ttf, Find::FindFlags findFlags, bool incremental);
|
||||
|
||||
CentralWidget *m_centralWidget;
|
||||
};
|
||||
@@ -79,23 +79,23 @@ public:
|
||||
|
||||
bool isEnabled() const { return true; }
|
||||
bool supportsReplace() const { return false; }
|
||||
IFindSupport::FindFlags supportedFindFlags() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
void resetIncrementalSearch() {}
|
||||
void clearResults() {}
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const { return QString(); }
|
||||
|
||||
Result findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
void replace(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { }
|
||||
Find::FindFlags ) { }
|
||||
bool replaceStep(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { return false; }
|
||||
Find::FindFlags ) { return false; }
|
||||
int replaceAll(const QString &, const QString &,
|
||||
Find::IFindSupport::FindFlags ) { return 0; }
|
||||
Find::FindFlags ) { return 0; }
|
||||
|
||||
private:
|
||||
bool find(const QString &ttf, Find::IFindSupport::FindFlags findFlags, bool incremental);
|
||||
bool find(const QString &ttf, Find::FindFlags findFlags, bool incremental);
|
||||
HelpViewer *m_viewer;
|
||||
};
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
bool isForwardAvailable() const;
|
||||
bool isBackwardAvailable() const;
|
||||
|
||||
bool findText(const QString &text, Find::IFindSupport::FindFlags flags,
|
||||
bool findText(const QString &text, Find::FindFlags flags,
|
||||
bool incremental, bool fromSearch);
|
||||
|
||||
static const QString NsNokia;
|
||||
|
||||
@@ -186,7 +186,7 @@ bool HelpViewer::isBackwardAvailable() const
|
||||
return QTextBrowser::isBackwardAvailable();
|
||||
}
|
||||
|
||||
bool HelpViewer::findText(const QString &text, IFindSupport::FindFlags flags,
|
||||
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
||||
bool incremental, bool fromSearch)
|
||||
{
|
||||
QTextDocument *doc = document();
|
||||
@@ -198,10 +198,10 @@ bool HelpViewer::findText(const QString &text, IFindSupport::FindFlags flags,
|
||||
if (incremental)
|
||||
cursor.setPosition(position);
|
||||
|
||||
QTextDocument::FindFlags f = IFindSupport::textDocumentFlagsForFindFlags(flags);
|
||||
QTextDocument::FindFlags f = Find::textDocumentFlagsForFindFlags(flags);
|
||||
QTextCursor found = doc->find(text, cursor, f);
|
||||
if (found.isNull()) {
|
||||
if ((flags & Find::IFindSupport::FindBackward) == 0)
|
||||
if ((flags & Find::FindBackward) == 0)
|
||||
cursor.movePosition(QTextCursor::Start);
|
||||
else
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
|
||||
@@ -338,14 +338,14 @@ bool HelpViewer::isBackwardAvailable() const
|
||||
return pageAction(QWebPage::Back)->isEnabled();
|
||||
}
|
||||
|
||||
bool HelpViewer::findText(const QString &text, IFindSupport::FindFlags flags,
|
||||
bool HelpViewer::findText(const QString &text, Find::FindFlags flags,
|
||||
bool incremental, bool fromSearch)
|
||||
{
|
||||
Q_UNUSED((incremental && fromSearch))
|
||||
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
|
||||
if (flags & Find::IFindSupport::FindBackward)
|
||||
if (flags & Find::FindBackward)
|
||||
options |= QWebPage::FindBackward;
|
||||
if (flags & Find::IFindSupport::FindCaseSensitively)
|
||||
if (flags & Find::FindCaseSensitively)
|
||||
options |= QWebPage::FindCaseSensitively;
|
||||
|
||||
bool found = QWebView::findText(text, options);
|
||||
|
||||
@@ -2137,7 +2137,7 @@ void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block,
|
||||
l = m_searchExpr.matchedLength();
|
||||
if (l == 0)
|
||||
break;
|
||||
if ((m_findFlags & Find::IFindSupport::FindWholeWords)
|
||||
if ((m_findFlags & Find::FindWholeWords)
|
||||
&& ((idx && text.at(idx-1).isLetterOrNumber())
|
||||
|| (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))
|
||||
continue;
|
||||
@@ -4254,7 +4254,7 @@ void BaseTextEditor::markBlocksAsChanged(QList<int> blockNumbers)
|
||||
}
|
||||
|
||||
|
||||
void BaseTextEditor::highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||
void BaseTextEditor::highlightSearchResults(const QString &txt, Find::FindFlags findFlags)
|
||||
{
|
||||
QString pattern = txt;
|
||||
if (pattern.size() < 2)
|
||||
@@ -4263,9 +4263,9 @@ void BaseTextEditor::highlightSearchResults(const QString &txt, Find::IFindSuppo
|
||||
if (d->m_searchExpr.pattern() == pattern)
|
||||
return;
|
||||
d->m_searchExpr.setPattern(pattern);
|
||||
d->m_searchExpr.setPatternSyntax((findFlags & Find::IFindSupport::FindRegularExpression) ?
|
||||
d->m_searchExpr.setPatternSyntax((findFlags & Find::FindRegularExpression) ?
|
||||
QRegExp::RegExp : QRegExp::FixedString);
|
||||
d->m_searchExpr.setCaseSensitivity((findFlags & Find::IFindSupport::FindCaseSensitively) ?
|
||||
d->m_searchExpr.setCaseSensitivity((findFlags & Find::FindCaseSensitively) ?
|
||||
Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
d->m_findFlags = findFlags;
|
||||
|
||||
@@ -5323,8 +5323,8 @@ BaseTextEditorEditable::BaseTextEditorEditable(BaseTextEditor *editor)
|
||||
using namespace Find;
|
||||
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
|
||||
BaseTextFind *baseTextFind = new BaseTextFind(editor);
|
||||
connect(baseTextFind, SIGNAL(highlightAll(QString, Find::IFindSupport::FindFlags)),
|
||||
editor, SLOT(highlightSearchResults(QString, Find::IFindSupport::FindFlags)));
|
||||
connect(baseTextFind, SIGNAL(highlightAll(QString, Find::FindFlags)),
|
||||
editor, SLOT(highlightSearchResults(QString, Find::FindFlags)));
|
||||
connect(baseTextFind, SIGNAL(findScopeChanged(QTextCursor, QTextCursor, int)),
|
||||
editor, SLOT(setFindScope(QTextCursor, QTextCursor, int)));
|
||||
aggregate->add(baseTextFind);
|
||||
|
||||
@@ -314,7 +314,7 @@ private slots:
|
||||
void editorContentsChange(int position, int charsRemoved, int charsAdded);
|
||||
void documentAboutToBeReloaded();
|
||||
void documentReloaded();
|
||||
void highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||
void highlightSearchResults(const QString &txt, Find::FindFlags findFlags);
|
||||
void setFindScope(const QTextCursor &start, const QTextCursor &end, int);
|
||||
void currentEditorChanged(Core::IEditor *editor);
|
||||
void maybeEmitContentsChangedBecauseOfUndo();
|
||||
|
||||
@@ -229,7 +229,7 @@ public:
|
||||
QTextCharFormat m_ifdefedOutFormat;
|
||||
|
||||
QRegExp m_searchExpr;
|
||||
Find::IFindSupport::FindFlags m_findFlags;
|
||||
Find::FindFlags m_findFlags;
|
||||
QTextCharFormat m_searchResultFormat;
|
||||
QTextCharFormat m_searchScopeFormat;
|
||||
QTextCharFormat m_currentLineFormat;
|
||||
|
||||
Reference in New Issue
Block a user