Commit f9504cd3 authored by dt's avatar dt
Browse files

Find Dialog: Update en/disabled state on finishing searching

Makes QTCREATORBUG-2243 easier to do.
parent 7c2d3659
...@@ -45,7 +45,8 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin) ...@@ -45,7 +45,8 @@ FindToolWindow::FindToolWindow(FindPlugin *plugin)
: QDialog(Core::ICore::instance()->mainWindow()), : QDialog(Core::ICore::instance()->mainWindow()),
m_plugin(plugin), m_plugin(plugin),
m_findCompleter(new QCompleter(this)), m_findCompleter(new QCompleter(this)),
m_currentFilter(0) m_currentFilter(0),
m_configWidget(0)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
connect(m_ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); connect(m_ui.closeButton, SIGNAL(clicked()), this, SLOT(reject()));
...@@ -84,11 +85,21 @@ bool FindToolWindow::eventFilter(QObject *obj, QEvent *event) ...@@ -84,11 +85,21 @@ bool FindToolWindow::eventFilter(QObject *obj, QEvent *event)
void FindToolWindow::updateButtonStates() void FindToolWindow::updateButtonStates()
{ {
bool enabled = !m_ui.searchTerm->text().isEmpty() bool filterEnabled = m_currentFilter && m_currentFilter->isEnabled();
&& m_currentFilter && m_currentFilter->isEnabled(); bool enabled = !m_ui.searchTerm->text().isEmpty() && filterEnabled;
m_ui.searchButton->setEnabled(enabled); m_ui.searchButton->setEnabled(enabled);
m_ui.replaceButton->setEnabled(m_currentFilter m_ui.replaceButton->setEnabled(m_currentFilter
&& m_currentFilter->isReplaceSupported() && enabled); && m_currentFilter->isReplaceSupported() && enabled);
if (m_configWidget)
m_configWidget->setEnabled(filterEnabled);
m_ui.matchCase->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & Find::FindCaseSensitively));
m_ui.wholeWords->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & Find::FindWholeWords));
m_ui.regExp->setEnabled(filterEnabled
&& (m_currentFilter->supportedFindFlags() & Find::FindRegularExpression));
m_ui.searchTerm->setEnabled(filterEnabled);
} }
void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters) void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
...@@ -135,19 +146,14 @@ void FindToolWindow::setCurrentFilter(int index) ...@@ -135,19 +146,14 @@ void FindToolWindow::setCurrentFilter(int index)
for (int i = 0; i < m_configWidgets.size(); ++i) { for (int i = 0; i < m_configWidgets.size(); ++i) {
QWidget *configWidget = m_configWidgets.at(i); QWidget *configWidget = m_configWidgets.at(i);
if (i == index) { if (i == index) {
m_configWidget = configWidget;
if (m_currentFilter)
disconnect(m_currentFilter, SIGNAL(changed()), this, SLOT(updateButtonStates()));
m_currentFilter = m_filters.at(i); m_currentFilter = m_filters.at(i);
bool enabled = m_currentFilter->isEnabled(); connect(m_currentFilter, SIGNAL(changed()), this, SLOT(updateButtonStates()));
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(); updateButtonStates();
if (configWidget) { if (m_configWidget) {
configWidget->setEnabled(enabled); m_ui.configWidget->layout()->addWidget(m_configWidget);
m_ui.configWidget->layout()->addWidget(configWidget);
} }
} else { } else {
if (configWidget) if (configWidget)
......
...@@ -75,6 +75,7 @@ private: ...@@ -75,6 +75,7 @@ private:
QCompleter *m_findCompleter; QCompleter *m_findCompleter;
QWidgetList m_configWidgets; QWidgetList m_configWidgets;
IFindFilter *m_currentFilter; IFindFilter *m_currentFilter;
QWidget *m_configWidget;
}; };
} // namespace Internal } // namespace Internal
......
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