forked from qt-creator/qt-creator
		
	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:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user