diff options
author | Daniel Teske <[email protected]> | 2013-02-12 18:37:14 +0100 |
---|---|---|
committer | David Schulz <[email protected]> | 2013-02-13 13:48:35 +0100 |
commit | 4b807bb78aace31939aa5da12cfb6ab6084a473e (patch) | |
tree | e508612c462d851356d0db64418b820626d1a833 /src/plugins | |
parent | ea0d68f7d46c800319d3926360603c67652f4a8d (diff) |
CurrentProjectFind: Correct enabled/disable logic
Task-number: QTCREATORBUG-8556
Change-Id: Ic542ac518656e2edf9c3cb17b2960238aa467a9d
Reviewed-by: Daniel Teske <[email protected]>
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/find/searchresultwindow.h | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/currentprojectfind.cpp | 20 | ||||
-rw-r--r-- | src/plugins/projectexplorer/currentprojectfind.h | 1 | ||||
-rw-r--r-- | src/plugins/texteditor/basefilefind.cpp | 17 | ||||
-rw-r--r-- | src/plugins/texteditor/basefilefind.h | 2 |
5 files changed, 40 insertions, 1 deletions
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<SearchResult *>(sender()); + if (!search) + return; + QString projectFile = getAdditionalParameters(search).toString(); + QList<Project *> 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<SearchResult *>(sender()); + if (!search) + return; + search->setSearchAgainEnabled(isEnabled()); +} + QStringList BaseFileFind::replaceAll(const QString &text, const QList<Find::SearchResultItem> &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<FileFindParameters>().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, |