forked from qt-creator/qt-creator
Find dialog doesn't remember last selected scope.
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
This commit is contained in:
@@ -40,14 +40,15 @@ using namespace Find::Internal;
|
|||||||
FindToolWindow::FindToolWindow(FindPlugin *plugin)
|
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_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()));
|
||||||
connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(accept()));
|
connect(m_ui.searchButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
connect(m_ui.matchCase, SIGNAL(toggled(bool)), m_plugin, SLOT(setCaseSensitive(bool)));
|
connect(m_ui.matchCase, SIGNAL(toggled(bool)), m_plugin, SLOT(setCaseSensitive(bool)));
|
||||||
connect(m_ui.wholeWords, SIGNAL(toggled(bool)), m_plugin, SLOT(setWholeWord(bool)));
|
connect(m_ui.wholeWords, SIGNAL(toggled(bool)), m_plugin, SLOT(setWholeWord(bool)));
|
||||||
connect(m_ui.filterList, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentFilter(int)));
|
connect(m_ui.filterList, SIGNAL(activated(int)), this, SLOT(setCurrentFilter(int)));
|
||||||
connect(this, SIGNAL(accepted()), this, SLOT(search()));
|
connect(this, SIGNAL(accepted()), this, SLOT(search()));
|
||||||
m_findCompleter->setModel(m_plugin->findCompletionModel());
|
m_findCompleter->setModel(m_plugin->findCompletionModel());
|
||||||
m_ui.searchTerm->setCompleter(m_findCompleter);
|
m_ui.searchTerm->setCompleter(m_findCompleter);
|
||||||
@@ -74,6 +75,8 @@ void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters)
|
|||||||
m_configWidgets.append(filter->createConfigWidget());
|
m_configWidgets.append(filter->createConfigWidget());
|
||||||
}
|
}
|
||||||
m_ui.filterList->addItems(names);
|
m_ui.filterList->addItems(names);
|
||||||
|
if (m_filters.size() > 0)
|
||||||
|
setCurrentFilter(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolWindow::setFindText(const QString &text)
|
void FindToolWindow::setFindText(const QString &text)
|
||||||
@@ -83,9 +86,11 @@ void FindToolWindow::setFindText(const QString &text)
|
|||||||
|
|
||||||
void FindToolWindow::open(IFindFilter *filter)
|
void FindToolWindow::open(IFindFilter *filter)
|
||||||
{
|
{
|
||||||
|
if (!filter)
|
||||||
|
filter = m_currentFilter;
|
||||||
int index = m_filters.indexOf(filter);
|
int index = m_filters.indexOf(filter);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
m_ui.filterList->setCurrentIndex(index);
|
setCurrentFilter(index);
|
||||||
}
|
}
|
||||||
m_ui.matchCase->setChecked(m_plugin->findFlags() & QTextDocument::FindCaseSensitively);
|
m_ui.matchCase->setChecked(m_plugin->findFlags() & QTextDocument::FindCaseSensitively);
|
||||||
m_ui.wholeWords->setChecked(m_plugin->findFlags() & QTextDocument::FindWholeWords);
|
m_ui.wholeWords->setChecked(m_plugin->findFlags() & QTextDocument::FindWholeWords);
|
||||||
@@ -96,6 +101,7 @@ void FindToolWindow::open(IFindFilter *filter)
|
|||||||
|
|
||||||
void FindToolWindow::setCurrentFilter(int index)
|
void FindToolWindow::setCurrentFilter(int index)
|
||||||
{
|
{
|
||||||
|
m_ui.filterList->setCurrentIndex(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 (!configWidget)
|
if (!configWidget)
|
||||||
@@ -112,6 +118,7 @@ void FindToolWindow::setCurrentFilter(int index)
|
|||||||
configWidget->setParent(0);
|
configWidget->setParent(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_currentFilter = m_filters.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindToolWindow::search()
|
void FindToolWindow::search()
|
||||||
@@ -129,6 +136,7 @@ void FindToolWindow::writeSettings()
|
|||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup("Find");
|
settings->beginGroup("Find");
|
||||||
|
settings->setValue("CurrentFilter", m_currentFilter->id());
|
||||||
foreach (IFindFilter *filter, m_filters)
|
foreach (IFindFilter *filter, m_filters)
|
||||||
filter->writeSettings(settings);
|
filter->writeSettings(settings);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
@@ -138,7 +146,13 @@ void FindToolWindow::readSettings()
|
|||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup("Find");
|
settings->beginGroup("Find");
|
||||||
foreach (IFindFilter *filter, m_filters)
|
const QString currentFilter = settings->value("CurrentFilter").toString();
|
||||||
|
for (int i = 0; i < m_filters.size(); ++i) {
|
||||||
|
IFindFilter *filter = m_filters.at(i);
|
||||||
filter->readSettings(settings);
|
filter->readSettings(settings);
|
||||||
|
if (filter->id() == currentFilter) {
|
||||||
|
setCurrentFilter(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ private:
|
|||||||
QList<IFindFilter *> m_filters;
|
QList<IFindFilter *> m_filters;
|
||||||
QCompleter *m_findCompleter;
|
QCompleter *m_findCompleter;
|
||||||
QList<QWidget *> m_configWidgets;
|
QList<QWidget *> m_configWidgets;
|
||||||
|
IFindFilter *m_currentFilter;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public:
|
|||||||
|
|
||||||
virtual ~IFindFilter() {}
|
virtual ~IFindFilter() {}
|
||||||
|
|
||||||
|
virtual QString id() const = 0;
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
virtual bool isEnabled() const = 0;
|
virtual bool isEnabled() const = 0;
|
||||||
virtual QKeySequence defaultShortcut() const = 0;
|
virtual QKeySequence defaultShortcut() const = 0;
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ AllProjectsFind::AllProjectsFind(ProjectExplorerPlugin *plugin, SearchResultWind
|
|||||||
connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed()));
|
connect(m_plugin, SIGNAL(fileListChanged()), this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AllProjectsFind::id() const
|
||||||
|
{
|
||||||
|
return "All Projects";
|
||||||
|
}
|
||||||
|
|
||||||
QString AllProjectsFind::name() const
|
QString AllProjectsFind::name() const
|
||||||
{
|
{
|
||||||
return tr("All Projects");
|
return tr("All Projects");
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class AllProjectsFind : public TextEditor::BaseFileFind
|
|||||||
public:
|
public:
|
||||||
AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
AllProjectsFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ CurrentProjectFind::CurrentProjectFind(ProjectExplorerPlugin *plugin, SearchResu
|
|||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CurrentProjectFind::id() const
|
||||||
|
{
|
||||||
|
return "Current Project";
|
||||||
|
}
|
||||||
|
|
||||||
QString CurrentProjectFind::name() const
|
QString CurrentProjectFind::name() const
|
||||||
{
|
{
|
||||||
return tr("Current Project");
|
return tr("Current Project");
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class CurrentProjectFind : public TextEditor::BaseFileFind
|
|||||||
public:
|
public:
|
||||||
CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
CurrentProjectFind(ProjectExplorerPlugin *plugin, Find::SearchResultWindow *resultWindow);
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ FindInFiles::FindInFiles(SearchResultWindow *resultWindow)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FindInFiles::id() const
|
||||||
|
{
|
||||||
|
return "Files on Disk";
|
||||||
|
}
|
||||||
|
|
||||||
QString FindInFiles::name() const
|
QString FindInFiles::name() const
|
||||||
{
|
{
|
||||||
return tr("Files on Disk");
|
return tr("Files on Disk");
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class FindInFiles : public BaseFileFind
|
|||||||
public:
|
public:
|
||||||
explicit FindInFiles(Find::SearchResultWindow *resultWindow);
|
explicit FindInFiles(Find::SearchResultWindow *resultWindow);
|
||||||
|
|
||||||
|
QString id() const;
|
||||||
QString name() const;
|
QString name() const;
|
||||||
QKeySequence defaultShortcut() const;
|
QKeySequence defaultShortcut() const;
|
||||||
void findAll(const QString &txt, QTextDocument::FindFlags findFlags);
|
void findAll(const QString &txt, QTextDocument::FindFlags findFlags);
|
||||||
|
|||||||
Reference in New Issue
Block a user