diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2011-09-02 11:51:31 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-09-06 17:05:22 +0200 |
commit | 0594887dea745d3583154a3a2c96a959845ae7f7 (patch) | |
tree | 45a5200a6bac998258730d11756b3f74fc4fe2c3 /src/plugins/cpptools/cppfindreferences.cpp | |
parent | 3fb2e7246e6f1daab2259130bdc362ba54b5055b (diff) | |
download | qt-creator-0594887dea745d3583154a3a2c96a959845ae7f7.tar.gz |
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>
Diffstat (limited to 'src/plugins/cpptools/cppfindreferences.cpp')
-rw-r--r-- | src/plugins/cpptools/cppfindreferences.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 1d8911f7c6..75232ac1ea 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -162,7 +162,7 @@ public: CppFindReferences::CppFindReferences(CppModelManagerInterface *modelManager) : QObject(modelManager), _modelManager(modelManager), - _resultWindow(Find::SearchResultWindow::instance()) + m_currentSearch(0) { m_watcher.setPendingResultsLimit(1); connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); @@ -227,9 +227,9 @@ static void find_helper(QFutureInterface<Usage> &future, void CppFindReferences::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) { - Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly); + m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly); - connect(search, SIGNAL(activated(Find::SearchResultItem)), + connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem))); findAll_helper(symbol, context); @@ -242,14 +242,14 @@ void CppFindReferences::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus: const QString textToReplace = replacement.isEmpty() ? QString::fromUtf8(id->chars(), id->size()) : replacement; - Find::SearchResult *search = _resultWindow->startNewSearch( + m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch( Find::SearchResultWindow::SearchAndReplace, QLatin1String("CppEditor")); - _resultWindow->setTextToReplace(textToReplace); + m_currentSearch->setTextToReplace(textToReplace); - connect(search, SIGNAL(activated(Find::SearchResultItem)), + connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem))); - connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)), + connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>)), SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>))); findAll_helper(symbol, context); @@ -261,7 +261,7 @@ void CppFindReferences::findAll_helper(Symbol *symbol, const LookupContext &cont if (! (symbol && symbol->identifier())) return; - _resultWindow->popup(true); + Find::SearchResultWindow::instance()->popup(true); const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy(); @@ -275,7 +275,7 @@ void CppFindReferences::findAll_helper(Symbol *symbol, const LookupContext &cont Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"), CppTools::Constants::TASK_SEARCH); - connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup())); + connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup())); } void CppFindReferences::onReplaceButtonClicked(const QString &text, @@ -284,7 +284,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text, const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items); if (!fileNames.isEmpty()) { _modelManager->updateSourceFiles(fileNames); - _resultWindow->hide(); + Find::SearchResultWindow::instance()->hide(); } } @@ -292,7 +292,7 @@ void CppFindReferences::displayResults(int first, int last) { 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, @@ -302,7 +302,8 @@ void CppFindReferences::displayResults(int first, int last) void CppFindReferences::searchFinished() { - _resultWindow->finishSearch(); + m_currentSearch->finishSearch(); + m_currentSearch = 0; emit changed(); } @@ -413,11 +414,11 @@ static void findMacroUses_helper(QFutureInterface<Usage> &future, void CppFindReferences::findMacroUses(const Macro ¯o) { - Find::SearchResult *search = _resultWindow->startNewSearch(Find::SearchResultWindow::SearchOnly); + m_currentSearch = Find::SearchResultWindow::instance()->startNewSearch(Find::SearchResultWindow::SearchOnly); - _resultWindow->popup(true); + Find::SearchResultWindow::instance()->popup(true); - connect(search, SIGNAL(activated(Find::SearchResultItem)), + connect(m_currentSearch, SIGNAL(activated(Find::SearchResultItem)), this, SLOT(openEditor(Find::SearchResultItem))); const Snapshot snapshot = _modelManager->snapshot(); @@ -427,7 +428,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o) { // ### FIXME: Encoding? const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1(); - _resultWindow->addResult(macro.fileName(), macro.line(), + m_currentSearch->addResult(macro.fileName(), macro.line(), source.mid(macro.offset(), macro.length()), 0, macro.length()); } @@ -438,7 +439,7 @@ void CppFindReferences::findMacroUses(const Macro ¯o) Core::ProgressManager *progressManager = Core::ICore::instance()->progressManager(); Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"), CppTools::Constants::TASK_SEARCH); - connect(progress, SIGNAL(clicked()), _resultWindow, SLOT(popup())); + connect(progress, SIGNAL(clicked()), Find::SearchResultWindow::instance(), SLOT(popup())); } DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot snapshot) |