Skip to content
Snippets Groups Projects
Commit a841c058 authored by con's avatar con
Browse files

Correctly update the status of the current file find filter.

parent cbe034e0
No related branches found
No related tags found
No related merge requests found
...@@ -43,8 +43,12 @@ using namespace TextEditor::Internal; ...@@ -43,8 +43,12 @@ using namespace TextEditor::Internal;
FindInCurrentFile::FindInCurrentFile(SearchResultWindow *resultWindow) FindInCurrentFile::FindInCurrentFile(SearchResultWindow *resultWindow)
: BaseFileFind(resultWindow), : BaseFileFind(resultWindow),
m_configWidget(0) m_configWidget(0),
m_currentFile(0)
{ {
connect(Core::ICore::instance()->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(handleFileChange(Core::IEditor*)));
handleFileChange(Core::ICore::instance()->editorManager()->currentEditor());
} }
QString FindInCurrentFile::id() const QString FindInCurrentFile::id() const
...@@ -65,19 +69,33 @@ QKeySequence FindInCurrentFile::defaultShortcut() const ...@@ -65,19 +69,33 @@ QKeySequence FindInCurrentFile::defaultShortcut() const
QStringList FindInCurrentFile::files() QStringList FindInCurrentFile::files()
{ {
QStringList fileList; QStringList fileList;
if (Core::IEditor *editor = Core::ICore::instance()->editorManager()->currentEditor()) { if (isEnabled())
if (editor->file() && !editor->file()->fileName().isEmpty()) fileList << m_currentFile->fileName();
fileList << editor->file()->fileName();
}
return fileList; return fileList;
} }
bool FindInCurrentFile::isEnabled() const bool FindInCurrentFile::isEnabled() const
{ {
Core::IEditor *editor = Core::ICore::instance()->editorManager()->currentEditor(); return m_currentFile && !m_currentFile->fileName().isEmpty();
return editor && editor->file() && !editor->file()->fileName().isEmpty(); }
void FindInCurrentFile::handleFileChange(Core::IEditor *editor)
{
if (!editor) {
if (m_currentFile) {
m_currentFile = 0;
emit changed();
}
} else {
Core::IFile *file = editor->file();
if (file != m_currentFile) {
m_currentFile = file;
emit changed();
}
}
} }
QWidget *FindInCurrentFile::createConfigWidget() QWidget *FindInCurrentFile::createConfigWidget()
{ {
if (!m_configWidget) { if (!m_configWidget) {
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "basefilefind.h" #include "basefilefind.h"
#include <coreplugin/ifile.h>
#include <coreplugin/editormanager/ieditor.h>
#include <find/ifindfilter.h> #include <find/ifindfilter.h>
#include <find/searchresultwindow.h> #include <find/searchresultwindow.h>
...@@ -62,8 +64,12 @@ public: ...@@ -62,8 +64,12 @@ public:
protected: protected:
QStringList files(); QStringList files();
private slots:
void handleFileChange(Core::IEditor *editor);
private: private:
QPointer<QWidget> m_configWidget; QPointer<QWidget> m_configWidget;
Core::IFile *m_currentFile;
}; };
} // namespace Internal } // namespace Internal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment