forked from qt-creator/qt-creator
Make "Use regular expressions" a general option for find filters.
This was the main goal of the new generalized Find::FindFlags
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>378</width>
|
<width>450</width>
|
||||||
<height>123</height>
|
<height>221</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QWidget" name="configWidget" native="true">
|
<widget class="QWidget" name="configWidget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
@@ -106,20 +106,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QCheckBox" name="matchCase">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Case sensitive</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QCheckBox" name="wholeWords">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Whole words only</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
<widget class="QPushButton" name="replaceButton">
|
<widget class="QPushButton" name="replaceButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -127,8 +113,51 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1" rowspan="3">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="matchCase">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Case sensitive</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="wholeWords">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Whole words only</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="regExp">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use regular E&xpressions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
@@ -137,8 +166,6 @@
|
|||||||
<tabstop>searchButton</tabstop>
|
<tabstop>searchButton</tabstop>
|
||||||
<tabstop>closeButton</tabstop>
|
<tabstop>closeButton</tabstop>
|
||||||
<tabstop>replaceButton</tabstop>
|
<tabstop>replaceButton</tabstop>
|
||||||
<tabstop>matchCase</tabstop>
|
|
||||||
<tabstop>wholeWords</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
@@ -265,6 +265,11 @@ void FindPlugin::setBackward(bool backward)
|
|||||||
setFindFlag(Find::FindBackward, backward);
|
setFindFlag(Find::FindBackward, backward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FindPlugin::setRegularExpression(bool regExp)
|
||||||
|
{
|
||||||
|
setFindFlag(Find::FindRegularExpression, regExp);
|
||||||
|
}
|
||||||
|
|
||||||
void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
|
void FindPlugin::setFindFlag(Find::FindFlag flag, bool enabled)
|
||||||
{
|
{
|
||||||
bool hasFlag = hasFindFlag(flag);
|
bool hasFlag = hasFindFlag(flag);
|
||||||
@@ -287,9 +292,10 @@ void FindPlugin::writeSettings()
|
|||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup("Find");
|
settings->beginGroup("Find");
|
||||||
settings->setValue("Backward", QVariant((d->m_findFlags & Find::FindBackward) != 0));
|
settings->setValue("Backward", hasFindFlag(Find::FindBackward));
|
||||||
settings->setValue("CaseSensitively", QVariant((d->m_findFlags & Find::FindCaseSensitively) != 0));
|
settings->setValue("CaseSensitively", hasFindFlag(Find::FindCaseSensitively));
|
||||||
settings->setValue("WholeWords", QVariant((d->m_findFlags & Find::FindWholeWords) != 0));
|
settings->setValue("WholeWords", hasFindFlag(Find::FindWholeWords));
|
||||||
|
settings->setValue("RegularExpression", hasFindFlag(Find::FindRegularExpression));
|
||||||
settings->setValue("FindStrings", d->m_findCompletions);
|
settings->setValue("FindStrings", d->m_findCompletions);
|
||||||
settings->setValue("ReplaceStrings", d->m_replaceCompletions);
|
settings->setValue("ReplaceStrings", d->m_replaceCompletions);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
@@ -305,6 +311,7 @@ void FindPlugin::readSettings()
|
|||||||
setBackward(settings->value("Backward", false).toBool());
|
setBackward(settings->value("Backward", false).toBool());
|
||||||
setCaseSensitive(settings->value("CaseSensitively", false).toBool());
|
setCaseSensitive(settings->value("CaseSensitively", false).toBool());
|
||||||
setWholeWord(settings->value("WholeWords", false).toBool());
|
setWholeWord(settings->value("WholeWords", false).toBool());
|
||||||
|
setRegularExpression(settings->value("RegularExpression", false).toBool());
|
||||||
blockSignals(block);
|
blockSignals(block);
|
||||||
d->m_findCompletions = settings->value("FindStrings").toStringList();
|
d->m_findCompletions = settings->value("FindStrings").toStringList();
|
||||||
d->m_replaceCompletions = settings->value("ReplaceStrings").toStringList();
|
d->m_replaceCompletions = settings->value("ReplaceStrings").toStringList();
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ public:
|
|||||||
ShutdownFlag aboutToShutdown();
|
ShutdownFlag aboutToShutdown();
|
||||||
|
|
||||||
Find::FindFlags findFlags() const;
|
Find::FindFlags findFlags() const;
|
||||||
|
bool hasFindFlag(Find::FindFlag flag);
|
||||||
void updateFindCompletion(const QString &text);
|
void updateFindCompletion(const QString &text);
|
||||||
void updateReplaceCompletion(const QString &text);
|
void updateReplaceCompletion(const QString &text);
|
||||||
QStringListModel *findCompletionModel() const;
|
QStringListModel *findCompletionModel() const;
|
||||||
@@ -82,6 +83,7 @@ public slots:
|
|||||||
void setCaseSensitive(bool sensitive);
|
void setCaseSensitive(bool sensitive);
|
||||||
void setWholeWord(bool wholeOnly);
|
void setWholeWord(bool wholeOnly);
|
||||||
void setBackward(bool backward);
|
void setBackward(bool backward);
|
||||||
|
void setRegularExpression(bool regExp);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void findFlagsChanged();
|
void findFlagsChanged();
|
||||||
@@ -92,7 +94,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setFindFlag(Find::FindFlag flag, bool enabled);
|
void setFindFlag(Find::FindFlag flag, bool enabled);
|
||||||
bool hasFindFlag(Find::FindFlag flag);
|
|
||||||
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
|
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
|
||||||
void setupMenu();
|
void setupMenu();
|
||||||
void setupFilterMenuItems();
|
void setupFilterMenuItems();
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin)
|
|||||||
connect(m_ui.replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
|
connect(m_ui.replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
|
||||||
connect(m_ui.matchCase, SIGNAL(toggled(bool)), m_plugin, SLOT(setCaseSensitive(bool)));
|
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.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.filterList, SIGNAL(activated(int)), this, SLOT(setCurrentFilter(int)));
|
||||||
connect(m_ui.searchTerm, SIGNAL(textChanged(QString)), this, SLOT(updateButtonStates()));
|
connect(m_ui.searchTerm, SIGNAL(textChanged(QString)), this, SLOT(updateButtonStates()));
|
||||||
m_findCompleter->setModel(m_plugin->findCompletionModel());
|
m_findCompleter->setModel(m_plugin->findCompletionModel());
|
||||||
@@ -119,8 +120,10 @@ void FindToolWindow::open(IFindFilter *filter)
|
|||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
setCurrentFilter(index);
|
setCurrentFilter(index);
|
||||||
}
|
}
|
||||||
m_ui.matchCase->setChecked(m_plugin->findFlags() & QTextDocument::FindCaseSensitively);
|
m_ui.matchCase->setChecked(m_plugin->hasFindFlag(Find::FindCaseSensitively));
|
||||||
m_ui.wholeWords->setChecked(m_plugin->findFlags() & QTextDocument::FindWholeWords);
|
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->setFocus();
|
||||||
m_ui.searchTerm->selectAll();
|
m_ui.searchTerm->selectAll();
|
||||||
exec();
|
exec();
|
||||||
@@ -134,8 +137,12 @@ void FindToolWindow::setCurrentFilter(int index)
|
|||||||
if (i == index) {
|
if (i == index) {
|
||||||
m_currentFilter = m_filters.at(i);
|
m_currentFilter = m_filters.at(i);
|
||||||
bool enabled = m_currentFilter->isEnabled();
|
bool enabled = m_currentFilter->isEnabled();
|
||||||
m_ui.matchCase->setEnabled(enabled);
|
m_ui.matchCase->setEnabled(enabled
|
||||||
m_ui.wholeWords->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);
|
m_ui.searchTerm->setEnabled(enabled);
|
||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
if (configWidget) {
|
if (configWidget) {
|
||||||
|
|||||||
@@ -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
|
\brief This method is called when the user selected this find scope and
|
||||||
initiated a search.
|
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.
|
\brief Override this method if you want to support search and replace.
|
||||||
|
|
||||||
This method is called when the user selected this find scope and
|
This method is called when the user selected this find scope and
|
||||||
@@ -172,3 +172,19 @@
|
|||||||
\fn void IFindFilter::changed()
|
\fn void IFindFilter::changed()
|
||||||
\brief Signals that the enabled state of this find filter has 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
virtual bool isEnabled() const = 0;
|
virtual bool isEnabled() const = 0;
|
||||||
virtual QKeySequence defaultShortcut() const = 0;
|
virtual QKeySequence defaultShortcut() const = 0;
|
||||||
virtual bool isReplaceSupported() const { return false; }
|
virtual bool isReplaceSupported() const { return false; }
|
||||||
|
virtual FindFlags supportedFindFlags() const;
|
||||||
|
|
||||||
virtual void findAll(const QString &txt, Find::FindFlags findFlags) = 0;
|
virtual void findAll(const QString &txt, Find::FindFlags findFlags) = 0;
|
||||||
virtual void replaceAll(const QString &txt, Find::FindFlags findFlags)
|
virtual void replaceAll(const QString &txt, Find::FindFlags findFlags)
|
||||||
|
|||||||
@@ -113,15 +113,14 @@ QWidget *AllProjectsFind::createConfigWidget()
|
|||||||
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
||||||
gridLayout->setMargin(0);
|
gridLayout->setMargin(0);
|
||||||
m_configWidget->setLayout(gridLayout);
|
m_configWidget->setLayout(gridLayout);
|
||||||
gridLayout->addWidget(createRegExpWidget(), 0, 1);
|
|
||||||
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
||||||
filePatternLabel->setMinimumWidth(80);
|
filePatternLabel->setMinimumWidth(80);
|
||||||
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
QWidget *patternWidget = createPatternWidget();
|
QWidget *patternWidget = createPatternWidget();
|
||||||
filePatternLabel->setBuddy(patternWidget);
|
filePatternLabel->setBuddy(patternWidget);
|
||||||
gridLayout->addWidget(filePatternLabel, 1, 0, Qt::AlignRight);
|
gridLayout->addWidget(filePatternLabel, 0, 0, Qt::AlignRight);
|
||||||
gridLayout->addWidget(patternWidget, 1, 1);
|
gridLayout->addWidget(patternWidget, 0, 1);
|
||||||
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
return m_configWidget;
|
return m_configWidget;
|
||||||
|
|||||||
@@ -108,15 +108,14 @@ QWidget *CurrentProjectFind::createConfigWidget()
|
|||||||
QGridLayout * const layout = new QGridLayout(m_configWidget);
|
QGridLayout * const layout = new QGridLayout(m_configWidget);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
m_configWidget->setLayout(layout);
|
m_configWidget->setLayout(layout);
|
||||||
layout->addWidget(createRegExpWidget(), 0, 1);
|
|
||||||
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
||||||
filePatternLabel->setMinimumWidth(80);
|
filePatternLabel->setMinimumWidth(80);
|
||||||
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
filePatternLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
QWidget *patternWidget = createPatternWidget();
|
QWidget *patternWidget = createPatternWidget();
|
||||||
filePatternLabel->setBuddy(patternWidget);
|
filePatternLabel->setBuddy(patternWidget);
|
||||||
layout->addWidget(filePatternLabel, 1, 0, Qt::AlignRight);
|
layout->addWidget(filePatternLabel, 0, 0, Qt::AlignRight);
|
||||||
layout->addWidget(patternWidget, 1, 1);
|
layout->addWidget(patternWidget, 0, 1);
|
||||||
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
return m_configWidget;
|
return m_configWidget;
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ BaseFileFind::BaseFileFind(SearchResultWindow *resultWindow)
|
|||||||
: m_resultWindow(resultWindow),
|
: m_resultWindow(resultWindow),
|
||||||
m_isSearching(false),
|
m_isSearching(false),
|
||||||
m_resultLabel(0),
|
m_resultLabel(0),
|
||||||
m_filterCombo(0),
|
m_filterCombo(0)
|
||||||
m_useRegExp(false),
|
|
||||||
m_useRegExpCheckBox(0)
|
|
||||||
{
|
{
|
||||||
m_watcher.setPendingResultsLimit(1);
|
m_watcher.setPendingResultsLimit(1);
|
||||||
connect(&m_watcher, SIGNAL(resultReadyAt(int)), this, SLOT(displayResult(int)));
|
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();
|
SearchResult *result = m_resultWindow->startNewSearch();
|
||||||
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
connect(result, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem)));
|
||||||
m_resultWindow->popup(true);
|
m_resultWindow->popup(true);
|
||||||
if (m_useRegExp) {
|
if (findFlags & Find::FindRegularExpression) {
|
||||||
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
||||||
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
||||||
} else {
|
} else {
|
||||||
@@ -124,7 +122,7 @@ void BaseFileFind::replaceAll(const QString &txt, Find::FindFlags findFlags)
|
|||||||
connect(result, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
connect(result, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
|
||||||
this, SLOT(doReplace(QString,QList<Find::SearchResultItem>)));
|
this, SLOT(doReplace(QString,QList<Find::SearchResultItem>)));
|
||||||
m_resultWindow->popup(true);
|
m_resultWindow->popup(true);
|
||||||
if (m_useRegExp) {
|
if (findFlags & Find::FindRegularExpression) {
|
||||||
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
m_watcher.setFuture(Utils::findInFilesRegExp(txt, files(),
|
||||||
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
textDocumentFlagsForFindFlags(findFlags), ITextEditor::openedTextEditorsContents()));
|
||||||
} else {
|
} else {
|
||||||
@@ -192,20 +190,7 @@ QWidget *BaseFileFind::createProgressWidget()
|
|||||||
|
|
||||||
QWidget *BaseFileFind::createPatternWidget()
|
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");
|
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 = new QComboBox;
|
||||||
m_filterCombo->setEditable(true);
|
m_filterCombo->setEditable(true);
|
||||||
m_filterCombo->setModel(&m_filterStrings);
|
m_filterCombo->setModel(&m_filterStrings);
|
||||||
@@ -216,36 +201,20 @@ QWidget *BaseFileFind::createPatternWidget()
|
|||||||
m_filterCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
m_filterCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
m_filterCombo->setToolTip(filterToolTip);
|
m_filterCombo->setToolTip(filterToolTip);
|
||||||
syncComboWithSettings(m_filterCombo, m_filterSetting);
|
syncComboWithSettings(m_filterCombo, m_filterSetting);
|
||||||
/*
|
|
||||||
label->setBuddy(m_filterCombo);
|
|
||||||
hlayout->addWidget(m_filterCombo);
|
|
||||||
*/
|
|
||||||
return 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)
|
void BaseFileFind::writeCommonSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
settings->setValue("filters", m_filterStrings.stringList());
|
settings->setValue("filters", m_filterStrings.stringList());
|
||||||
if (m_filterCombo)
|
if (m_filterCombo)
|
||||||
settings->setValue("currentFilter", m_filterCombo->currentText());
|
settings->setValue("currentFilter", m_filterCombo->currentText());
|
||||||
settings->setValue("useRegExp", m_useRegExp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter)
|
void BaseFileFind::readCommonSettings(QSettings *settings, const QString &defaultFilter)
|
||||||
{
|
{
|
||||||
QStringList filters = settings->value("filters").toStringList();
|
QStringList filters = settings->value("filters").toStringList();
|
||||||
m_filterSetting = settings->value("currentFilter").toString();
|
m_filterSetting = settings->value("currentFilter").toString();
|
||||||
m_useRegExp = settings->value("useRegExp", false).toBool();
|
|
||||||
if (m_useRegExpCheckBox)
|
|
||||||
m_useRegExpCheckBox->setChecked(m_useRegExp);
|
|
||||||
if (filters.isEmpty())
|
if (filters.isEmpty())
|
||||||
filters << defaultFilter;
|
filters << defaultFilter;
|
||||||
if (m_filterSetting.isEmpty())
|
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)
|
void BaseFileFind::openEditor(const Find::SearchResultItem &item)
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextEditor::openEditorAt(item.fileName, item.lineNumber, item.searchTermStart);
|
TextEditor::BaseTextEditor::openEditorAt(item.fileName, item.lineNumber, item.searchTermStart);
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ protected:
|
|||||||
void writeCommonSettings(QSettings *settings);
|
void writeCommonSettings(QSettings *settings);
|
||||||
void readCommonSettings(QSettings *settings, const QString &defaultFilter);
|
void readCommonSettings(QSettings *settings, const QString &defaultFilter);
|
||||||
QWidget *createPatternWidget();
|
QWidget *createPatternWidget();
|
||||||
QWidget *createRegExpWidget();
|
|
||||||
void syncComboWithSettings(QComboBox *combo, const QString &setting);
|
void syncComboWithSettings(QComboBox *combo, const QString &setting);
|
||||||
void updateComboEntries(QComboBox *combo, bool onTop);
|
void updateComboEntries(QComboBox *combo, bool onTop);
|
||||||
QStringList fileNameFilters() const;
|
QStringList fileNameFilters() const;
|
||||||
@@ -84,7 +83,6 @@ private slots:
|
|||||||
void displayResult(int index);
|
void displayResult(int index);
|
||||||
void searchFinished();
|
void searchFinished();
|
||||||
void openEditor(const Find::SearchResultItem &item);
|
void openEditor(const Find::SearchResultItem &item);
|
||||||
void syncRegExpSetting(bool useRegExp);
|
|
||||||
void doReplace(const QString &txt,
|
void doReplace(const QString &txt,
|
||||||
const QList<Find::SearchResultItem> &items);
|
const QList<Find::SearchResultItem> &items);
|
||||||
|
|
||||||
@@ -98,8 +96,6 @@ private:
|
|||||||
QStringListModel m_filterStrings;
|
QStringListModel m_filterStrings;
|
||||||
QString m_filterSetting;
|
QString m_filterSetting;
|
||||||
QPointer<QComboBox> m_filterCombo;
|
QPointer<QComboBox> m_filterCombo;
|
||||||
bool m_useRegExp;
|
|
||||||
QCheckBox *m_useRegExpCheckBox;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ QWidget *FindInCurrentFile::createConfigWidget()
|
|||||||
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
||||||
gridLayout->setMargin(0);
|
gridLayout->setMargin(0);
|
||||||
m_configWidget->setLayout(gridLayout);
|
m_configWidget->setLayout(gridLayout);
|
||||||
gridLayout->addWidget(createRegExpWidget(), 0, 1, 1, 2);
|
|
||||||
// just for the layout HACK
|
// just for the layout HACK
|
||||||
QLabel * const filePatternLabel = new QLabel;
|
QLabel * const filePatternLabel = new QLabel;
|
||||||
filePatternLabel->setMinimumWidth(80);
|
filePatternLabel->setMinimumWidth(80);
|
||||||
|
|||||||
@@ -81,10 +81,9 @@ QWidget *FindInFiles::createConfigWidget()
|
|||||||
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
QGridLayout * const gridLayout = new QGridLayout(m_configWidget);
|
||||||
gridLayout->setMargin(0);
|
gridLayout->setMargin(0);
|
||||||
m_configWidget->setLayout(gridLayout);
|
m_configWidget->setLayout(gridLayout);
|
||||||
gridLayout->addWidget(createRegExpWidget(), 0, 1, 1, 2);
|
|
||||||
|
|
||||||
QLabel *dirLabel = new QLabel(tr("&Directory:"));
|
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 = new QComboBox;
|
||||||
m_directory->setEditable(true);
|
m_directory->setEditable(true);
|
||||||
m_directory->setMaxCount(30);
|
m_directory->setMaxCount(30);
|
||||||
@@ -95,9 +94,9 @@ QWidget *FindInFiles::createConfigWidget()
|
|||||||
m_directory->setModel(&m_directoryStrings);
|
m_directory->setModel(&m_directoryStrings);
|
||||||
syncComboWithSettings(m_directory, m_directorySetting);
|
syncComboWithSettings(m_directory, m_directorySetting);
|
||||||
dirLabel->setBuddy(m_directory);
|
dirLabel->setBuddy(m_directory);
|
||||||
gridLayout->addWidget(m_directory, 1, 1);
|
gridLayout->addWidget(m_directory, 0, 1);
|
||||||
QPushButton *browseButton = new QPushButton(tr("&Browse"));
|
QPushButton *browseButton = new QPushButton(tr("&Browse"));
|
||||||
gridLayout->addWidget(browseButton, 1, 2);
|
gridLayout->addWidget(browseButton, 0, 2);
|
||||||
connect(browseButton, SIGNAL(clicked()), this, SLOT(openFileBrowser()));
|
connect(browseButton, SIGNAL(clicked()), this, SLOT(openFileBrowser()));
|
||||||
|
|
||||||
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
QLabel * const filePatternLabel = new QLabel(tr("File &pattern:"));
|
||||||
@@ -106,8 +105,8 @@ QWidget *FindInFiles::createConfigWidget()
|
|||||||
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
filePatternLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
QWidget *patternWidget = createPatternWidget();
|
QWidget *patternWidget = createPatternWidget();
|
||||||
filePatternLabel->setBuddy(patternWidget);
|
filePatternLabel->setBuddy(patternWidget);
|
||||||
gridLayout->addWidget(filePatternLabel, 2, 0);
|
gridLayout->addWidget(filePatternLabel, 1, 0);
|
||||||
gridLayout->addWidget(patternWidget, 2, 1, 1, 2);
|
gridLayout->addWidget(patternWidget, 1, 1, 1, 2);
|
||||||
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
m_configWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
return m_configWidget;
|
return m_configWidget;
|
||||||
|
|||||||
Reference in New Issue
Block a user