Commit a8316c46 authored by con's avatar con

Use the Find::FindFlags also for the search dialog.

parent cecf9ac2
......@@ -87,7 +87,7 @@ struct FindPluginPrivate {
Internal::CurrentDocumentFind *m_currentDocumentFind;
Internal::FindToolBar *m_findToolBar;
Internal::FindToolWindow *m_findDialog;
QTextDocument::FindFlags m_findFlags;
Find::FindFlags m_findFlags;
QStringListModel *m_findCompletionModel;
QStringListModel *m_replaceCompletionModel;
QStringList m_findCompletions;
......@@ -245,27 +245,27 @@ void FindPlugin::setupFilterMenuItems()
d->m_openFindDialog->setEnabled(haveEnabledFilters);
}
QTextDocument::FindFlags FindPlugin::findFlags() const
Find::FindFlags FindPlugin::findFlags() const
{
return d->m_findFlags;
}
void FindPlugin::setCaseSensitive(bool sensitive)
{
setFindFlag(QTextDocument::FindCaseSensitively, sensitive);
setFindFlag(Find::FindCaseSensitively, sensitive);
}
void FindPlugin::setWholeWord(bool wholeOnly)
{
setFindFlag(QTextDocument::FindWholeWords, wholeOnly);
setFindFlag(Find::FindWholeWords, wholeOnly);
}
void FindPlugin::setBackward(bool backward)
{
setFindFlag(QTextDocument::FindBackward, backward);
setFindFlag(Find::FindBackward, backward);
}
void FindPlugin::setFindFlag(QTextDocument::FindFlag flag, bool enabled)
void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
{
bool hasFlag = hasFindFlag(flag);
if ((hasFlag && enabled) || (!hasFlag && !enabled))
......@@ -274,11 +274,11 @@ void FindPlugin::setFindFlag(QTextDocument::FindFlag flag, bool enabled)
d->m_findFlags |= flag;
else
d->m_findFlags &= ~flag;
if (flag != QTextDocument::FindBackward)
if (flag != Find::FindBackward)
emit findFlagsChanged();
}
bool FindPlugin::hasFindFlag(QTextDocument::FindFlag flag)
bool FindPlugin::hasFindFlag(Find::FindFlag flag)
{
return d->m_findFlags & flag;
}
......@@ -287,9 +287,9 @@ void FindPlugin::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("Find");
settings->setValue("Backward", QVariant((d->m_findFlags & QTextDocument::FindBackward) != 0));
settings->setValue("CaseSensitively", QVariant((d->m_findFlags & QTextDocument::FindCaseSensitively) != 0));
settings->setValue("WholeWords", QVariant((d->m_findFlags & QTextDocument::FindWholeWords) != 0));
settings->setValue("Backward", QVariant((d->m_findFlags & Find::FindBackward) != 0));
settings->setValue("CaseSensitively", QVariant((d->m_findFlags & Find::FindCaseSensitively) != 0));
settings->setValue("WholeWords", QVariant((d->m_findFlags & Find::FindWholeWords) != 0));
settings->setValue("FindStrings", d->m_findCompletions);
settings->setValue("ReplaceStrings", d->m_replaceCompletions);
settings->endGroup();
......@@ -361,7 +361,10 @@ QStringListModel *FindPlugin::replaceCompletionModel() const
return d->m_replaceCompletionModel;
}
QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
} // namespace Find
// declared in textfindconstants.h
QTextDocument::FindFlags Find::textDocumentFlagsForFindFlags(Find::FindFlags flags)
{
QTextDocument::FindFlags textDocFlags;
if (flags & Find::FindBackward)
......@@ -373,6 +376,4 @@ QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
return textDocFlags;
}
} // namespace Find
Q_EXPORT_PLUGIN(Find::FindPlugin)
......@@ -31,6 +31,7 @@
#define FINDPLUGIN_H
#include "find_global.h"
#include "textfindconstants.h"
#include <extensionsystem/iplugin.h>
......@@ -69,7 +70,7 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
QTextDocument::FindFlags findFlags() const;
Find::FindFlags findFlags() const;
void updateFindCompletion(const QString &text);
void updateReplaceCompletion(const QString &text);
QStringListModel *findCompletionModel() const;
......@@ -90,8 +91,8 @@ private slots:
void openFindFilter();
private:
void setFindFlag(QTextDocument::FindFlag flag, bool enabled);
bool hasFindFlag(QTextDocument::FindFlag flag);
void setFindFlag(Find::FindFlag flag, bool enabled);
bool hasFindFlag(Find::FindFlag flag);
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
void setupMenu();
void setupFilterMenuItems();
......
......@@ -31,6 +31,7 @@
#define IFINDFILTER_H
#include "find_global.h"
#include "textfindconstants.h"
#include <QtGui/QTextDocument>
......@@ -55,8 +56,8 @@ public:
virtual QKeySequence defaultShortcut() const = 0;
virtual bool isReplaceSupported() const { return false; }
virtual void findAll(const QString &txt, QTextDocument::FindFlags findFlags) = 0;
virtual void replaceAll(const QString &txt, QTextDocument::FindFlags findFlags)
virtual void findAll(const QString &txt, Find::FindFlags findFlags) = 0;
virtual void replaceAll(const QString &txt, Find::FindFlags findFlags)
{ Q_UNUSED(txt) Q_UNUSED(findFlags) }
virtual QWidget *createConfigWidget() { return 0; }
......
......@@ -71,7 +71,7 @@ enum FindFlag {
Q_DECLARE_FLAGS(FindFlags, FindFlag)
// defined in findplugin.cpp
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(Find::FindFlags flags);
} // namespace Find
......
......@@ -87,7 +87,7 @@ QStringList BaseFileFind::fileNameFilters() const
return filters;
}
void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlags)
void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
{
m_isSearching = true;
emit changed();
......@@ -97,10 +97,13 @@ void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlag
SearchResult *result = m_resultWindow->startNewSearch();
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
m_resultWindow->popup(true);
if (m_useRegExp)
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(), findFlags, ITextEditor::openedTextEditorsContents()));
else
m_watcher.setFuture(Utils::findInFiles(txt, files(), findFlags, ITextEditor::openedTextEditorsContents()));
if (m_useRegExp) {
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
} else {
m_watcher.setFuture(Utils::findInFiles(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
}
Core::FutureProgress *progress =
Core::ICore::instance()->progressManager()->addTask(m_watcher.future(),
"Search",
......@@ -109,7 +112,7 @@ void BaseFileFind::findAll(const QString &txt, QTextDocument::FindFlags findFlag
connect(progress, SIGNAL(clicked()), m_resultWindow, SLOT(popup()));
}
void BaseFileFind::replaceAll(const QString &txt, QTextDocument::FindFlags findFlags)
void BaseFileFind::replaceAll(const QString &txt, Find::FindFlags findFlags)
{
m_isSearching = true;
emit changed();
......@@ -121,10 +124,13 @@ void BaseFileFind::replaceAll(const QString &txt, QTextDocument::FindFlags findF
connect(result, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
this, SLOT(doReplace(QString,QList<Find::SearchResultItem>)));
m_resultWindow->popup(true);
if (m_useRegExp)
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(), findFlags, ITextEditor::openedTextEditorsContents()));
else
m_watcher.setFuture(Utils::findInFiles(txt, files(), findFlags, ITextEditor::openedTextEditorsContents()));
if (m_useRegExp) {
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
} else {
m_watcher.setFuture(Utils::findInFiles(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
}
Core::FutureProgress *progress =
Core::ICore::instance()->progressManager()->addTask(m_watcher.future(),
"Search",
......
......@@ -63,8 +63,8 @@ public:
bool isEnabled() const;
bool isReplaceSupported() const { return true; }
void findAll(const QString &txt, QTextDocument::FindFlags findFlags);
void replaceAll(const QString &txt, QTextDocument::FindFlags findFlags);
void findAll(const QString &txt, Find::FindFlags findFlags);
void replaceAll(const QString &txt, Find::FindFlags findFlags);
/* returns the list of unique files that were passed in items */
static QStringList replaceAll(const QString &txt,
......
......@@ -62,7 +62,7 @@ QKeySequence FindInFiles::defaultShortcut() const
return QKeySequence();
}
void FindInFiles::findAll(const QString &txt, QTextDocument::FindFlags findFlags)
void FindInFiles::findAll(const QString &txt, Find::FindFlags findFlags)
{
updateComboEntries(m_directory, true);
BaseFileFind::findAll(txt, findFlags);
......
......@@ -54,7 +54,7 @@ public:
QString id() const;
QString displayName() const;
QKeySequence defaultShortcut() const;
void findAll(const QString &txt, QTextDocument::FindFlags findFlags);
void findAll(const QString &txt, Find::FindFlags findFlags);
QWidget *createConfigWidget();
void writeSettings(QSettings *settings);
void readSettings(QSettings *settings);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment