Move and cleanup search specific API to SearchResult class

Change-Id: I7e64701e8833ad38b9ac01d316bd00302602a390
Rubber-stamped-by: Daniel Teske
Reviewed-on: http://codereview.qt.nokia.com/4179
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Eike Ziller
2011-09-02 11:51:31 +02:00
parent 3fb2e7246e
commit 0594887dea
24 changed files with 216 additions and 143 deletions

View File

@@ -774,8 +774,8 @@ public:
} // end of anonymous namespace
FindReferences::FindReferences(QObject *parent)
: QObject(parent)
, _resultWindow(Find::SearchResultWindow::instance())
: QObject(parent),
m_currentSearch(0)
{
m_watcher.setPendingResultsLimit(1);
connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int)));
@@ -904,31 +904,30 @@ void FindReferences::displayResults(int first, int last)
Usage dummy = m_watcher.future().resultAt(0);
QString replacement = dummy.path;
Find::SearchResult *search;
if (replacement.isEmpty()) {
search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly);
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly);
} else {
search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
_resultWindow->setTextToReplace(replacement);
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchAndReplace);
m_currentSearch->setTextToReplace(replacement);
connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>)));
}
connect(search, SIGNAL(activated(Find::SearchResultItem)),
connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
_resultWindow->popup(true);
Find::SearchResultWindow::instance()->popup(true);
Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager();
Core::FutureProgress *progress = progressManager->addTask(
m_watcher.future(), tr("Searching"),
QmlJSEditor::Constants::TASK_SEARCH);
connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup()));
connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup()));
++first;
}
for (int index = first; index != last; ++index) {
Usage result = m_watcher.future().resultAt(index);
_resultWindow->addResult(result.path,
m_currentSearch->addResult(result.path,
result.line,
result.lineText,
result.col,
@@ -938,7 +937,8 @@ void FindReferences::displayResults(int first, int last)
void FindReferences::searchFinished()
{
_resultWindow->finishSearch();
m_currentSearch->finishSearch();
m_currentSearch = 0;
emit changed();
}
@@ -973,5 +973,5 @@ void FindReferences::onReplaceButtonClicked(const QString &text, const QList<Fin
if (!changedUnsavedEditors.isEmpty())
QmlJS::ModelManagerInterface::instance()->updateSourceFiles(changedUnsavedEditors, false);
_resultWindow->hide();
Find::SearchResultWindow::instance()->hide();
}