forked from qt-creator/qt-creator
CurrentProjectFind: Correct enabled/disable logic
Task-number: QTCREATORBUG-8556 Change-Id: Ic542ac518656e2edf9c3cb17b2960238aa467a9d Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
ea0d68f7d4
commit
4b807bb78a
@@ -116,6 +116,7 @@ signals:
|
|||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible);
|
||||||
void countChanged(int count);
|
void countChanged(int count);
|
||||||
void searchAgainRequested();
|
void searchAgainRequested();
|
||||||
|
void requestEnabledCheck();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SearchResult(Internal::SearchResultWidget *widget);
|
SearchResult(Internal::SearchResultWidget *widget);
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin)
|
|||||||
{
|
{
|
||||||
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
connect(m_plugin, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
||||||
this, SLOT(handleProjectChanged()));
|
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
|
QString CurrentProjectFind::id() const
|
||||||
@@ -101,6 +105,22 @@ void CurrentProjectFind::handleProjectChanged()
|
|||||||
emit enabledChanged(isEnabled());
|
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)
|
void CurrentProjectFind::writeSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
settings->beginGroup(QLatin1String("CurrentProjectFind"));
|
settings->beginGroup(QLatin1String("CurrentProjectFind"));
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ protected:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleProjectChanged();
|
void handleProjectChanged();
|
||||||
|
void recheckEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectExplorerPlugin *m_plugin;
|
ProjectExplorerPlugin *m_plugin;
|
||||||
|
|||||||
@@ -137,7 +137,9 @@ void BaseFileFind::runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
|||||||
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
|
||||||
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
|
||||||
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
|
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);
|
runSearch(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +331,14 @@ void BaseFileFind::searchAgain()
|
|||||||
runSearch(search);
|
runSearch(search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseFileFind::recheckEnabled()
|
||||||
|
{
|
||||||
|
SearchResult *search = qobject_cast<SearchResult *>(sender());
|
||||||
|
if (!search)
|
||||||
|
return;
|
||||||
|
search->setSearchAgainEnabled(isEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
QStringList BaseFileFind::replaceAll(const QString &text,
|
QStringList BaseFileFind::replaceAll(const QString &text,
|
||||||
const QList<Find::SearchResultItem> &items,
|
const QList<Find::SearchResultItem> &items,
|
||||||
bool preserveCase)
|
bool preserveCase)
|
||||||
@@ -380,6 +390,11 @@ QStringList BaseFileFind::replaceAll(const QString &text,
|
|||||||
return changes.keys();
|
return changes.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant BaseFileFind::getAdditionalParameters(SearchResult *search)
|
||||||
|
{
|
||||||
|
return search->userData().value<FileFindParameters>().additionalParameters;
|
||||||
|
}
|
||||||
|
|
||||||
CountingLabel::CountingLabel()
|
CountingLabel::CountingLabel()
|
||||||
{
|
{
|
||||||
setAlignment(Qt::AlignCenter);
|
setAlignment(Qt::AlignCenter);
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ protected:
|
|||||||
virtual Utils::FileIterator *files(const QStringList &nameFilters,
|
virtual Utils::FileIterator *files(const QStringList &nameFilters,
|
||||||
const QVariant &additionalParameters) const = 0;
|
const QVariant &additionalParameters) const = 0;
|
||||||
virtual 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 label() const = 0; // see Find::SearchResultWindow::startNewSearch
|
||||||
virtual QString toolTip() 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
|
// add %1 placeholder where the find flags should be put
|
||||||
@@ -100,6 +101,7 @@ private slots:
|
|||||||
bool preserveCase);
|
bool preserveCase);
|
||||||
void hideHighlightAll(bool visible);
|
void hideHighlightAll(bool visible);
|
||||||
void searchAgain();
|
void searchAgain();
|
||||||
|
void recheckEnabled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
void runNewSearch(const QString &txt, Find::FindFlags findFlags,
|
||||||
|
|||||||
Reference in New Issue
Block a user