forked from qt-creator/qt-creator
Find: Remove some Find namespace usages
Change-Id: I3caf03474c7e080766b85c6a3042f6a29f13cd40 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -1401,8 +1401,8 @@ void FakeVimPluginPrivate::find(bool reverse)
|
||||
if (Find::FindPlugin *plugin = Find::FindPlugin::instance()) {
|
||||
plugin->setUseFakeVim(true);
|
||||
plugin->openFindToolBar(reverse
|
||||
? Find::FindPlugin::FindBackward
|
||||
: Find::FindPlugin::FindForward);
|
||||
? Find::FindPlugin::FindBackwardDirection
|
||||
: Find::FindPlugin::FindForwardDirection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,11 +121,10 @@ bool BaseTextFind::supportsReplace() const
|
||||
return !isReadOnly();
|
||||
}
|
||||
|
||||
Find::FindFlags BaseTextFind::supportedFindFlags() const
|
||||
FindFlags BaseTextFind::supportedFindFlags() const
|
||||
{
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindRegularExpression | Find::FindWholeWords
|
||||
| Find::FindPreserveCase;
|
||||
return FindBackward | FindCaseSensitively | FindRegularExpression
|
||||
| FindWholeWords | FindPreserveCase;
|
||||
}
|
||||
|
||||
void BaseTextFind::resetIncrementalSearch()
|
||||
@@ -172,7 +171,7 @@ QString BaseTextFind::completedFindString() const
|
||||
return cursor.selectedText();
|
||||
}
|
||||
|
||||
IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, Find::FindFlags findFlags)
|
||||
IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
if (d->m_incrementalStartPos < 0)
|
||||
@@ -191,7 +190,7 @@ IFindSupport::Result BaseTextFind::findIncremental(const QString &txt, Find::Fin
|
||||
return found ? Found : NotFound;
|
||||
}
|
||||
|
||||
IFindSupport::Result BaseTextFind::findStep(const QString &txt, Find::FindFlags findFlags)
|
||||
IFindSupport::Result BaseTextFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
bool wrapped = false;
|
||||
bool found = find(txt, findFlags, textCursor(), &wrapped);
|
||||
@@ -204,21 +203,20 @@ IFindSupport::Result BaseTextFind::findStep(const QString &txt, Find::FindFlags
|
||||
return found ? Found : NotFound;
|
||||
}
|
||||
|
||||
void BaseTextFind::replace(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
void BaseTextFind::replace(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = replaceInternal(before, after, findFlags);
|
||||
setTextCursor(cursor);
|
||||
}
|
||||
|
||||
QTextCursor BaseTextFind::replaceInternal(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
bool usesRegExp = (findFlags & Find::FindRegularExpression);
|
||||
bool preserveCase = (findFlags & Find::FindPreserveCase);
|
||||
bool usesRegExp = (findFlags & FindRegularExpression);
|
||||
bool preserveCase = (findFlags & FindPreserveCase);
|
||||
QRegExp regexp(before,
|
||||
(findFlags & Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
(findFlags & FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
usesRegExp ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
|
||||
if (regexp.exactMatch(cursor.selectedText())) {
|
||||
@@ -231,14 +229,13 @@ QTextCursor BaseTextFind::replaceInternal(const QString &before, const QString &
|
||||
realAfter = after;
|
||||
int start = cursor.selectionStart();
|
||||
cursor.insertText(realAfter);
|
||||
if ((findFlags&Find::FindBackward) != 0)
|
||||
if ((findFlags & FindBackward) != 0)
|
||||
cursor.setPosition(start);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
bool BaseTextFind::replaceStep(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
bool BaseTextFind::replaceStep(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTextCursor cursor = replaceInternal(before, after, findFlags);
|
||||
bool wrapped = false;
|
||||
@@ -248,8 +245,7 @@ bool BaseTextFind::replaceStep(const QString &before, const QString &after,
|
||||
return found;
|
||||
}
|
||||
|
||||
int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
int BaseTextFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTextCursor editCursor = textCursor();
|
||||
if (!d->m_findScopeStart.isNull())
|
||||
@@ -258,12 +254,12 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
editCursor.movePosition(QTextCursor::Start);
|
||||
editCursor.beginEditBlock();
|
||||
int count = 0;
|
||||
bool usesRegExp = (findFlags & Find::FindRegularExpression);
|
||||
bool preserveCase = (findFlags & Find::FindPreserveCase);
|
||||
bool usesRegExp = (findFlags & FindRegularExpression);
|
||||
bool preserveCase = (findFlags & FindPreserveCase);
|
||||
QRegExp regexp(before);
|
||||
regexp.setPatternSyntax(usesRegExp ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
regexp.setCaseSensitivity((findFlags & Find::FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, editCursor, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
regexp.setCaseSensitivity((findFlags & FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, editCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
bool first = true;
|
||||
while (!found.isNull() && inScope(found.selectionStart(), found.selectionEnd())) {
|
||||
if (found == editCursor && !first) {
|
||||
@@ -273,10 +269,10 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
// otherwise we would run into an endless loop for some regular expressions
|
||||
// like ^ or \b.
|
||||
QTextCursor newPosCursor = editCursor;
|
||||
newPosCursor.movePosition(findFlags & Find::FindBackward ?
|
||||
newPosCursor.movePosition(findFlags & FindBackward ?
|
||||
QTextCursor::PreviousCharacter :
|
||||
QTextCursor::NextCharacter);
|
||||
found = findOne(regexp, newPosCursor, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, newPosCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
continue;
|
||||
}
|
||||
if (first)
|
||||
@@ -294,13 +290,13 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||
else
|
||||
realAfter = after;
|
||||
editCursor.insertText(realAfter);
|
||||
found = findOne(regexp, editCursor, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, editCursor, textDocumentFlagsForFindFlags(findFlags));
|
||||
}
|
||||
editCursor.endEditBlock();
|
||||
return count;
|
||||
}
|
||||
|
||||
bool BaseTextFind::find(const QString &txt, Find::FindFlags findFlags,
|
||||
bool BaseTextFind::find(const QString &txt, FindFlags findFlags,
|
||||
QTextCursor start, bool *wrapped)
|
||||
{
|
||||
if (txt.isEmpty()) {
|
||||
@@ -308,9 +304,9 @@ bool BaseTextFind::find(const QString &txt, Find::FindFlags findFlags,
|
||||
return true;
|
||||
}
|
||||
QRegExp regexp(txt);
|
||||
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));
|
||||
regexp.setPatternSyntax((findFlags & FindRegularExpression) ? QRegExp::RegExp : QRegExp::FixedString);
|
||||
regexp.setCaseSensitivity((findFlags & FindCaseSensitively) ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
QTextCursor found = findOne(regexp, start, textDocumentFlagsForFindFlags(findFlags));
|
||||
if (wrapped)
|
||||
*wrapped = false;
|
||||
|
||||
@@ -318,11 +314,11 @@ bool BaseTextFind::find(const QString &txt, Find::FindFlags findFlags,
|
||||
|
||||
// scoped
|
||||
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd())) {
|
||||
if ((findFlags&Find::FindBackward) == 0)
|
||||
if ((findFlags & FindBackward) == 0)
|
||||
start.setPosition(d->m_findScopeStart.position());
|
||||
else
|
||||
start.setPosition(d->m_findScopeEnd.position());
|
||||
found = findOne(regexp, start, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, start, textDocumentFlagsForFindFlags(findFlags));
|
||||
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd()))
|
||||
return false;
|
||||
if (wrapped)
|
||||
@@ -332,11 +328,11 @@ bool BaseTextFind::find(const QString &txt, Find::FindFlags findFlags,
|
||||
|
||||
// entire document
|
||||
if (found.isNull()) {
|
||||
if ((findFlags&Find::FindBackward) == 0)
|
||||
if ((findFlags & FindBackward) == 0)
|
||||
start.movePosition(QTextCursor::Start);
|
||||
else
|
||||
start.movePosition(QTextCursor::End);
|
||||
found = findOne(regexp, start, Find::textDocumentFlagsForFindFlags(findFlags));
|
||||
found = findOne(regexp, start, textDocumentFlagsForFindFlags(findFlags));
|
||||
if (found.isNull())
|
||||
return false;
|
||||
if (wrapped)
|
||||
|
||||
@@ -42,7 +42,7 @@ QT_END_NAMESPACE
|
||||
namespace Find {
|
||||
struct BaseTextFindPrivate;
|
||||
|
||||
class FIND_EXPORT BaseTextFind : public Find::IFindSupport
|
||||
class FIND_EXPORT BaseTextFind : public IFindSupport
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -52,20 +52,17 @@ public:
|
||||
virtual ~BaseTextFind();
|
||||
|
||||
bool supportsReplace() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
FindFlags supportedFindFlags() const;
|
||||
void resetIncrementalSearch();
|
||||
void clearResults();
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, FindFlags findFlags);
|
||||
Result findStep(const QString &txt, FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after, FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after, FindFlags findFlags);
|
||||
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
@@ -77,12 +74,8 @@ signals:
|
||||
int verticalBlockSelectionLastColumn);
|
||||
|
||||
private:
|
||||
bool find(const QString &txt,
|
||||
Find::FindFlags findFlags,
|
||||
QTextCursor start,
|
||||
bool *wrapped);
|
||||
QTextCursor replaceInternal(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
bool find(const QString &txt, FindFlags findFlags, QTextCursor start, bool *wrapped);
|
||||
QTextCursor replaceInternal(const QString &before, const QString &after, FindFlags findFlags);
|
||||
|
||||
QTextCursor textCursor() const;
|
||||
void setTextCursor(const QTextCursor&);
|
||||
|
||||
@@ -82,7 +82,7 @@ bool CurrentDocumentFind::supportsReplace() const
|
||||
return m_currentFind->supportsReplace();
|
||||
}
|
||||
|
||||
Find::FindFlags CurrentDocumentFind::supportedFindFlags() const
|
||||
FindFlags CurrentDocumentFind::supportedFindFlags() const
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
return m_currentFind->supportedFindFlags();
|
||||
@@ -100,40 +100,37 @@ QString CurrentDocumentFind::completedFindString() const
|
||||
return m_currentFind->completedFindString();
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::highlightAll(const QString &txt, Find::FindFlags findFlags)
|
||||
void CurrentDocumentFind::highlightAll(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->highlightAll(txt, findFlags);
|
||||
}
|
||||
|
||||
IFindSupport::Result CurrentDocumentFind::findIncremental(const QString &txt, Find::FindFlags findFlags)
|
||||
IFindSupport::Result CurrentDocumentFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
return m_currentFind->findIncremental(txt, findFlags);
|
||||
}
|
||||
|
||||
IFindSupport::Result CurrentDocumentFind::findStep(const QString &txt, Find::FindFlags findFlags)
|
||||
IFindSupport::Result CurrentDocumentFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return IFindSupport::NotFound);
|
||||
return m_currentFind->findStep(txt, findFlags);
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::replace(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
void CurrentDocumentFind::replace(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return);
|
||||
m_currentFind->replace(before, after, findFlags);
|
||||
}
|
||||
|
||||
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return false);
|
||||
return m_currentFind->replaceStep(before, after, findFlags);
|
||||
}
|
||||
|
||||
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags)
|
||||
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return 0);
|
||||
return m_currentFind->replaceAll(before, after, findFlags);
|
||||
|
||||
@@ -47,21 +47,18 @@ public:
|
||||
void resetIncrementalSearch();
|
||||
void clearResults();
|
||||
bool supportsReplace() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
FindFlags supportedFindFlags() const;
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
bool candidateIsEnabled() const;
|
||||
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,
|
||||
Find::FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after,
|
||||
Find::FindFlags findFlags);
|
||||
void highlightAll(const QString &txt, FindFlags findFlags);
|
||||
IFindSupport::Result findIncremental(const QString &txt, FindFlags findFlags);
|
||||
IFindSupport::Result findStep(const QString &txt, FindFlags findFlags);
|
||||
void replace(const QString &before, const QString &after, FindFlags findFlags);
|
||||
bool replaceStep(const QString &before, const QString &after, FindFlags findFlags);
|
||||
int replaceAll(const QString &before, const QString &after, FindFlags findFlags);
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
void acceptCandidate();
|
||||
|
||||
@@ -74,7 +74,8 @@ namespace {
|
||||
|
||||
namespace Find {
|
||||
|
||||
struct FindPluginPrivate {
|
||||
class FindPluginPrivate {
|
||||
public:
|
||||
explicit FindPluginPrivate(FindPlugin *q);
|
||||
|
||||
//variables
|
||||
@@ -85,7 +86,7 @@ struct FindPluginPrivate {
|
||||
Internal::CurrentDocumentFind *m_currentDocumentFind;
|
||||
Internal::FindToolBar *m_findToolBar;
|
||||
Internal::FindToolWindow *m_findDialog;
|
||||
Find::FindFlags m_findFlags;
|
||||
FindFlags m_findFlags;
|
||||
QStringListModel *m_findCompletionModel;
|
||||
QStringListModel *m_replaceCompletionModel;
|
||||
QStringList m_findCompletions;
|
||||
@@ -244,37 +245,37 @@ void FindPlugin::setupFilterMenuItems()
|
||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
}
|
||||
|
||||
Find::FindFlags FindPlugin::findFlags() const
|
||||
FindFlags FindPlugin::findFlags() const
|
||||
{
|
||||
return d->m_findFlags;
|
||||
}
|
||||
|
||||
void FindPlugin::setCaseSensitive(bool sensitive)
|
||||
{
|
||||
setFindFlag(Find::FindCaseSensitively, sensitive);
|
||||
setFindFlag(FindCaseSensitively, sensitive);
|
||||
}
|
||||
|
||||
void FindPlugin::setWholeWord(bool wholeOnly)
|
||||
{
|
||||
setFindFlag(Find::FindWholeWords, wholeOnly);
|
||||
setFindFlag(FindWholeWords, wholeOnly);
|
||||
}
|
||||
|
||||
void FindPlugin::setBackward(bool backward)
|
||||
{
|
||||
setFindFlag(Find::FindBackward, backward);
|
||||
setFindFlag(FindBackward, backward);
|
||||
}
|
||||
|
||||
void FindPlugin::setRegularExpression(bool regExp)
|
||||
{
|
||||
setFindFlag(Find::FindRegularExpression, regExp);
|
||||
setFindFlag(FindRegularExpression, regExp);
|
||||
}
|
||||
|
||||
void FindPlugin::setPreserveCase(bool preserveCase)
|
||||
{
|
||||
setFindFlag(Find::FindPreserveCase, preserveCase);
|
||||
setFindFlag(FindPreserveCase, preserveCase);
|
||||
}
|
||||
|
||||
void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||
void FindPlugin::setFindFlag(FindFlag flag, bool enabled)
|
||||
{
|
||||
bool hasFlag = hasFindFlag(flag);
|
||||
if ((hasFlag && enabled) || (!hasFlag && !enabled))
|
||||
@@ -283,11 +284,11 @@ void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||
d->m_findFlags |= flag;
|
||||
else
|
||||
d->m_findFlags &= ~flag;
|
||||
if (flag != Find::FindBackward)
|
||||
if (flag != FindBackward)
|
||||
emit findFlagsChanged();
|
||||
}
|
||||
|
||||
bool FindPlugin::hasFindFlag(Find::FindFlag flag)
|
||||
bool FindPlugin::hasFindFlag(FindFlag flag)
|
||||
{
|
||||
return d->m_findFlags & flag;
|
||||
}
|
||||
@@ -296,11 +297,11 @@ void FindPlugin::writeSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->setValue(QLatin1String("Backward"), hasFindFlag(Find::FindBackward));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), hasFindFlag(Find::FindCaseSensitively));
|
||||
settings->setValue(QLatin1String("WholeWords"), hasFindFlag(Find::FindWholeWords));
|
||||
settings->setValue(QLatin1String("RegularExpression"), hasFindFlag(Find::FindRegularExpression));
|
||||
settings->setValue(QLatin1String("PreserveCase"), hasFindFlag(Find::FindPreserveCase));
|
||||
settings->setValue(QLatin1String("Backward"), hasFindFlag(FindBackward));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), hasFindFlag(FindCaseSensitively));
|
||||
settings->setValue(QLatin1String("WholeWords"), hasFindFlag(FindWholeWords));
|
||||
settings->setValue(QLatin1String("RegularExpression"), hasFindFlag(FindRegularExpression));
|
||||
settings->setValue(QLatin1String("PreserveCase"), hasFindFlag(FindPreserveCase));
|
||||
settings->setValue(QLatin1String("FindStrings"), d->m_findCompletions);
|
||||
settings->setValue(QLatin1String("ReplaceStrings"), d->m_replaceCompletions);
|
||||
settings->endGroup();
|
||||
@@ -359,7 +360,7 @@ void FindPlugin::setUseFakeVim(bool on)
|
||||
void FindPlugin::openFindToolBar(FindDirection direction)
|
||||
{
|
||||
if (d->m_findToolBar) {
|
||||
d->m_findToolBar->setBackward(direction == FindBackward);
|
||||
d->m_findToolBar->setBackward(direction == FindBackwardDirection);
|
||||
d->m_findToolBar->openFindToolBar();
|
||||
}
|
||||
}
|
||||
@@ -385,7 +386,7 @@ QKeySequence IFindFilter::defaultShortcut() const
|
||||
QTextDocument::FindFlags Find::textDocumentFlagsForFindFlags(Find::FindFlags flags)
|
||||
{
|
||||
QTextDocument::FindFlags textDocFlags;
|
||||
if (flags & Find::FindBackward)
|
||||
if (flags & FindBackward)
|
||||
textDocFlags |= QTextDocument::FindBackward;
|
||||
if (flags & Find::FindCaseSensitively)
|
||||
textDocFlags |= QTextDocument::FindCaseSensitively;
|
||||
|
||||
@@ -41,7 +41,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Find {
|
||||
class IFindFilter;
|
||||
struct FindPluginPrivate;
|
||||
class FindPluginPrivate;
|
||||
|
||||
namespace Internal {
|
||||
class FindToolBar;
|
||||
@@ -59,8 +59,8 @@ public:
|
||||
static FindPlugin *instance();
|
||||
|
||||
enum FindDirection {
|
||||
FindForward,
|
||||
FindBackward
|
||||
FindForwardDirection,
|
||||
FindBackwardDirection
|
||||
};
|
||||
|
||||
// IPlugin
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
void extensionsInitialized();
|
||||
ShutdownFlag aboutToShutdown();
|
||||
|
||||
Find::FindFlags findFlags() const;
|
||||
bool hasFindFlag(Find::FindFlag flag);
|
||||
FindFlags findFlags() const;
|
||||
bool hasFindFlag(FindFlag flag);
|
||||
void updateFindCompletion(const QString &text);
|
||||
void updateReplaceCompletion(const QString &text);
|
||||
QStringListModel *findCompletionModel() const;
|
||||
@@ -93,7 +93,7 @@ private slots:
|
||||
void openFindFilter();
|
||||
|
||||
private:
|
||||
void setFindFlag(Find::FindFlag flag, bool enabled);
|
||||
void setFindFlag(FindFlag flag, bool enabled);
|
||||
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
|
||||
void setupMenu();
|
||||
void setupFilterMenuItems();
|
||||
|
||||
@@ -369,7 +369,7 @@ void FindToolBar::updateToolBar()
|
||||
m_caseSensitiveAction->setEnabled(enabled);
|
||||
m_wholeWordAction->setEnabled(enabled);
|
||||
m_regularExpressionAction->setEnabled(enabled);
|
||||
m_preserveCaseAction->setEnabled(replaceEnabled && !hasFindFlag(Find::FindRegularExpression));
|
||||
m_preserveCaseAction->setEnabled(replaceEnabled && !hasFindFlag(FindRegularExpression));
|
||||
if (QApplication::clipboard()->supportsFindBuffer())
|
||||
m_enterFindStringAction->setEnabled(enabled);
|
||||
bool replaceFocus = m_ui.replaceEdit->hasFocus();
|
||||
@@ -415,13 +415,13 @@ void FindToolBar::invokeClearResults()
|
||||
|
||||
void FindToolBar::invokeFindNext()
|
||||
{
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
setFindFlag(FindBackward, false);
|
||||
invokeFindStep();
|
||||
}
|
||||
|
||||
void FindToolBar::invokeFindPrevious()
|
||||
{
|
||||
setFindFlag(Find::FindBackward, true);
|
||||
setFindFlag(FindBackward, true);
|
||||
invokeFindStep();
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ QString FindToolBar::getReplaceText()
|
||||
void FindToolBar::setFindText(const QString &text)
|
||||
{
|
||||
disconnect(m_ui.findEdit, SIGNAL(textChanged(QString)), this, SLOT(invokeFindIncremental()));
|
||||
if (hasFindFlag(Find::FindRegularExpression))
|
||||
if (hasFindFlag(FindRegularExpression))
|
||||
m_ui.findEdit->setText(QRegExp::escape(text));
|
||||
else
|
||||
m_ui.findEdit->setText(text);
|
||||
@@ -480,7 +480,7 @@ void FindToolBar::invokeFindIncremental()
|
||||
|
||||
void FindToolBar::invokeReplace()
|
||||
{
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
setFindFlag(FindBackward, false);
|
||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||
m_plugin->updateFindCompletion(getFindText());
|
||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||
@@ -490,13 +490,13 @@ void FindToolBar::invokeReplace()
|
||||
|
||||
void FindToolBar::invokeReplaceNext()
|
||||
{
|
||||
setFindFlag(Find::FindBackward, false);
|
||||
setFindFlag(FindBackward, false);
|
||||
invokeReplaceStep();
|
||||
}
|
||||
|
||||
void FindToolBar::invokeReplacePrevious()
|
||||
{
|
||||
setFindFlag(Find::FindBackward, true);
|
||||
setFindFlag(FindBackward, true);
|
||||
invokeReplaceStep();
|
||||
}
|
||||
|
||||
@@ -554,11 +554,11 @@ void FindToolBar::findFlagsChanged()
|
||||
|
||||
void FindToolBar::updateIcons()
|
||||
{
|
||||
Find::FindFlags effectiveFlags = effectiveFindFlags();
|
||||
bool casesensitive = effectiveFlags & Find::FindCaseSensitively;
|
||||
bool wholewords = effectiveFlags & Find::FindWholeWords;
|
||||
bool regexp = effectiveFlags & Find::FindRegularExpression;
|
||||
bool preserveCase = effectiveFlags & Find::FindPreserveCase;
|
||||
FindFlags effectiveFlags = effectiveFindFlags();
|
||||
bool casesensitive = effectiveFlags & FindCaseSensitively;
|
||||
bool wholewords = effectiveFlags & FindWholeWords;
|
||||
bool regexp = effectiveFlags & FindRegularExpression;
|
||||
bool preserveCase = effectiveFlags & FindPreserveCase;
|
||||
if (!casesensitive && !wholewords && !regexp && !preserveCase) {
|
||||
QPixmap pixmap(17, 17);
|
||||
pixmap.fill(Qt::transparent);
|
||||
@@ -572,27 +572,27 @@ void FindToolBar::updateIcons()
|
||||
}
|
||||
}
|
||||
|
||||
Find::FindFlags FindToolBar::effectiveFindFlags()
|
||||
FindFlags FindToolBar::effectiveFindFlags()
|
||||
{
|
||||
Find::FindFlags supportedFlags;
|
||||
FindFlags supportedFlags;
|
||||
bool supportsReplace = true;
|
||||
if (m_currentDocumentFind->isEnabled()) {
|
||||
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||
supportsReplace = m_currentDocumentFind->supportsReplace();
|
||||
} else {
|
||||
supportedFlags = (Find::FindFlags)0xFFFFFF;
|
||||
supportedFlags = (FindFlags)0xFFFFFF;
|
||||
}
|
||||
if (!supportsReplace || m_findFlags & Find::FindRegularExpression)
|
||||
supportedFlags &= ~Find::FindPreserveCase;
|
||||
if (!supportsReplace || m_findFlags & FindRegularExpression)
|
||||
supportedFlags &= ~FindPreserveCase;
|
||||
return supportedFlags & m_findFlags;
|
||||
}
|
||||
|
||||
void FindToolBar::updateFlagMenus()
|
||||
{
|
||||
bool wholeOnly = ((m_findFlags & Find::FindWholeWords));
|
||||
bool sensitive = ((m_findFlags & Find::FindCaseSensitively));
|
||||
bool regexp = ((m_findFlags & Find::FindRegularExpression));
|
||||
bool preserveCase = ((m_findFlags & Find::FindPreserveCase));
|
||||
bool wholeOnly = ((m_findFlags & FindWholeWords));
|
||||
bool sensitive = ((m_findFlags & FindCaseSensitively));
|
||||
bool regexp = ((m_findFlags & FindRegularExpression));
|
||||
bool preserveCase = ((m_findFlags & FindPreserveCase));
|
||||
if (m_wholeWordAction->isChecked() != wholeOnly)
|
||||
m_wholeWordAction->setChecked(wholeOnly);
|
||||
if (m_caseSensitiveAction->isChecked() != sensitive)
|
||||
@@ -601,14 +601,14 @@ void FindToolBar::updateFlagMenus()
|
||||
m_regularExpressionAction->setChecked(regexp);
|
||||
if (m_preserveCaseAction->isChecked() != preserveCase)
|
||||
m_preserveCaseAction->setChecked(preserveCase);
|
||||
Find::FindFlags supportedFlags;
|
||||
FindFlags supportedFlags;
|
||||
if (m_currentDocumentFind->isEnabled())
|
||||
supportedFlags = m_currentDocumentFind->supportedFindFlags();
|
||||
m_wholeWordAction->setEnabled(supportedFlags & Find::FindWholeWords);
|
||||
m_caseSensitiveAction->setEnabled(supportedFlags & Find::FindCaseSensitively);
|
||||
m_regularExpressionAction->setEnabled(supportedFlags & Find::FindRegularExpression);
|
||||
m_wholeWordAction->setEnabled(supportedFlags & FindWholeWords);
|
||||
m_caseSensitiveAction->setEnabled(supportedFlags & FindCaseSensitively);
|
||||
m_regularExpressionAction->setEnabled(supportedFlags & FindRegularExpression);
|
||||
bool replaceEnabled = m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace();
|
||||
m_preserveCaseAction->setEnabled((supportedFlags & Find::FindPreserveCase) && !regexp && replaceEnabled);
|
||||
m_preserveCaseAction->setEnabled((supportedFlags & FindPreserveCase) && !regexp && replaceEnabled);
|
||||
}
|
||||
|
||||
bool FindToolBar::setFocusToCurrentFindSupport()
|
||||
@@ -698,11 +698,11 @@ void FindToolBar::writeSettings()
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->beginGroup(QLatin1String("FindToolBar"));
|
||||
settings->setValue(QLatin1String("Backward"), QVariant((m_findFlags & Find::FindBackward) != 0));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), QVariant((m_findFlags & Find::FindCaseSensitively) != 0));
|
||||
settings->setValue(QLatin1String("WholeWords"), QVariant((m_findFlags & Find::FindWholeWords) != 0));
|
||||
settings->setValue(QLatin1String("RegularExpression"), QVariant((m_findFlags & Find::FindRegularExpression) != 0));
|
||||
settings->setValue(QLatin1String("PreserveCase"), QVariant((m_findFlags & Find::FindPreserveCase) != 0));
|
||||
settings->setValue(QLatin1String("Backward"), QVariant((m_findFlags & FindBackward) != 0));
|
||||
settings->setValue(QLatin1String("CaseSensitively"), QVariant((m_findFlags & FindCaseSensitively) != 0));
|
||||
settings->setValue(QLatin1String("WholeWords"), QVariant((m_findFlags & FindWholeWords) != 0));
|
||||
settings->setValue(QLatin1String("RegularExpression"), QVariant((m_findFlags & FindRegularExpression) != 0));
|
||||
settings->setValue(QLatin1String("PreserveCase"), QVariant((m_findFlags & FindPreserveCase) != 0));
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
}
|
||||
@@ -712,17 +712,17 @@ void FindToolBar::readSettings()
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("Find"));
|
||||
settings->beginGroup(QLatin1String("FindToolBar"));
|
||||
Find::FindFlags flags;
|
||||
FindFlags flags;
|
||||
if (settings->value(QLatin1String("Backward"), false).toBool())
|
||||
flags |= Find::FindBackward;
|
||||
flags |= FindBackward;
|
||||
if (settings->value(QLatin1String("CaseSensitively"), false).toBool())
|
||||
flags |= Find::FindCaseSensitively;
|
||||
flags |= FindCaseSensitively;
|
||||
if (settings->value(QLatin1String("WholeWords"), false).toBool())
|
||||
flags |= Find::FindWholeWords;
|
||||
flags |= FindWholeWords;
|
||||
if (settings->value(QLatin1String("RegularExpression"), false).toBool())
|
||||
flags |= Find::FindRegularExpression;
|
||||
flags |= FindRegularExpression;
|
||||
if (settings->value(QLatin1String("PreserveCase"), false).toBool())
|
||||
flags |= Find::FindPreserveCase;
|
||||
flags |= FindPreserveCase;
|
||||
settings->endGroup();
|
||||
settings->endGroup();
|
||||
m_findFlags = flags;
|
||||
@@ -734,7 +734,7 @@ void FindToolBar::setUseFakeVim(bool on)
|
||||
m_useFakeVim = on;
|
||||
}
|
||||
|
||||
void FindToolBar::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||
void FindToolBar::setFindFlag(FindFlag flag, bool enabled)
|
||||
{
|
||||
bool hasFlag = hasFindFlag(flag);
|
||||
if ((hasFlag && enabled) || (!hasFlag && !enabled))
|
||||
@@ -743,36 +743,36 @@ void FindToolBar::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||
m_findFlags |= flag;
|
||||
else
|
||||
m_findFlags &= ~flag;
|
||||
if (flag != Find::FindBackward)
|
||||
if (flag != FindBackward)
|
||||
findFlagsChanged();
|
||||
}
|
||||
|
||||
bool FindToolBar::hasFindFlag(Find::FindFlag flag)
|
||||
bool FindToolBar::hasFindFlag(FindFlag flag)
|
||||
{
|
||||
return m_findFlags & flag;
|
||||
}
|
||||
|
||||
void FindToolBar::setCaseSensitive(bool sensitive)
|
||||
{
|
||||
setFindFlag(Find::FindCaseSensitively, sensitive);
|
||||
setFindFlag(FindCaseSensitively, sensitive);
|
||||
}
|
||||
|
||||
void FindToolBar::setWholeWord(bool wholeOnly)
|
||||
{
|
||||
setFindFlag(Find::FindWholeWords, wholeOnly);
|
||||
setFindFlag(FindWholeWords, wholeOnly);
|
||||
}
|
||||
|
||||
void FindToolBar::setRegularExpressions(bool regexp)
|
||||
{
|
||||
setFindFlag(Find::FindRegularExpression, regexp);
|
||||
setFindFlag(FindRegularExpression, regexp);
|
||||
}
|
||||
|
||||
void FindToolBar::setPreserveCase(bool preserveCase)
|
||||
{
|
||||
setFindFlag(Find::FindPreserveCase, preserveCase);
|
||||
setFindFlag(FindPreserveCase, preserveCase);
|
||||
}
|
||||
|
||||
void FindToolBar::setBackward(bool backward)
|
||||
{
|
||||
setFindFlag(Find::FindBackward, backward);
|
||||
setFindFlag(FindBackward, backward);
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ private:
|
||||
void installEventFilters();
|
||||
void invokeClearResults();
|
||||
bool setFocusToCurrentFindSupport();
|
||||
void setFindFlag(Find::FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(Find::FindFlag flag);
|
||||
Find::FindFlags effectiveFindFlags();
|
||||
void setFindFlag(FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(FindFlag flag);
|
||||
FindFlags effectiveFindFlags();
|
||||
Core::FindToolBarPlaceHolder *findToolBarPlaceHolder() const;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
QAction *m_wholeWordAction;
|
||||
QAction *m_regularExpressionAction;
|
||||
QAction *m_preserveCaseAction;
|
||||
Find::FindFlags m_findFlags;
|
||||
FindFlags m_findFlags;
|
||||
|
||||
QTimer m_findIncrementalTimer;
|
||||
QTimer m_findStepTimer;
|
||||
|
||||
@@ -124,19 +124,19 @@ void FindToolWindow::updateButtonStates()
|
||||
m_configWidget->setEnabled(filterEnabled);
|
||||
|
||||
m_ui.matchCase->setEnabled(filterEnabled
|
||||
&& (m_currentFilter->supportedFindFlags() & Find::FindCaseSensitively));
|
||||
&& (m_currentFilter->supportedFindFlags() & FindCaseSensitively));
|
||||
m_ui.wholeWords->setEnabled(filterEnabled
|
||||
&& (m_currentFilter->supportedFindFlags() & Find::FindWholeWords));
|
||||
&& (m_currentFilter->supportedFindFlags() & FindWholeWords));
|
||||
m_ui.regExp->setEnabled(filterEnabled
|
||||
&& (m_currentFilter->supportedFindFlags() & Find::FindRegularExpression));
|
||||
&& (m_currentFilter->supportedFindFlags() & FindRegularExpression));
|
||||
m_ui.searchTerm->setEnabled(filterEnabled);
|
||||
}
|
||||
|
||||
void FindToolWindow::updateFindFlags()
|
||||
{
|
||||
m_ui.matchCase->setChecked(m_plugin->hasFindFlag(Find::FindCaseSensitively));
|
||||
m_ui.wholeWords->setChecked(m_plugin->hasFindFlag(Find::FindWholeWords));
|
||||
m_ui.regExp->setChecked(m_plugin->hasFindFlag(Find::FindRegularExpression));
|
||||
m_ui.matchCase->setChecked(m_plugin->hasFindFlag(FindCaseSensitively));
|
||||
m_ui.wholeWords->setChecked(m_plugin->hasFindFlag(FindWholeWords));
|
||||
m_ui.regExp->setChecked(m_plugin->hasFindFlag(FindRegularExpression));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -215,22 +215,25 @@
|
||||
The default is Find::FindCaseSensitively, Find::FindRegularExpression
|
||||
and Find::FindWholeWords
|
||||
*/
|
||||
Find::FindFlags Find::IFindFilter::supportedFindFlags() const
|
||||
|
||||
namespace Find {
|
||||
|
||||
FindFlags IFindFilter::supportedFindFlags() const
|
||||
{
|
||||
return Find::FindCaseSensitively
|
||||
| Find::FindRegularExpression | Find::FindWholeWords;
|
||||
return FindCaseSensitively
|
||||
| FindRegularExpression | FindWholeWords;
|
||||
}
|
||||
|
||||
QPixmap Find::IFindFilter::pixmapForFindFlags(Find::FindFlags flags)
|
||||
QPixmap IFindFilter::pixmapForFindFlags(FindFlags flags)
|
||||
{
|
||||
static const QPixmap casesensitiveIcon = QPixmap(QLatin1String(":/find/images/casesensitively.png"));
|
||||
static const QPixmap regexpIcon = QPixmap(QLatin1String(":/find/images/regexp.png"));
|
||||
static const QPixmap wholewordsIcon = QPixmap(QLatin1String(":/find/images/wholewords.png"));
|
||||
static const QPixmap preservecaseIcon = QPixmap(QLatin1String(":/find/images/preservecase.png"));
|
||||
bool casesensitive = flags & Find::FindCaseSensitively;
|
||||
bool wholewords = flags & Find::FindWholeWords;
|
||||
bool regexp = flags & Find::FindRegularExpression;
|
||||
bool preservecase = flags & Find::FindPreserveCase;
|
||||
bool casesensitive = flags & FindCaseSensitively;
|
||||
bool wholewords = flags & FindWholeWords;
|
||||
bool regexp = flags & FindRegularExpression;
|
||||
bool preservecase = flags & FindPreserveCase;
|
||||
int width = 0;
|
||||
if (casesensitive) width += 6;
|
||||
if (wholewords) width += 6;
|
||||
@@ -259,16 +262,16 @@ QPixmap Find::IFindFilter::pixmapForFindFlags(Find::FindFlags flags)
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QString Find::IFindFilter::descriptionForFindFlags(Find::FindFlags flags)
|
||||
QString IFindFilter::descriptionForFindFlags(FindFlags flags)
|
||||
{
|
||||
QStringList flagStrings;
|
||||
if (flags & Find::FindCaseSensitively)
|
||||
if (flags & FindCaseSensitively)
|
||||
flagStrings.append(tr("Case sensitive"));
|
||||
if (flags & Find::FindWholeWords)
|
||||
if (flags & FindWholeWords)
|
||||
flagStrings.append(tr("Whole words"));
|
||||
if (flags & Find::FindRegularExpression)
|
||||
if (flags & FindRegularExpression)
|
||||
flagStrings.append(tr("Regular expressions"));
|
||||
if (flags & Find::FindPreserveCase)
|
||||
if (flags & FindPreserveCase)
|
||||
flagStrings.append(tr("Preserve case"));
|
||||
QString description = tr("Flags: %1");
|
||||
if (flagStrings.isEmpty())
|
||||
@@ -277,3 +280,5 @@ QString Find::IFindFilter::descriptionForFindFlags(Find::FindFlags flags)
|
||||
description = description.arg(flagStrings.join(tr(", ")));
|
||||
return description;
|
||||
}
|
||||
|
||||
} // namespace Find
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
virtual bool isReplaceSupported() const { return false; }
|
||||
virtual FindFlags supportedFindFlags() const;
|
||||
|
||||
virtual void findAll(const QString &txt, Find::FindFlags findFlags) = 0;
|
||||
virtual void replaceAll(const QString &txt, Find::FindFlags findFlags)
|
||||
virtual void findAll(const QString &txt, FindFlags findFlags) = 0;
|
||||
virtual void replaceAll(const QString &txt, FindFlags findFlags)
|
||||
{ Q_UNUSED(txt) Q_UNUSED(findFlags) }
|
||||
|
||||
virtual QWidget *createConfigWidget() { return 0; }
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
using namespace Find::Internal;
|
||||
|
||||
SearchResultTreeItem::SearchResultTreeItem(const Find::SearchResultItem &item,
|
||||
SearchResultTreeItem::SearchResultTreeItem(const SearchResultItem &item,
|
||||
SearchResultTreeItem *parent)
|
||||
: item(item),
|
||||
m_parent(parent),
|
||||
@@ -115,7 +115,7 @@ int SearchResultTreeItem::insertionIndex(const QString &text, SearchResultTreeIt
|
||||
return insertionPosition - m_children.begin();
|
||||
}
|
||||
|
||||
int SearchResultTreeItem::insertionIndex(const Find::SearchResultItem &item, SearchResultTreeItem **existingItem) const
|
||||
int SearchResultTreeItem::insertionIndex(const SearchResultItem &item, SearchResultTreeItem **existingItem) const
|
||||
{
|
||||
return insertionIndex(item.text, existingItem);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void SearchResultTreeItem::insertChild(int index, SearchResultTreeItem *child)
|
||||
m_children.insert(index, child);
|
||||
}
|
||||
|
||||
void SearchResultTreeItem::insertChild(int index, const Find::SearchResultItem &item)
|
||||
void SearchResultTreeItem::insertChild(int index, const SearchResultItem &item)
|
||||
{
|
||||
SearchResultTreeItem *child = new SearchResultTreeItem(item, this);
|
||||
if (isUserCheckable()) {
|
||||
@@ -135,7 +135,7 @@ void SearchResultTreeItem::insertChild(int index, const Find::SearchResultItem &
|
||||
insertChild(index, child);
|
||||
}
|
||||
|
||||
void SearchResultTreeItem::appendChild(const Find::SearchResultItem &item)
|
||||
void SearchResultTreeItem::appendChild(const SearchResultItem &item)
|
||||
{
|
||||
insertChild(m_children.count(), item);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void SearchResultTreeView::clear()
|
||||
m_model->clear();
|
||||
}
|
||||
|
||||
void SearchResultTreeView::addResults(const QList<Find::SearchResultItem> &items, Find::SearchResult::AddMode mode)
|
||||
void SearchResultTreeView::addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode)
|
||||
{
|
||||
QList<QModelIndex> addedParents = m_model->addResults(items, mode);
|
||||
if (m_autoExpandResults && !addedParents.isEmpty()) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
void setTextEditorFont(const QFont &font, const SearchResultColor color);
|
||||
|
||||
SearchResultTreeModel *model() const;
|
||||
void addResults(const QList<Find::SearchResultItem> &items, SearchResult::AddMode mode);
|
||||
void addResults(const QList<SearchResultItem> &items, SearchResult::AddMode mode);
|
||||
|
||||
signals:
|
||||
void jumpToSearchResult(const SearchResultItem &item);
|
||||
|
||||
@@ -167,7 +167,7 @@ SearchResultWidget::SearchResultWidget(QWidget *parent) :
|
||||
m_preserveCaseCheck->setEnabled(false);
|
||||
|
||||
if (FindPlugin * plugin = FindPlugin::instance()) {
|
||||
m_preserveCaseCheck->setChecked(plugin->hasFindFlag(Find::FindPreserveCase));
|
||||
m_preserveCaseCheck->setChecked(plugin->hasFindFlag(FindPreserveCase));
|
||||
connect(m_preserveCaseCheck, SIGNAL(clicked(bool)), plugin, SLOT(setPreserveCase(bool)));
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ enum FindFlag {
|
||||
Q_DECLARE_FLAGS(FindFlags, FindFlag)
|
||||
|
||||
// defined in findplugin.cpp
|
||||
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(Find::FindFlags flags);
|
||||
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
|
||||
|
||||
} // namespace Find
|
||||
|
||||
|
||||
@@ -66,10 +66,9 @@ bool TreeViewFind::supportsReplace() const
|
||||
return false;
|
||||
}
|
||||
|
||||
Find::FindFlags TreeViewFind::supportedFindFlags() const
|
||||
FindFlags TreeViewFind::supportedFindFlags() const
|
||||
{
|
||||
return Find::FindBackward | Find::FindCaseSensitively
|
||||
| Find::FindRegularExpression | Find::FindWholeWords;
|
||||
return FindBackward | FindCaseSensitively | FindRegularExpression | FindWholeWords;
|
||||
}
|
||||
|
||||
void TreeViewFind::resetIncrementalSearch()
|
||||
@@ -96,8 +95,7 @@ void TreeViewFind::highlightAll(const QString &/*txt*/, FindFlags /*findFlags*/)
|
||||
{
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::findIncremental(const QString &txt,
|
||||
Find::FindFlags findFlags)
|
||||
IFindSupport::Result TreeViewFind::findIncremental(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
if (!d->m_incrementalFindStart.isValid()) {
|
||||
d->m_incrementalFindStart = d->m_view->currentIndex();
|
||||
@@ -114,8 +112,7 @@ IFindSupport::Result TreeViewFind::findIncremental(const QString &txt,
|
||||
return result;
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::findStep(const QString &txt,
|
||||
Find::FindFlags findFlags)
|
||||
IFindSupport::Result TreeViewFind::findStep(const QString &txt, FindFlags findFlags)
|
||||
{
|
||||
bool wrapped = false;
|
||||
IFindSupport::Result result = find(txt, findFlags, false/*startFromNext*/,
|
||||
@@ -130,7 +127,7 @@ IFindSupport::Result TreeViewFind::findStep(const QString &txt,
|
||||
}
|
||||
|
||||
IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
Find::FindFlags findFlags,
|
||||
FindFlags findFlags,
|
||||
bool startFromCurrentIndex,
|
||||
bool *wrapped)
|
||||
{
|
||||
@@ -139,8 +136,7 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
if (searchTxt.isEmpty())
|
||||
return IFindSupport::NotFound;
|
||||
|
||||
QTextDocument::FindFlags flags =
|
||||
Find::textDocumentFlagsForFindFlags(findFlags);
|
||||
QTextDocument::FindFlags flags = textDocumentFlagsForFindFlags(findFlags);
|
||||
QModelIndex resultIndex;
|
||||
QModelIndex currentIndex = d->m_view->currentIndex();
|
||||
QModelIndex index = currentIndex;
|
||||
@@ -160,8 +156,8 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
if (index.isValid()) {
|
||||
const QString &text = d->m_view->model()->data(
|
||||
index, d->m_role).toString();
|
||||
if (findFlags & Find::FindRegularExpression) {
|
||||
bool sensitive = (findFlags & Find::FindCaseSensitively);
|
||||
if (findFlags & FindRegularExpression) {
|
||||
bool sensitive = (findFlags & FindCaseSensitively);
|
||||
QRegExp searchExpr = QRegExp(searchTxt,
|
||||
(sensitive ? Qt::CaseSensitive :
|
||||
Qt::CaseInsensitive));
|
||||
@@ -172,8 +168,7 @@ IFindSupport::Result TreeViewFind::find(const QString &searchTxt,
|
||||
} else {
|
||||
QTextDocument doc(text);
|
||||
if (!doc.find(searchTxt, 0,
|
||||
flags & (Find::FindCaseSensitively |
|
||||
Find::FindWholeWords)).isNull()
|
||||
flags & (FindCaseSensitively | FindWholeWords)).isNull()
|
||||
&& d->m_view->model()->flags(index) & Qt::ItemIsSelectable
|
||||
&& (index.row() != currentRow || index.parent() != currentIndex.parent()))
|
||||
resultIndex = index;
|
||||
|
||||
@@ -40,7 +40,7 @@ QT_END_NAMESPACE
|
||||
namespace Find {
|
||||
class ItemModelFindPrivate;
|
||||
|
||||
class FIND_EXPORT TreeViewFind : public Find::IFindSupport
|
||||
class FIND_EXPORT TreeViewFind : public IFindSupport
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -48,18 +48,18 @@ public:
|
||||
virtual ~TreeViewFind();
|
||||
|
||||
bool supportsReplace() const;
|
||||
Find::FindFlags supportedFindFlags() const;
|
||||
FindFlags supportedFindFlags() const;
|
||||
void resetIncrementalSearch();
|
||||
void clearResults();
|
||||
QString currentFindString() const;
|
||||
QString completedFindString() const;
|
||||
|
||||
virtual void highlightAll(const QString &txt, FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findStep(const QString &txt, Find::FindFlags findFlags);
|
||||
Result findIncremental(const QString &txt, FindFlags findFlags);
|
||||
Result findStep(const QString &txt, FindFlags findFlags);
|
||||
|
||||
private:
|
||||
Result find(const QString &txt, Find::FindFlags findFlags,
|
||||
Result find(const QString &txt, FindFlags findFlags,
|
||||
bool startFromCurrentIndex, bool *wrapped);
|
||||
QModelIndex nextIndex(const QModelIndex &idx, bool *wrapped) const;
|
||||
QModelIndex prevIndex(const QModelIndex &idx, bool *wrapped) const;
|
||||
|
||||
@@ -1229,7 +1229,7 @@ void HelpPlugin::slotReportBug()
|
||||
void HelpPlugin::openFindToolBar()
|
||||
{
|
||||
if (Find::FindPlugin::instance())
|
||||
Find::FindPlugin::instance()->openFindToolBar(Find::FindPlugin::FindForward);
|
||||
Find::FindPlugin::instance()->openFindToolBar(Find::FindPlugin::FindForwardDirection);
|
||||
}
|
||||
|
||||
void HelpPlugin::onSideBarVisibilityChanged()
|
||||
|
||||
Reference in New Issue
Block a user