diff --git a/src/plugins/find/searchresultwindow.h b/src/plugins/find/searchresultwindow.h index 57150324762..24bc7db97e3 100644 --- a/src/plugins/find/searchresultwindow.h +++ b/src/plugins/find/searchresultwindow.h @@ -116,6 +116,7 @@ signals: void visibilityChanged(bool visible); void countChanged(int count); void searchAgainRequested(); + void requestEnabledCheck(); private: SearchResult(Internal::SearchResultWidget *widget); diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 7fe51592c5a..3ac9f87d4ed 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -52,6 +52,10 @@ CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin) { connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), this, SLOT(handleProjectChanged())); + connect(m_plugin->session(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), + this, SLOT(handleProjectChanged())); + connect(m_plugin->session(), SIGNAL(projectAdded(ProjectExplorer::Project*)), + this, SLOT(handleProjectChanged())); } QString CurrentProjectFind::id() const @@ -101,6 +105,22 @@ void CurrentProjectFind::handleProjectChanged() emit enabledChanged(isEnabled()); } +void CurrentProjectFind::recheckEnabled() +{ + SearchResult *search = qobject_cast(sender()); + if (!search) + return; + QString projectFile = getAdditionalParameters(search).toString(); + QList allProjects = m_plugin->session()->projects(); + foreach (Project *project, allProjects) { + if (project->document() && projectFile == project->document()->fileName()) { + search->setSearchAgainEnabled(true); + return; + } + } + search->setSearchAgainEnabled(false); +} + void CurrentProjectFind::writeSettings(QSettings *settings) { settings->beginGroup(QLatin1String("CurrentProjectFind")); diff --git a/src/plugins/projectexplorer/currentprojectfind.h b/src/plugins/projectexplorer/currentprojectfind.h index 44d4d65b6b3..28c006018b4 100644 --- a/src/plugins/projectexplorer/currentprojectfind.h +++ b/src/plugins/projectexplorer/currentprojectfind.h @@ -66,6 +66,7 @@ protected: private slots: void handleProjectChanged(); + void recheckEnabled(); private: ProjectExplorerPlugin *m_plugin; diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 0fcc66d9602..6cdf3d1a339 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -137,7 +137,9 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags, connect(search, SIGNAL(cancelled()), this, SLOT(cancel())); connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool))); connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain())); - connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool))); + connect(this, SIGNAL(enabledChanged(bool)), search, SIGNAL(requestEnabledCheck())); + connect(search, SIGNAL(requestEnabledCheck()), this, SLOT(recheckEnabled())); + runSearch(search); } @@ -329,6 +331,14 @@ void BaseFileFind::searchAgain() runSearch(search); } +void BaseFileFind::recheckEnabled() +{ + SearchResult *search = qobject_cast(sender()); + if (!search) + return; + search->setSearchAgainEnabled(isEnabled()); +} + QStringList BaseFileFind::replaceAll(const QString &text, const QList &items, bool preserveCase) @@ -380,6 +390,11 @@ QStringList BaseFileFind::replaceAll(const QString &text, return changes.keys(); } +QVariant BaseFileFind::getAdditionalParameters(SearchResult *search) +{ + return search->userData().value().additionalParameters; +} + CountingLabel::CountingLabel() { setAlignment(Qt::AlignCenter); diff --git a/src/plugins/texteditor/basefilefind.h b/src/plugins/texteditor/basefilefind.h index 5780eb3094c..e1f489b3744 100644 --- a/src/plugins/texteditor/basefilefind.h +++ b/src/plugins/texteditor/basefilefind.h @@ -78,6 +78,7 @@ protected: virtual Utils::FileIterator *files(const QStringList &nameFilters, const QVariant &additionalParameters) const = 0; virtual QVariant additionalParameters() const = 0; + QVariant getAdditionalParameters(Find::SearchResult *search); virtual QString label() const = 0; // see Find::SearchResultWindow::startNewSearch virtual QString toolTip() const = 0; // see Find::SearchResultWindow::startNewSearch, // add %1 placeholder where the find flags should be put @@ -100,6 +101,7 @@ private slots: bool preserveCase); void hideHighlightAll(bool visible); void searchAgain(); + void recheckEnabled(); private: void runNewSearch(const QString &txt, Find::FindFlags findFlags,