forked from qt-creator/qt-creator
Prepare for being able to add find flags that are not in QTextDocument
This commit is contained in:
@@ -69,51 +69,51 @@ public:
|
|||||||
QString completedFindString() const { return QString(); }
|
QString completedFindString() const { return QString(); }
|
||||||
|
|
||||||
|
|
||||||
int find(const QByteArray &pattern, int pos, QTextDocument::FindFlags findFlags) {
|
int find(const QByteArray &pattern, int pos, Find::IFindSupport::FindFlags findFlags) {
|
||||||
if (pattern.isEmpty()) {
|
if (pattern.isEmpty()) {
|
||||||
m_editor->setCursorPosition(pos);
|
m_editor->setCursorPosition(pos);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int found = m_editor->find(pattern, pos, findFlags);
|
int found = m_editor->find(pattern, pos, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
if (found < 0)
|
if (found < 0)
|
||||||
found = m_editor->find(pattern,
|
found = m_editor->find(pattern,
|
||||||
(findFlags & QTextDocument::FindBackward)?m_editor->data().size()-1:0,
|
(findFlags & Find::IFindSupport::FindBackward)?m_editor->data().size()-1:0,
|
||||||
findFlags);
|
Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags) {
|
bool findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags) {
|
||||||
QByteArray pattern = txt.toLatin1();
|
QByteArray pattern = txt.toLatin1();
|
||||||
if (m_incrementalStartPos < 0)
|
if (m_incrementalStartPos < 0)
|
||||||
m_incrementalStartPos = m_editor->selectionStart();
|
m_incrementalStartPos = m_editor->selectionStart();
|
||||||
int pos = m_incrementalStartPos;
|
int pos = m_incrementalStartPos;
|
||||||
findFlags &= ~QTextDocument::FindBackward;
|
findFlags &= ~Find::IFindSupport::FindBackward;
|
||||||
int found = find(pattern, pos, findFlags);
|
int found = find(pattern, pos, findFlags);
|
||||||
if (found >= 0)
|
if (found >= 0)
|
||||||
m_editor->highlightSearchResults(pattern, findFlags);
|
m_editor->highlightSearchResults(pattern, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
else
|
else
|
||||||
m_editor->highlightSearchResults(QByteArray(), 0);
|
m_editor->highlightSearchResults(QByteArray(), 0);
|
||||||
return found >= 0;
|
return found >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags) {
|
bool findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags) {
|
||||||
QByteArray pattern = txt.toLatin1();
|
QByteArray pattern = txt.toLatin1();
|
||||||
bool wasReset = (m_incrementalStartPos < 0);
|
bool wasReset = (m_incrementalStartPos < 0);
|
||||||
int pos = m_editor->cursorPosition();
|
int pos = m_editor->cursorPosition();
|
||||||
if (findFlags & QTextDocument::FindBackward)
|
if (findFlags & Find::IFindSupport::FindBackward)
|
||||||
pos = m_editor->selectionStart()-1;
|
pos = m_editor->selectionStart()-1;
|
||||||
int found = find(pattern, pos, findFlags);
|
int found = find(pattern, pos, findFlags);
|
||||||
if (found)
|
if (found)
|
||||||
m_incrementalStartPos = found;
|
m_incrementalStartPos = found;
|
||||||
if (wasReset && found >= 0)
|
if (wasReset && found >= 0)
|
||||||
m_editor->highlightSearchResults(pattern, findFlags);
|
m_editor->highlightSearchResults(pattern, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
return found >= 0;
|
return found >= 0;
|
||||||
}
|
}
|
||||||
bool replaceStep(const QString &, const QString &,
|
bool replaceStep(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags) { return false;}
|
Find::IFindSupport::FindFlags) { return false;}
|
||||||
int replaceAll(const QString &, const QString &,
|
int replaceAll(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags) { return 0; }
|
Find::IFindSupport::FindFlags) { return 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinEditor *m_editor;
|
BinEditor *m_editor;
|
||||||
|
|||||||
@@ -119,13 +119,13 @@ QString BaseTextFind::completedFindString() const
|
|||||||
return cursor.selectedText();
|
return cursor.selectedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextFind::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool BaseTextFind::findIncremental(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
if (m_incrementalStartPos < 0)
|
if (m_incrementalStartPos < 0)
|
||||||
m_incrementalStartPos = cursor.selectionStart();
|
m_incrementalStartPos = cursor.selectionStart();
|
||||||
cursor.setPosition(m_incrementalStartPos);
|
cursor.setPosition(m_incrementalStartPos);
|
||||||
findFlags &= ~QTextDocument::FindBackward;
|
findFlags &= ~IFindSupport::FindBackward;
|
||||||
bool found = find(txt, findFlags, cursor);
|
bool found = find(txt, findFlags, cursor);
|
||||||
if (found)
|
if (found)
|
||||||
emit highlightAll(txt, findFlags);
|
emit highlightAll(txt, findFlags);
|
||||||
@@ -134,7 +134,7 @@ bool BaseTextFind::findIncremental(const QString &txt, QTextDocument::FindFlags
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextFind::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool BaseTextFind::findStep(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
bool found = find(txt, findFlags, textCursor());
|
bool found = find(txt, findFlags, textCursor());
|
||||||
if (found)
|
if (found)
|
||||||
@@ -143,21 +143,21 @@ bool BaseTextFind::findStep(const QString &txt, QTextDocument::FindFlags findFla
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextFind::replaceStep(const QString &before, const QString &after,
|
bool BaseTextFind::replaceStep(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags)
|
IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
if (cursor.selectedText().compare(before,
|
if (cursor.selectedText().compare(before,
|
||||||
((findFlags&QTextDocument::FindCaseSensitively)!=0) ? Qt::CaseSensitive : Qt::CaseInsensitive) == 0) {
|
((findFlags&IFindSupport::FindCaseSensitively)!=0) ? Qt::CaseSensitive : Qt::CaseInsensitive) == 0) {
|
||||||
int start = cursor.selectionStart();
|
int start = cursor.selectionStart();
|
||||||
cursor.insertText(after);
|
cursor.insertText(after);
|
||||||
if ((findFlags&QTextDocument::FindBackward) != 0)
|
if ((findFlags&IFindSupport::FindBackward) != 0)
|
||||||
cursor.setPosition(start);
|
cursor.setPosition(start);
|
||||||
}
|
}
|
||||||
return find(before, findFlags, cursor);
|
return find(before, findFlags, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags)
|
IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTextCursor editCursor = textCursor();
|
QTextCursor editCursor = textCursor();
|
||||||
if (!m_findScope.isNull())
|
if (!m_findScope.isNull())
|
||||||
@@ -167,27 +167,27 @@ int BaseTextFind::replaceAll(const QString &before, const QString &after,
|
|||||||
editCursor.beginEditBlock();
|
editCursor.beginEditBlock();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
QTextCursor found;
|
QTextCursor found;
|
||||||
found = document()->find(before, editCursor, findFlags);
|
found = document()->find(before, editCursor, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
while (!found.isNull() && inScope(found.selectionStart(), found.selectionEnd())) {
|
while (!found.isNull() && inScope(found.selectionStart(), found.selectionEnd())) {
|
||||||
++count;
|
++count;
|
||||||
editCursor.setPosition(found.selectionStart());
|
editCursor.setPosition(found.selectionStart());
|
||||||
editCursor.setPosition(found.selectionEnd(), QTextCursor::KeepAnchor);
|
editCursor.setPosition(found.selectionEnd(), QTextCursor::KeepAnchor);
|
||||||
editCursor.insertText(after);
|
editCursor.insertText(after);
|
||||||
found = document()->find(before, editCursor, findFlags);
|
found = document()->find(before, editCursor, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
}
|
}
|
||||||
editCursor.endEditBlock();
|
editCursor.endEditBlock();
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseTextFind::find(const QString &txt,
|
bool BaseTextFind::find(const QString &txt,
|
||||||
QTextDocument::FindFlags findFlags,
|
IFindSupport::FindFlags findFlags,
|
||||||
QTextCursor start)
|
QTextCursor start)
|
||||||
{
|
{
|
||||||
if (txt.isEmpty()) {
|
if (txt.isEmpty()) {
|
||||||
setTextCursor(start);
|
setTextCursor(start);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
QTextCursor found = document()->find(txt, start, findFlags);
|
QTextCursor found = document()->find(txt, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
|
|
||||||
if (!m_findScope.isNull()) {
|
if (!m_findScope.isNull()) {
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ bool BaseTextFind::find(const QString &txt,
|
|||||||
start.setPosition(m_findScope.selectionStart());
|
start.setPosition(m_findScope.selectionStart());
|
||||||
else
|
else
|
||||||
start.setPosition(m_findScope.selectionEnd());
|
start.setPosition(m_findScope.selectionEnd());
|
||||||
found = document()->find(txt, start, findFlags);
|
found = document()->find(txt, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd()))
|
if (found.isNull() || !inScope(found.selectionStart(), found.selectionEnd()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ bool BaseTextFind::find(const QString &txt,
|
|||||||
start.movePosition(QTextCursor::Start);
|
start.movePosition(QTextCursor::Start);
|
||||||
else
|
else
|
||||||
start.movePosition(QTextCursor::End);
|
start.movePosition(QTextCursor::End);
|
||||||
found = document()->find(txt, start, findFlags);
|
found = document()->find(txt, start, IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
if (found.isNull()) {
|
if (found.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,23 +52,23 @@ public:
|
|||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
QString completedFindString() const;
|
QString completedFindString() const;
|
||||||
|
|
||||||
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findIncremental(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||||
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findStep(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||||
bool replaceStep(const QString &before, const QString &after,
|
bool replaceStep(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags);
|
IFindSupport::FindFlags findFlags);
|
||||||
int replaceAll(const QString &before, const QString &after,
|
int replaceAll(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags);
|
IFindSupport::FindFlags findFlags);
|
||||||
|
|
||||||
void defineFindScope();
|
void defineFindScope();
|
||||||
void clearFindScope();
|
void clearFindScope();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void highlightAll(const QString &txt, QTextDocument::FindFlags findFlags);
|
void highlightAll(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
void findScopeChanged(const QTextCursor &);
|
void findScopeChanged(const QTextCursor &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool find(const QString &txt,
|
bool find(const QString &txt,
|
||||||
QTextDocument::FindFlags findFlags,
|
IFindSupport::FindFlags findFlags,
|
||||||
QTextCursor start);
|
QTextCursor start);
|
||||||
|
|
||||||
QTextCursor textCursor() const;
|
QTextCursor textCursor() const;
|
||||||
|
|||||||
@@ -89,33 +89,33 @@ QString CurrentDocumentFind::completedFindString() const
|
|||||||
return m_currentFind->completedFindString();
|
return m_currentFind->completedFindString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentDocumentFind::highlightAll(const QString &txt, QTextDocument::FindFlags findFlags)
|
void CurrentDocumentFind::highlightAll(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return);
|
QTC_ASSERT(m_currentFind, return);
|
||||||
m_currentFind->highlightAll(txt, findFlags);
|
m_currentFind->highlightAll(txt, findFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurrentDocumentFind::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool CurrentDocumentFind::findIncremental(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return false);
|
QTC_ASSERT(m_currentFind, return false);
|
||||||
return m_currentFind->findIncremental(txt, findFlags);
|
return m_currentFind->findIncremental(txt, findFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurrentDocumentFind::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool CurrentDocumentFind::findStep(const QString &txt, IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return false);
|
QTC_ASSERT(m_currentFind, return false);
|
||||||
return m_currentFind->findStep(txt, findFlags);
|
return m_currentFind->findStep(txt, findFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
|
bool CurrentDocumentFind::replaceStep(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags)
|
IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return false);
|
QTC_ASSERT(m_currentFind, return false);
|
||||||
return m_currentFind->replaceStep(before, after, findFlags);
|
return m_currentFind->replaceStep(before, after, findFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
|
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags)
|
IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_currentFind, return 0);
|
QTC_ASSERT(m_currentFind, return 0);
|
||||||
return m_currentFind->replaceAll(before, after, findFlags);
|
return m_currentFind->replaceAll(before, after, findFlags);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#ifndef CURRENTDOCUMENTFIND_H
|
#ifndef CURRENTDOCUMENTFIND_H
|
||||||
#define CURRENTDOCUMENTFIND_H
|
#define CURRENTDOCUMENTFIND_H
|
||||||
|
|
||||||
#include "ifindfilter.h"
|
#include "ifindsupport.h"
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
@@ -52,13 +52,13 @@ public:
|
|||||||
QString completedFindString() const;
|
QString completedFindString() const;
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
void highlightAll(const QString &txt, QTextDocument::FindFlags findFlags);
|
void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||||
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findIncremental(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||||
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findStep(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||||
bool replaceStep(const QString &before, const QString &after,
|
bool replaceStep(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags);
|
IFindSupport::FindFlags findFlags);
|
||||||
int replaceAll(const QString &before, const QString &after,
|
int replaceAll(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags);
|
IFindSupport::FindFlags findFlags);
|
||||||
void defineFindScope();
|
void defineFindScope();
|
||||||
void clearFindScope();
|
void clearFindScope();
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ void FindPlugin::writeSettings()
|
|||||||
settings->setValue("FindStrings", m_findCompletions);
|
settings->setValue("FindStrings", m_findCompletions);
|
||||||
settings->setValue("ReplaceStrings", m_replaceCompletions);
|
settings->setValue("ReplaceStrings", m_replaceCompletions);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
m_findToolBar->writeSettings();
|
||||||
m_findDialog->writeSettings();
|
m_findDialog->writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,6 +266,7 @@ void FindPlugin::readSettings()
|
|||||||
m_findCompletionModel->setStringList(m_findCompletions);
|
m_findCompletionModel->setStringList(m_findCompletions);
|
||||||
m_replaceCompletionModel->setStringList(m_replaceCompletions);
|
m_replaceCompletionModel->setStringList(m_replaceCompletions);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
m_findToolBar->readSettings();
|
||||||
m_findDialog->readSettings();
|
m_findDialog->readSettings();
|
||||||
emit findFlagsChanged(); // would have been done in the setXXX methods above
|
emit findFlagsChanged(); // would have been done in the setXXX methods above
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#ifndef FINDPLUGIN_H
|
#ifndef FINDPLUGIN_H
|
||||||
#define FINDPLUGIN_H
|
#define FINDPLUGIN_H
|
||||||
|
|
||||||
#include "ui_findwidget.h"
|
|
||||||
#include "ifindfilter.h"
|
#include "ifindfilter.h"
|
||||||
#include "findtoolbar.h"
|
#include "findtoolbar.h"
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
|||||||
m_caseSensitiveAction->setChecked(false);
|
m_caseSensitiveAction->setChecked(false);
|
||||||
cmd = am->registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext);
|
cmd = am->registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
||||||
connect(m_caseSensitiveAction, SIGNAL(triggered(bool)), m_plugin, SLOT(setCaseSensitive(bool)));
|
connect(m_caseSensitiveAction, SIGNAL(triggered(bool)), this, SLOT(setCaseSensitive(bool)));
|
||||||
lineEditMenu->addAction(m_caseSensitiveAction);
|
lineEditMenu->addAction(m_caseSensitiveAction);
|
||||||
|
|
||||||
m_wholeWordAction = new QAction(tr("Whole Words Only"), this);
|
m_wholeWordAction = new QAction(tr("Whole Words Only"), this);
|
||||||
@@ -211,13 +211,12 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
|||||||
m_wholeWordAction->setChecked(false);
|
m_wholeWordAction->setChecked(false);
|
||||||
cmd = am->registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext);
|
cmd = am->registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
||||||
connect(m_wholeWordAction, SIGNAL(triggered(bool)), m_plugin, SLOT(setWholeWord(bool)));
|
connect(m_wholeWordAction, SIGNAL(triggered(bool)), this, SLOT(setWholeWord(bool)));
|
||||||
lineEditMenu->addAction(m_wholeWordAction);
|
lineEditMenu->addAction(m_wholeWordAction);
|
||||||
|
|
||||||
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions()));
|
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions()));
|
||||||
updateActions();
|
updateActions();
|
||||||
updateIcons();
|
updateIcons();
|
||||||
connect(m_plugin, SIGNAL(findFlagsChanged()), this, SLOT(findFlagsChanged()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FindToolBar::~FindToolBar()
|
FindToolBar::~FindToolBar()
|
||||||
@@ -314,13 +313,13 @@ void FindToolBar::invokeClearResults()
|
|||||||
|
|
||||||
void FindToolBar::invokeFindNext()
|
void FindToolBar::invokeFindNext()
|
||||||
{
|
{
|
||||||
m_plugin->setBackward(false);
|
setFindFlag(IFindSupport::FindBackward, false);
|
||||||
invokeFindStep();
|
invokeFindStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolBar::invokeFindPrevious()
|
void FindToolBar::invokeFindPrevious()
|
||||||
{
|
{
|
||||||
m_plugin->setBackward(true);
|
setFindFlag(IFindSupport::FindBackward, true);
|
||||||
invokeFindStep();
|
invokeFindStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +349,7 @@ void FindToolBar::invokeFindStep()
|
|||||||
{
|
{
|
||||||
if (m_currentDocumentFind->isEnabled()) {
|
if (m_currentDocumentFind->isEnabled()) {
|
||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_currentDocumentFind->findStep(getFindText(), m_plugin->findFlags());
|
m_currentDocumentFind->findStep(getFindText(), m_findFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +357,7 @@ void FindToolBar::invokeFindIncremental()
|
|||||||
{
|
{
|
||||||
if (m_currentDocumentFind->isEnabled()) {
|
if (m_currentDocumentFind->isEnabled()) {
|
||||||
QString text = getFindText();
|
QString text = getFindText();
|
||||||
m_currentDocumentFind->findIncremental(text, m_plugin->findFlags());
|
m_currentDocumentFind->findIncremental(text, m_findFlags);
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
m_currentDocumentFind->clearResults();
|
m_currentDocumentFind->clearResults();
|
||||||
}
|
}
|
||||||
@@ -366,13 +365,13 @@ void FindToolBar::invokeFindIncremental()
|
|||||||
|
|
||||||
void FindToolBar::invokeReplaceNext()
|
void FindToolBar::invokeReplaceNext()
|
||||||
{
|
{
|
||||||
m_plugin->setBackward(false);
|
setFindFlag(IFindSupport::FindBackward, false);
|
||||||
invokeReplaceStep();
|
invokeReplaceStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolBar::invokeReplacePrevious()
|
void FindToolBar::invokeReplacePrevious()
|
||||||
{
|
{
|
||||||
m_plugin->setBackward(true);
|
setFindFlag(IFindSupport::FindBackward, true);
|
||||||
invokeReplaceStep();
|
invokeReplaceStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +380,7 @@ void FindToolBar::invokeReplaceStep()
|
|||||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||||
m_currentDocumentFind->replaceStep(getFindText(), getReplaceText(), m_plugin->findFlags());
|
m_currentDocumentFind->replaceStep(getFindText(), getReplaceText(), m_findFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,7 +389,7 @@ void FindToolBar::invokeReplaceAll()
|
|||||||
m_plugin->updateFindCompletion(getFindText());
|
m_plugin->updateFindCompletion(getFindText());
|
||||||
m_plugin->updateReplaceCompletion(getReplaceText());
|
m_plugin->updateReplaceCompletion(getReplaceText());
|
||||||
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
if (m_currentDocumentFind->isEnabled() && m_currentDocumentFind->supportsReplace()) {
|
||||||
m_currentDocumentFind->replaceAll(getFindText(), getReplaceText(), m_plugin->findFlags());
|
m_currentDocumentFind->replaceAll(getFindText(), getReplaceText(), m_findFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,8 +426,8 @@ void FindToolBar::findFlagsChanged()
|
|||||||
|
|
||||||
void FindToolBar::updateIcons()
|
void FindToolBar::updateIcons()
|
||||||
{
|
{
|
||||||
bool casesensitive = m_plugin->findFlags() & QTextDocument::FindCaseSensitively;
|
bool casesensitive = m_findFlags & QTextDocument::FindCaseSensitively;
|
||||||
bool wholewords = m_plugin->findFlags() & QTextDocument::FindWholeWords;
|
bool wholewords = m_findFlags & QTextDocument::FindWholeWords;
|
||||||
|
|
||||||
if (casesensitive && wholewords) {
|
if (casesensitive && wholewords) {
|
||||||
QPixmap image = QPixmap(":/find/images/wordandcase.png");
|
QPixmap image = QPixmap(":/find/images/wordandcase.png");
|
||||||
@@ -446,8 +445,8 @@ void FindToolBar::updateIcons()
|
|||||||
|
|
||||||
void FindToolBar::updateFlagMenus()
|
void FindToolBar::updateFlagMenus()
|
||||||
{
|
{
|
||||||
bool wholeOnly = ((m_plugin->findFlags() & QTextDocument::FindWholeWords));
|
bool wholeOnly = ((m_findFlags & QTextDocument::FindWholeWords));
|
||||||
bool sensitive = ((m_plugin->findFlags() & QTextDocument::FindCaseSensitively));
|
bool sensitive = ((m_findFlags & QTextDocument::FindCaseSensitively));
|
||||||
if (m_wholeWordAction->isChecked() != wholeOnly)
|
if (m_wholeWordAction->isChecked() != wholeOnly)
|
||||||
m_wholeWordAction->setChecked(wholeOnly);
|
m_wholeWordAction->setChecked(wholeOnly);
|
||||||
if (m_caseSensitiveAction->isChecked() != sensitive)
|
if (m_caseSensitiveAction->isChecked() != sensitive)
|
||||||
@@ -482,7 +481,7 @@ void FindToolBar::openFind()
|
|||||||
if (!text.isEmpty())
|
if (!text.isEmpty())
|
||||||
setFindText(text);
|
setFindText(text);
|
||||||
m_currentDocumentFind->defineFindScope();
|
m_currentDocumentFind->defineFindScope();
|
||||||
m_currentDocumentFind->highlightAll(getFindText(), m_plugin->findFlags());
|
m_currentDocumentFind->highlightAll(getFindText(), m_findFlags);
|
||||||
selectFindText();
|
selectFindText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,3 +497,61 @@ bool FindToolBar::focusNextPrevChild(bool next)
|
|||||||
return QToolBar::focusNextPrevChild(next);
|
return QToolBar::focusNextPrevChild(next);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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->endGroup();
|
||||||
|
settings->endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindToolBar::readSettings()
|
||||||
|
{
|
||||||
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
settings->beginGroup("Find");
|
||||||
|
settings->beginGroup("FindToolBar");
|
||||||
|
IFindSupport::FindFlags flags;
|
||||||
|
if (settings->value("Backward", false).toBool())
|
||||||
|
flags |= IFindSupport::FindBackward;
|
||||||
|
if (settings->value("CaseSensitively", false).toBool())
|
||||||
|
flags |= IFindSupport::FindCaseSensitively;
|
||||||
|
if (settings->value("WholeWords", false).toBool())
|
||||||
|
flags |= IFindSupport::FindWholeWords;
|
||||||
|
settings->endGroup();
|
||||||
|
settings->endGroup();
|
||||||
|
m_findFlags = flags;
|
||||||
|
findFlagsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindToolBar::setFindFlag(IFindSupport::FindFlag flag, bool enabled)
|
||||||
|
{
|
||||||
|
bool hasFlag = hasFindFlag(flag);
|
||||||
|
if ((hasFlag && enabled) || (!hasFlag && !enabled))
|
||||||
|
return;
|
||||||
|
if (enabled)
|
||||||
|
m_findFlags |= flag;
|
||||||
|
else
|
||||||
|
m_findFlags &= ~flag;
|
||||||
|
if (flag != IFindSupport::FindBackward)
|
||||||
|
findFlagsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FindToolBar::hasFindFlag(IFindSupport::FindFlag flag)
|
||||||
|
{
|
||||||
|
return m_findFlags & flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindToolBar::setCaseSensitive(bool sensitive)
|
||||||
|
{
|
||||||
|
setFindFlag(IFindSupport::FindCaseSensitively, sensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindToolBar::setWholeWord(bool wholeOnly)
|
||||||
|
{
|
||||||
|
setFindFlag(IFindSupport::FindWholeWords, wholeOnly);
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind);
|
FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind);
|
||||||
~FindToolBar();
|
~FindToolBar();
|
||||||
|
|
||||||
void invokeClearResults();
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void invokeFindNext();
|
void invokeFindNext();
|
||||||
@@ -75,11 +76,17 @@ private slots:
|
|||||||
void updateActions();
|
void updateActions();
|
||||||
void findFlagsChanged();
|
void findFlagsChanged();
|
||||||
|
|
||||||
|
void setCaseSensitive(bool sensitive);
|
||||||
|
void setWholeWord(bool wholeOnly);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool focusNextPrevChild(bool next);
|
bool focusNextPrevChild(bool next);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void invokeClearResults();
|
||||||
bool setFocusToCurrentFindSupport();
|
bool setFocusToCurrentFindSupport();
|
||||||
|
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
|
||||||
|
bool hasFindFlag(IFindSupport::FindFlag flag);
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
void setFindText(const QString &text);
|
void setFindText(const QString &text);
|
||||||
@@ -104,6 +111,7 @@ private:
|
|||||||
QAction *m_caseSensitiveAction;
|
QAction *m_caseSensitiveAction;
|
||||||
QAction *m_wholeWordAction;
|
QAction *m_wholeWordAction;
|
||||||
QWidget *m_widget;
|
QWidget *m_widget;
|
||||||
|
IFindSupport::FindFlags m_findFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -30,11 +30,13 @@
|
|||||||
#ifndef IFINDFILTER_H
|
#ifndef IFINDFILTER_H
|
||||||
#define IFINDFILTER_H
|
#define IFINDFILTER_H
|
||||||
|
|
||||||
#include "ifindsupport.h"
|
#include "find_global.h"
|
||||||
|
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <QtGui/QKeySequence>
|
#include <QtGui/QKeySequence>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
namespace Find {
|
namespace Find {
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
#define IFINDSUPPORT_H
|
#define IFINDSUPPORT_H
|
||||||
|
|
||||||
#include "find_global.h"
|
#include "find_global.h"
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QString>
|
||||||
#include <QtGui/QTextDocument>
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
namespace Find {
|
namespace Find {
|
||||||
@@ -41,6 +42,12 @@ class FIND_EXPORT IFindSupport : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum FindFlag {
|
||||||
|
FindBackward = 0x01,
|
||||||
|
FindCaseSensitively = 0x02,
|
||||||
|
FindWholeWords = 0x04,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(FindFlags, FindFlag);
|
||||||
|
|
||||||
IFindSupport() : QObject(0) {}
|
IFindSupport() : QObject(0) {}
|
||||||
virtual ~IFindSupport() {}
|
virtual ~IFindSupport() {}
|
||||||
@@ -51,24 +58,37 @@ public:
|
|||||||
virtual QString currentFindString() const = 0;
|
virtual QString currentFindString() const = 0;
|
||||||
virtual QString completedFindString() const = 0;
|
virtual QString completedFindString() const = 0;
|
||||||
|
|
||||||
virtual void highlightAll(const QString &txt, QTextDocument::FindFlags findFlags);
|
virtual void highlightAll(const QString &txt, FindFlags findFlags);
|
||||||
virtual bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags) = 0;
|
virtual bool findIncremental(const QString &txt, FindFlags findFlags) = 0;
|
||||||
virtual bool findStep(const QString &txt, QTextDocument::FindFlags findFlags) = 0;
|
virtual bool findStep(const QString &txt, FindFlags findFlags) = 0;
|
||||||
virtual bool replaceStep(const QString &before, const QString &after,
|
virtual bool replaceStep(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags) = 0;
|
FindFlags findFlags) = 0;
|
||||||
virtual int replaceAll(const QString &before, const QString &after,
|
virtual int replaceAll(const QString &before, const QString &after,
|
||||||
QTextDocument::FindFlags findFlags) = 0;
|
FindFlags findFlags) = 0;
|
||||||
|
|
||||||
virtual void defineFindScope(){}
|
virtual void defineFindScope(){}
|
||||||
virtual void clearFindScope(){}
|
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:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline void IFindSupport::highlightAll(const QString &, FindFlags) {}
|
||||||
inline void IFindSupport::highlightAll(const QString &, QTextDocument::FindFlags) {}
|
|
||||||
|
|
||||||
} // namespace Find
|
} // namespace Find
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Find::IFindSupport::FindFlags)
|
||||||
|
|
||||||
#endif // IFINDSUPPORT_H
|
#endif // IFINDSUPPORT_H
|
||||||
|
|||||||
@@ -66,17 +66,17 @@ QString HelpFindSupport::completedFindString() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpFindSupport::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool HelpFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_centralWidget, return false);
|
QTC_ASSERT(m_centralWidget, return false);
|
||||||
findFlags &= ~QTextDocument::FindBackward;
|
findFlags &= ~Find::IFindSupport::FindBackward;
|
||||||
return m_centralWidget->find(txt, findFlags, true);
|
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpFindSupport::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool HelpFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_centralWidget, return false);
|
QTC_ASSERT(m_centralWidget, return false);
|
||||||
return m_centralWidget->find(txt, findFlags, false);
|
return m_centralWidget->find(txt, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
||||||
@@ -94,28 +94,28 @@ QString HelpViewerFindSupport::currentFindString() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpViewerFindSupport::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool HelpViewerFindSupport::findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_viewer, return false);
|
QTC_ASSERT(m_viewer, return false);
|
||||||
findFlags &= ~QTextDocument::FindBackward;
|
findFlags &= ~Find::IFindSupport::FindBackward;
|
||||||
return find(txt, findFlags, true);
|
return find(txt, findFlags, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpViewerFindSupport::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
|
bool HelpViewerFindSupport::findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_viewer, return false);
|
QTC_ASSERT(m_viewer, return false);
|
||||||
return find(txt, findFlags, false);
|
return find(txt, findFlags, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelpViewerFindSupport::find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental)
|
bool HelpViewerFindSupport::find(const QString &txt, Find::IFindSupport::FindFlags findFlags, bool incremental)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_viewer, return false);
|
QTC_ASSERT(m_viewer, return false);
|
||||||
#if !defined(QT_NO_WEBKIT)
|
#if !defined(QT_NO_WEBKIT)
|
||||||
Q_UNUSED(incremental);
|
Q_UNUSED(incremental);
|
||||||
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
|
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
|
||||||
if (findFlags & QTextDocument::FindBackward)
|
if (findFlags & Find::IFindSupport::FindBackward)
|
||||||
options |= QWebPage::FindBackward;
|
options |= QWebPage::FindBackward;
|
||||||
if (findFlags & QTextDocument::FindCaseSensitively)
|
if (findFlags & Find::IFindSupport::FindCaseSensitively)
|
||||||
options |= QWebPage::FindCaseSensitively;
|
options |= QWebPage::FindCaseSensitively;
|
||||||
|
|
||||||
return m_viewer->findText(txt, options);
|
return m_viewer->findText(txt, options);
|
||||||
@@ -129,13 +129,13 @@ bool HelpViewerFindSupport::find(const QString &txt, QTextDocument::FindFlags fi
|
|||||||
if (incremental)
|
if (incremental)
|
||||||
cursor.setPosition(cursor.selectionStart());
|
cursor.setPosition(cursor.selectionStart());
|
||||||
|
|
||||||
QTextCursor found = doc->find(txt, cursor, findFlags);
|
QTextCursor found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
if (found.isNull()) {
|
if (found.isNull()) {
|
||||||
if ((findFlags&QTextDocument::FindBackward) == 0)
|
if ((findFlags&Find::IFindSupport::FindBackward) == 0)
|
||||||
cursor.movePosition(QTextCursor::Start);
|
cursor.movePosition(QTextCursor::Start);
|
||||||
else
|
else
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
found = doc->find(txt, cursor, findFlags);
|
found = doc->find(txt, cursor, Find::IFindSupport::textDocumentFlagsForFindFlags(findFlags));
|
||||||
if (found.isNull()) {
|
if (found.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,15 +55,15 @@ public:
|
|||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
QString completedFindString() const;
|
QString completedFindString() const;
|
||||||
|
|
||||||
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
bool replaceStep(const QString &, const QString &,
|
bool replaceStep(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags ) { return false; }
|
Find::IFindSupport::FindFlags ) { return false; }
|
||||||
int replaceAll(const QString &, const QString &,
|
int replaceAll(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags ) { return 0; }
|
Find::IFindSupport::FindFlags ) { return 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool find(const QString &ttf, QTextDocument::FindFlags findFlags, bool incremental);
|
bool find(const QString &ttf, Find::IFindSupport::FindFlags findFlags, bool incremental);
|
||||||
|
|
||||||
CentralWidget *m_centralWidget;
|
CentralWidget *m_centralWidget;
|
||||||
};
|
};
|
||||||
@@ -81,15 +81,15 @@ public:
|
|||||||
QString currentFindString() const;
|
QString currentFindString() const;
|
||||||
QString completedFindString() const { return QString(); }
|
QString completedFindString() const { return QString(); }
|
||||||
|
|
||||||
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findIncremental(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags);
|
bool findStep(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
bool replaceStep(const QString &, const QString &,
|
bool replaceStep(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags ) { return false; }
|
Find::IFindSupport::FindFlags ) { return false; }
|
||||||
int replaceAll(const QString &, const QString &,
|
int replaceAll(const QString &, const QString &,
|
||||||
QTextDocument::FindFlags ) { return 0; }
|
Find::IFindSupport::FindFlags ) { return 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool find(const QString &ttf, QTextDocument::FindFlags findFlags, bool incremental);
|
bool find(const QString &ttf, Find::IFindSupport::FindFlags findFlags, bool incremental);
|
||||||
HelpViewer *m_viewer;
|
HelpViewer *m_viewer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1630,7 +1630,7 @@ void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block,
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
break;
|
break;
|
||||||
int l = m_searchExpr.matchedLength();
|
int l = m_searchExpr.matchedLength();
|
||||||
if ((m_findFlags & QTextDocument::FindWholeWords)
|
if ((m_findFlags & Find::IFindSupport::FindWholeWords)
|
||||||
&& ((idx && text.at(idx-1).isLetterOrNumber())
|
&& ((idx && text.at(idx-1).isLetterOrNumber())
|
||||||
|| (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))
|
|| (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))
|
||||||
continue;
|
continue;
|
||||||
@@ -3441,13 +3441,13 @@ TextBlockUserData::MatchType TextBlockUserData::matchCursorForward(QTextCursor *
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseTextEditor::highlightSearchResults(const QString &txt, QTextDocument::FindFlags findFlags)
|
void BaseTextEditor::highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags)
|
||||||
{
|
{
|
||||||
if (d->m_searchExpr.pattern() == txt)
|
if (d->m_searchExpr.pattern() == txt)
|
||||||
return;
|
return;
|
||||||
d->m_searchExpr.setPattern(txt);
|
d->m_searchExpr.setPattern(txt);
|
||||||
d->m_searchExpr.setPatternSyntax(QRegExp::FixedString);
|
d->m_searchExpr.setPatternSyntax(QRegExp::FixedString);
|
||||||
d->m_searchExpr.setCaseSensitivity((findFlags & QTextDocument::FindCaseSensitively) ?
|
d->m_searchExpr.setCaseSensitivity((findFlags & Find::IFindSupport::FindCaseSensitively) ?
|
||||||
Qt::CaseSensitive : Qt::CaseInsensitive);
|
Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||||
d->m_findFlags = findFlags;
|
d->m_findFlags = findFlags;
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
@@ -4036,8 +4036,8 @@ BaseTextEditorEditable::BaseTextEditorEditable(BaseTextEditor *editor)
|
|||||||
using namespace Find;
|
using namespace Find;
|
||||||
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
|
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
|
||||||
BaseTextFind *baseTextFind = new BaseTextFind(editor);
|
BaseTextFind *baseTextFind = new BaseTextFind(editor);
|
||||||
connect(baseTextFind, SIGNAL(highlightAll(QString, QTextDocument::FindFlags)),
|
connect(baseTextFind, SIGNAL(highlightAll(QString, Find::IFindSupport::FindFlags)),
|
||||||
editor, SLOT(highlightSearchResults(QString, QTextDocument::FindFlags)));
|
editor, SLOT(highlightSearchResults(QString, Find::IFindSupport::FindFlags)));
|
||||||
connect(baseTextFind, SIGNAL(findScopeChanged(QTextCursor)), editor, SLOT(setFindScope(QTextCursor)));
|
connect(baseTextFind, SIGNAL(findScopeChanged(QTextCursor)), editor, SLOT(setFindScope(QTextCursor)));
|
||||||
aggregate->add(baseTextFind);
|
aggregate->add(baseTextFind);
|
||||||
aggregate->add(editor);
|
aggregate->add(editor);
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
#include "tabsettings.h"
|
#include "tabsettings.h"
|
||||||
#include "itexteditable.h"
|
#include "itexteditable.h"
|
||||||
|
|
||||||
|
#include <find/ifindsupport.h>
|
||||||
|
|
||||||
#include <QtGui/QPlainTextEdit>
|
#include <QtGui/QPlainTextEdit>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QtGui/QKeyEvent>
|
||||||
@@ -428,7 +430,7 @@ private slots:
|
|||||||
void editorContentsChange(int position, int charsRemoved, int charsAdded);
|
void editorContentsChange(int position, int charsRemoved, int charsAdded);
|
||||||
void memorizeCursorPosition();
|
void memorizeCursorPosition();
|
||||||
void restoreCursorPosition();
|
void restoreCursorPosition();
|
||||||
void highlightSearchResults(const QString &txt, QTextDocument::FindFlags findFlags);
|
void highlightSearchResults(const QString &txt, Find::IFindSupport::FindFlags findFlags);
|
||||||
void setFindScope(const QTextCursor &);
|
void setFindScope(const QTextCursor &);
|
||||||
void currentEditorChanged(Core::IEditor *editor);
|
void currentEditorChanged(Core::IEditor *editor);
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public:
|
|||||||
QTextCharFormat m_ifdefedOutFormat;
|
QTextCharFormat m_ifdefedOutFormat;
|
||||||
|
|
||||||
QRegExp m_searchExpr;
|
QRegExp m_searchExpr;
|
||||||
QTextDocument::FindFlags m_findFlags;
|
Find::IFindSupport::FindFlags m_findFlags;
|
||||||
QTextCharFormat m_searchResultFormat;
|
QTextCharFormat m_searchResultFormat;
|
||||||
QTextCharFormat m_searchScopeFormat;
|
QTextCharFormat m_searchScopeFormat;
|
||||||
QTextCharFormat m_currentLineFormat;
|
QTextCharFormat m_currentLineFormat;
|
||||||
|
|||||||
Reference in New Issue
Block a user