diff --git a/src/plugins/find/finddialog.ui b/src/plugins/find/finddialog.ui
index 7f8a3c0c7d3..98ae78e1091 100644
--- a/src/plugins/find/finddialog.ui
+++ b/src/plugins/find/finddialog.ui
@@ -6,8 +6,8 @@
0
0
- 378
- 123
+ 450
+ 221
@@ -96,7 +96,7 @@
- -
+
-
@@ -106,20 +106,6 @@
- -
-
-
- &Case sensitive
-
-
-
- -
-
-
- &Whole words only
-
-
-
-
@@ -127,8 +113,51 @@
+ -
+
+
+
+ 0
+
+
-
+
+
+ &Case sensitive
+
+
+
+ -
+
+
+ &Whole words only
+
+
+
+ -
+
+
+ Use regular E&xpressions
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
@@ -137,8 +166,6 @@
searchButton
closeButton
replaceButton
- matchCase
- wholeWords
diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp
index 0608dee941f..4d6d5dc789a 100644
--- a/src/plugins/find/findplugin.cpp
+++ b/src/plugins/find/findplugin.cpp
@@ -265,6 +265,11 @@ void FindPlugin::setBackward(bool backward)
setFindFlag(Find::FindBackward, backward);
}
+void FindPlugin::setRegularExpression(bool regExp)
+{
+ setFindFlag(Find::FindRegularExpression, regExp);
+}
+
void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
{
bool hasFlag = hasFindFlag(flag);
@@ -287,9 +292,10 @@ void FindPlugin::writeSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup("Find");
- 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("Backward", hasFindFlag(Find::FindBackward));
+ settings->setValue("CaseSensitively", hasFindFlag(Find::FindCaseSensitively));
+ settings->setValue("WholeWords", hasFindFlag(Find::FindWholeWords));
+ settings->setValue("RegularExpression", hasFindFlag(Find::FindRegularExpression));
settings->setValue("FindStrings", d->m_findCompletions);
settings->setValue("ReplaceStrings", d->m_replaceCompletions);
settings->endGroup();
@@ -305,6 +311,7 @@ void FindPlugin::readSettings()
setBackward(settings->value("Backward", false).toBool());
setCaseSensitive(settings->value("CaseSensitively", false).toBool());
setWholeWord(settings->value("WholeWords", false).toBool());
+ setRegularExpression(settings->value("RegularExpression", false).toBool());
blockSignals(block);
d->m_findCompletions = settings->value("FindStrings").toStringList();
d->m_replaceCompletions = settings->value("ReplaceStrings").toStringList();
diff --git a/src/plugins/find/findplugin.h b/src/plugins/find/findplugin.h
index fa4c9e00730..d76af80d46d 100644
--- a/src/plugins/find/findplugin.h
+++ b/src/plugins/find/findplugin.h
@@ -71,6 +71,7 @@ public:
ShutdownFlag aboutToShutdown();
Find::FindFlags findFlags() const;
+ bool hasFindFlag(Find::FindFlag flag);
void updateFindCompletion(const QString &text);
void updateReplaceCompletion(const QString &text);
QStringListModel *findCompletionModel() const;
@@ -82,6 +83,7 @@ public slots:
void setCaseSensitive(bool sensitive);
void setWholeWord(bool wholeOnly);
void setBackward(bool backward);
+ void setRegularExpression(bool regExp);
signals:
void findFlagsChanged();
@@ -92,7 +94,6 @@ private slots:
private:
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();
diff --git a/src/plugins/find/findtoolwindow.cpp b/src/plugins/find/findtoolwindow.cpp
index 63993c13cd4..c523e35b844 100644
--- a/src/plugins/find/findtoolwindow.cpp
+++ b/src/plugins/find/findtoolwindow.cpp
@@ -53,6 +53,7 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin)
connect(m_ui.replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
connect(m_ui.matchCase, SIGNAL(toggled(bool)), m_plugin, SLOT(setCaseSensitive(bool)));
connect(m_ui.wholeWords, SIGNAL(toggled(bool)), m_plugin, SLOT(setWholeWord(bool)));
+ connect(m_ui.regExp, SIGNAL(toggled(bool)), m_plugin, SLOT(setRegularExpression(bool)));
connect(m_ui.filterList, SIGNAL(activated(int)), this, SLOT(setCurrentFilter(int)));
connect(m_ui.searchTerm, SIGNAL(textChanged(QString)), this, SLOT(updateButtonStates()));
m_findCompleter->setModel(m_plugin->findCompletionModel());
@@ -119,8 +120,10 @@ void FindToolWindow::open(IFindFilter *filter)
if (index >= 0) {
setCurrentFilter(index);
}
- m_ui.matchCase->setChecked(m_plugin->findFlags() & QTextDocument::FindCaseSensitively);
- m_ui.wholeWords->setChecked(m_plugin->findFlags() & QTextDocument::FindWholeWords);
+ 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.searchTerm->setFocus();
m_ui.searchTerm->selectAll();
exec();
@@ -134,8 +137,12 @@ void FindToolWindow::setCurrentFilter(int index)
if (i == index) {
m_currentFilter = m_filters.at(i);
bool enabled = m_currentFilter->isEnabled();
- m_ui.matchCase->setEnabled(enabled);
- m_ui.wholeWords->setEnabled(enabled);
+ m_ui.matchCase->setEnabled(enabled
+ && (m_currentFilter->supportedFindFlags() & Find::FindCaseSensitively));
+ m_ui.wholeWords->setEnabled(enabled
+ && (m_currentFilter->supportedFindFlags() & Find::FindWholeWords));
+ m_ui.regExp->setEnabled(enabled
+ && (m_currentFilter->supportedFindFlags() & Find::FindRegularExpression));
m_ui.searchTerm->setEnabled(enabled);
updateButtonStates();
if (configWidget) {
diff --git a/src/plugins/find/ifindfilter.cpp b/src/plugins/find/ifindfilter.cpp
index d2eef03065a..63c08c4fefd 100644
--- a/src/plugins/find/ifindfilter.cpp
+++ b/src/plugins/find/ifindfilter.cpp
@@ -111,7 +111,7 @@
*/
/*!
- \fn void IFindFilter::findAll(const QString &txt, QTextDocument::FindFlags findFlags)
+ \fn void IFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
\brief This method is called when the user selected this find scope and
initiated a search.
@@ -128,7 +128,7 @@
*/
/*!
- \fn void IFindFilter::replaceAll(const QString &txt, QTextDocument::FindFlags findFlags)
+ \fn void IFindFilter::replaceAll(const QString &txt, Find::FindFlags findFlags)
\brief Override this method if you want to support search and replace.
This method is called when the user selected this find scope and
@@ -172,3 +172,19 @@
\fn void IFindFilter::changed()
\brief Signals that the enabled state of this find filter has changed.
*/
+
+/*!
+ \fn Find::FindFlags BaseTextFind::supportedFindFlags() const
+ \brief Returns the find flags, like whole words or regular expressions,
+ that this find filter supports.
+
+ Depending on the returned value, the default find option widgets are
+ enabled or disabled.
+ The default is Find::FindCaseSensitively, Find::FindRegularExpression
+ and Find::FindWholeWords
+*/
+Find::FindFlags Find::IFindFilter::supportedFindFlags() const
+{
+ return Find::FindCaseSensitively
+ | Find::FindRegularExpression | Find::FindWholeWords;
+}
diff --git a/src/plugins/find/ifindfilter.h b/src/plugins/find/ifindfilter.h
index da3059ce9d9..72d8cacdec8 100644
--- a/src/plugins/find/ifindfilter.h
+++ b/src/plugins/find/ifindfilter.h
@@ -55,6 +55,7 @@ public:
virtual bool isEnabled() const = 0;
virtual QKeySequence defaultShortcut() const = 0;
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)
diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp
index 78823bda17a..9bf1c995790 100644
--- a/src/plugins/projectexplorer/allprojectsfind.cpp
+++ b/src/plugins/projectexplorer/allprojectsfind.cpp
@@ -113,15 +113,14 @@ QWidget *AllProjectsFind::createConfigWidget()
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
gridLayout->setMargin(0);
m_configWidget->setLayout(gridLayout);
- gridLayout->addWidget(createRegExpWidget(), 0, 1);
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
filePatternLabel->setMinimumWidth(80);
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QWidget *patternWidget = createPatternWidget();
filePatternLabel->setBuddy(patternWidget);
- gridLayout->addWidget(filePatternLabel, 1, 0, Qt::AlignRight);
- gridLayout->addWidget(patternWidget, 1, 1);
+ gridLayout->addWidget(filePatternLabel, 0, 0, Qt::AlignRight);
+ gridLayout->addWidget(patternWidget, 0, 1);
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
return m_configWidget;
diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp
index ef9ec44a9b5..55a2ba6950d 100644
--- a/src/plugins/projectexplorer/currentprojectfind.cpp
+++ b/src/plugins/projectexplorer/currentprojectfind.cpp
@@ -108,15 +108,14 @@ QWidget *CurrentProjectFind::createConfigWidget()
QGridLayout * const layout = new QGridLayout(m_configWidget);
layout->setMargin(0);
m_configWidget->setLayout(layout);
- layout->addWidget(createRegExpWidget(), 0, 1);
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
filePatternLabel->setMinimumWidth(80);
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QWidget *patternWidget = createPatternWidget();
filePatternLabel->setBuddy(patternWidget);
- layout->addWidget(filePatternLabel, 1, 0, Qt::AlignRight);
- layout->addWidget(patternWidget, 1, 1);
+ layout->addWidget(filePatternLabel, 0, 0, Qt::AlignRight);
+ layout->addWidget(patternWidget, 0, 1);
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
return m_configWidget;
diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp
index 63535ab81ed..9006e11a736 100644
--- a/src/plugins/texteditor/basefilefind.cpp
+++ b/src/plugins/texteditor/basefilefind.cpp
@@ -58,9 +58,7 @@ BaseFileFind::BaseFileFind(SearchResultWindow *resultWindow)
: m_resultWindow(resultWindow),
m_isSearching(false),
m_resultLabel(0),
- m_filterCombo(0),
- m_useRegExp(false),
- m_useRegExpCheckBox(0)
+ m_filterCombo(0)
{
m_watcher.setPendingResultsLimit(1);
connect(&m_watcher, SIGNAL(resultReadyAt(int)), this, SLOT(displayResult(int)));
@@ -97,7 +95,7 @@ void BaseFileFind::findAll(const QString &txt, Find::FindFlags findFlags)
SearchResult *result = m_resultWindow->startNewSearch();
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
m_resultWindow->popup(true);
- if (m_useRegExp) {
+ if (findFlags & Find::FindRegularExpression) {
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
} else {
@@ -124,7 +122,7 @@ void BaseFileFind::replaceAll(const QString &txt, Find::FindFlags findFlags)
connect(result, SIGNAL(replaceButtonClicked(QString,QList)),
this, SLOT(doReplace(QString,QList)));
m_resultWindow->popup(true);
- if (m_useRegExp) {
+ if (findFlags & Find::FindRegularExpression) {
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
} else {
@@ -192,20 +190,7 @@ QWidget *BaseFileFind::createProgressWidget()
QWidget *BaseFileFind::createPatternWidget()
{
-/*
- QWidget *widget = new QWidget;
- QHBoxLayout *hlayout = new QHBoxLayout(widget);
- hlayout->setMargin(0);
- widget->setLayout(hlayout);
-*/
QString filterToolTip = tr("List of comma separated wildcard filters");
-/*
- QLabel *label = new QLabel(tr("File &pattern:"));
- label->setToolTip(filterToolTip);
-*/
-/*
- hlayout->addWidget(label);
-*/
m_filterCombo = new QComboBox;
m_filterCombo->setEditable(true);
m_filterCombo->setModel(&m_filterStrings);
@@ -216,36 +201,20 @@ QWidget *BaseFileFind::createPatternWidget()
m_filterCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_filterCombo->setToolTip(filterToolTip);
syncComboWithSettings(m_filterCombo, m_filterSetting);
-/*
- label->setBuddy(m_filterCombo);
- hlayout->addWidget(m_filterCombo);
-*/
return m_filterCombo;
}
-QWidget *BaseFileFind::createRegExpWidget()
-{
- m_useRegExpCheckBox = new QCheckBox(tr("Use regular e&xpressions"));
- m_useRegExpCheckBox->setChecked(m_useRegExp);
- connect(m_useRegExpCheckBox, SIGNAL(toggled(bool)), this, SLOT(syncRegExpSetting(bool)));
- return m_useRegExpCheckBox;
-}
-
void BaseFileFind::writeCommonSettings(QSettings *settings)
{
settings->setValue("filters", m_filterStrings.stringList());
if (m_filterCombo)
settings->setValue("currentFilter", m_filterCombo->currentText());
- settings->setValue("useRegExp", m_useRegExp);
}
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter)
{
QStringList filters = settings->value("filters").toStringList();
m_filterSetting = settings->value("currentFilter").toString();
- m_useRegExp = settings->value("useRegExp", false).toBool();
- if (m_useRegExpCheckBox)
- m_useRegExpCheckBox->setChecked(m_useRegExp);
if (filters.isEmpty())
filters << defaultFilter;
if (m_filterSetting.isEmpty())
@@ -279,11 +248,6 @@ void BaseFileFind::updateComboEntries(QComboBox *combo, bool onTop)
}
}
-void BaseFileFind::syncRegExpSetting(bool useRegExp)
-{
- m_useRegExp = useRegExp;
-}
-
void BaseFileFind::openEditor(const Find::SearchResultItem &item)
{
TextEditor::BaseTextEditor::openEditorAt(item.fileName, item.lineNumber, item.searchTermStart);
diff --git a/src/plugins/texteditor/basefilefind.h b/src/plugins/texteditor/basefilefind.h
index 2c2123a7da6..1a26154d405 100644
--- a/src/plugins/texteditor/basefilefind.h
+++ b/src/plugins/texteditor/basefilefind.h
@@ -75,7 +75,6 @@ protected:
void writeCommonSettings(QSettings *settings);
void readCommonSettings(QSettings *settings, const QString &defaultFilter);
QWidget *createPatternWidget();
- QWidget *createRegExpWidget();
void syncComboWithSettings(QComboBox *combo, const QString &setting);
void updateComboEntries(QComboBox *combo, bool onTop);
QStringList fileNameFilters() const;
@@ -84,7 +83,6 @@ private slots:
void displayResult(int index);
void searchFinished();
void openEditor(const Find::SearchResultItem &item);
- void syncRegExpSetting(bool useRegExp);
void doReplace(const QString &txt,
const QList &items);
@@ -98,8 +96,6 @@ private:
QStringListModel m_filterStrings;
QString m_filterSetting;
QPointer m_filterCombo;
- bool m_useRegExp;
- QCheckBox *m_useRegExpCheckBox;
};
} // namespace TextEditor
diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp
index 51f9eb3fe8c..cad56dd7a44 100644
--- a/src/plugins/texteditor/findincurrentfile.cpp
+++ b/src/plugins/texteditor/findincurrentfile.cpp
@@ -104,7 +104,6 @@ QWidget *FindInCurrentFile::createConfigWidget()
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
gridLayout->setMargin(0);
m_configWidget->setLayout(gridLayout);
- gridLayout->addWidget(createRegExpWidget(), 0, 1, 1, 2);
// just for the layout HACK
QLabel * const filePatternLabel = new QLabel;
filePatternLabel->setMinimumWidth(80);
diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp
index 05d313d509d..f2bbc54300e 100644
--- a/src/plugins/texteditor/findinfiles.cpp
+++ b/src/plugins/texteditor/findinfiles.cpp
@@ -81,10 +81,9 @@ QWidget *FindInFiles::createConfigWidget()
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
gridLayout->setMargin(0);
m_configWidget->setLayout(gridLayout);
- gridLayout->addWidget(createRegExpWidget(), 0, 1, 1, 2);
QLabel *dirLabel = new QLabel(tr("&Directory:"));
- gridLayout->addWidget(dirLabel, 1, 0, Qt::AlignRight);
+ gridLayout->addWidget(dirLabel, 0, 0, Qt::AlignRight);
m_directory = new QComboBox;
m_directory->setEditable(true);
m_directory->setMaxCount(30);
@@ -95,9 +94,9 @@ QWidget *FindInFiles::createConfigWidget()
m_directory->setModel(&m_directoryStrings);
syncComboWithSettings(m_directory, m_directorySetting);
dirLabel->setBuddy(m_directory);
- gridLayout->addWidget(m_directory, 1, 1);
+ gridLayout->addWidget(m_directory, 0, 1);
QPushButton *browseButton = new QPushButton(tr("&Browse"));
- gridLayout->addWidget(browseButton, 1, 2);
+ gridLayout->addWidget(browseButton, 0, 2);
connect(browseButton, SIGNAL(clicked()), this, SLOT(openFileBrowser()));
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
@@ -106,8 +105,8 @@ QWidget *FindInFiles::createConfigWidget()
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QWidget *patternWidget = createPatternWidget();
filePatternLabel->setBuddy(patternWidget);
- gridLayout->addWidget(filePatternLabel, 2, 0);
- gridLayout->addWidget(patternWidget, 2, 1, 1, 2);
+ gridLayout->addWidget(filePatternLabel, 1, 0);
+ gridLayout->addWidget(patternWidget, 1, 1, 1, 2);
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
return m_configWidget;