forked from qt-creator/qt-creator
Search Dialog: Make canceling possible
Task-Nr: QTCREATORBUG-2243
This commit is contained in:
@@ -131,6 +131,16 @@ bool SymbolsFindFilter::isEnabled() const
|
|||||||
return !m_isRunning && m_enabled;
|
return !m_isRunning && m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SymbolsFindFilter::canCancel() const
|
||||||
|
{
|
||||||
|
return m_isRunning;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SymbolsFindFilter::cancel()
|
||||||
|
{
|
||||||
|
m_watcher.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
Find::FindFlags SymbolsFindFilter::supportedFindFlags() const
|
||||||
{
|
{
|
||||||
return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
|
return Find::FindCaseSensitively | Find::FindRegularExpression | Find::FindWholeWords;
|
||||||
|
@@ -60,6 +60,8 @@ public:
|
|||||||
QString id() const;
|
QString id() const;
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
bool canCancel() const;
|
||||||
|
void cancel();
|
||||||
Find::FindFlags supportedFindFlags() const;
|
Find::FindFlags supportedFindFlags() const;
|
||||||
|
|
||||||
void findAll(const QString &txt, Find::FindFlags findFlags);
|
void findAll(const QString &txt, Find::FindFlags findFlags);
|
||||||
|
@@ -73,7 +73,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Search &for:</string>
|
<string>Search &for:</string>
|
||||||
@@ -86,17 +86,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="searchTerm"/>
|
<widget class="QLineEdit" name="searchTerm"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="closeButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<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,14 +99,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="4" column="1" rowspan="3">
|
||||||
<widget class="QPushButton" name="replaceButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search && Replace</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1" rowspan="3">
|
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
@@ -143,6 +129,27 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="2">
|
||||||
|
<widget class="QPushButton" name="replaceButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search && Replace</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
|
<widget class="QPushButton" name="closeButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Close</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="cancelButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -164,8 +171,6 @@
|
|||||||
<tabstop>filterList</tabstop>
|
<tabstop>filterList</tabstop>
|
||||||
<tabstop>searchTerm</tabstop>
|
<tabstop>searchTerm</tabstop>
|
||||||
<tabstop>searchButton</tabstop>
|
<tabstop>searchButton</tabstop>
|
||||||
<tabstop>closeButton</tabstop>
|
|
||||||
<tabstop>replaceButton</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@@ -52,11 +52,13 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin)
|
|||||||
connect(m_ui.closeButton, SIGNAL(clicked()), this, SLOT(reject()));
|
connect(m_ui.closeButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(search()));
|
connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(search()));
|
||||||
connect(m_ui.replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
|
connect(m_ui.replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
|
||||||
|
connect(m_ui.cancelButton, SIGNAL(clicked()), this, SLOT(cancelSearch()));
|
||||||
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.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());
|
||||||
m_ui.searchTerm->setCompleter(m_findCompleter);
|
m_ui.searchTerm->setCompleter(m_findCompleter);
|
||||||
m_ui.searchTerm->installEventFilter(this);
|
m_ui.searchTerm->installEventFilter(this);
|
||||||
@@ -100,6 +102,7 @@ void FindToolWindow::updateButtonStates()
|
|||||||
m_ui.regExp->setEnabled(filterEnabled
|
m_ui.regExp->setEnabled(filterEnabled
|
||||||
&& (m_currentFilter->supportedFindFlags() & Find::FindRegularExpression));
|
&& (m_currentFilter->supportedFindFlags() & Find::FindRegularExpression));
|
||||||
m_ui.searchTerm->setEnabled(filterEnabled);
|
m_ui.searchTerm->setEnabled(filterEnabled);
|
||||||
|
m_ui.cancelButton->setEnabled(m_currentFilter && m_currentFilter->canCancel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
|
void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
|
||||||
@@ -195,6 +198,12 @@ void FindToolWindow::replace()
|
|||||||
filter->replaceAll(term, m_plugin->findFlags());
|
filter->replaceAll(term, m_plugin->findFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FindToolWindow::cancelSearch()
|
||||||
|
{
|
||||||
|
if (m_currentFilter)
|
||||||
|
m_currentFilter->cancel();
|
||||||
|
}
|
||||||
|
|
||||||
void FindToolWindow::writeSettings()
|
void FindToolWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
@@ -63,6 +63,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void search();
|
void search();
|
||||||
void replace();
|
void replace();
|
||||||
|
void cancelSearch();
|
||||||
void setCurrentFilter(int index);
|
void setCurrentFilter(int index);
|
||||||
void updateButtonStates();
|
void updateButtonStates();
|
||||||
|
|
||||||
|
@@ -52,7 +52,10 @@ public:
|
|||||||
|
|
||||||
virtual QString id() const = 0;
|
virtual QString id() const = 0;
|
||||||
virtual QString displayName() const = 0;
|
virtual QString displayName() const = 0;
|
||||||
|
///
|
||||||
virtual bool isEnabled() const = 0;
|
virtual bool isEnabled() const = 0;
|
||||||
|
virtual bool canCancel() const = 0;
|
||||||
|
virtual void cancel() = 0;
|
||||||
virtual QKeySequence defaultShortcut() const { return QKeySequence(); }
|
virtual QKeySequence defaultShortcut() const { return QKeySequence(); }
|
||||||
virtual bool isReplaceSupported() const { return false; }
|
virtual bool isReplaceSupported() const { return false; }
|
||||||
virtual FindFlags supportedFindFlags() const;
|
virtual FindFlags supportedFindFlags() const;
|
||||||
|
@@ -70,6 +70,16 @@ bool BaseFileFind::isEnabled() const
|
|||||||
return !m_isSearching;
|
return !m_isSearching;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BaseFileFind::canCancel() const
|
||||||
|
{
|
||||||
|
return m_isSearching;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseFileFind::cancel()
|
||||||
|
{
|
||||||
|
m_watcher.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList BaseFileFind::fileNameFilters() const
|
QStringList BaseFileFind::fileNameFilters() const
|
||||||
{
|
{
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
|
@@ -62,6 +62,8 @@ public:
|
|||||||
explicit BaseFileFind(Find::SearchResultWindow *resultWindow);
|
explicit BaseFileFind(Find::SearchResultWindow *resultWindow);
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
bool canCancel() const;
|
||||||
|
void cancel();
|
||||||
bool isReplaceSupported() const { return true; }
|
bool isReplaceSupported() const { return true; }
|
||||||
void findAll(const QString &txt, Find::FindFlags findFlags);
|
void findAll(const QString &txt, Find::FindFlags findFlags);
|
||||||
void replaceAll(const QString &txt, Find::FindFlags findFlags);
|
void replaceAll(const QString &txt, Find::FindFlags findFlags);
|
||||||
|
Reference in New Issue
Block a user