예제 #1
0
void BaseFileFind::runSearch(Find::SearchResult *search)
{
    FileFindParameters parameters = search->userData().value<FileFindParameters>();
    CountingLabel *label = new CountingLabel;
    connect(search, SIGNAL(countChanged(int)), label, SLOT(updateCount(int)));
    Find::SearchResultWindow::instance()->popup(true);
    QFutureWatcher<FileSearchResultList> *watcher = new QFutureWatcher<FileSearchResultList>();
    m_watchers.insert(watcher, search);
    watcher->setPendingResultsLimit(1);
    connect(watcher, SIGNAL(resultReadyAt(int)), this, SLOT(displayResult(int)));
    connect(watcher, SIGNAL(finished()), this, SLOT(searchFinished()));
    if (parameters.flags & Find::FindRegularExpression) {
        watcher->setFuture(Utils::findInFilesRegExp(parameters.text,
            files(parameters.nameFilters, parameters.additionalParameters),
            textDocumentFlagsForFindFlags(parameters.flags),
            ITextEditor::openedTextEditorsContents()));
    } else {
        watcher->setFuture(Utils::findInFiles(parameters.text,
            files(parameters.nameFilters, parameters.additionalParameters),
            textDocumentFlagsForFindFlags(parameters.flags),
            ITextEditor::openedTextEditorsContents()));
    }
    Core::FutureProgress *progress =
        Core::ICore::progressManager()->addTask(watcher->future(),
                                                                        tr("Search"),
                                                                        QLatin1String(Constants::TASK_SEARCH));
    progress->setWidget(label);
    connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
예제 #2
0
void HeaderFilterProgress::findAll(const QString &text,QTextDocument::FindFlags findFlags)
{

    // Fetch a list of all open projects
    QList<ProjectExplorer::Project*> projects = d->projectExplorer()->session()->projects();

    // Make a list of files in each project
    QStringList files;
    Q_FOREACH(ProjectExplorer::Project* project, projects)
        files += project->files(ProjectExplorer::Project::AllFiles);

    // Remove duplicates
    files.removeDuplicates();

    //------------------------------------------------------------
    // Begin searching
    QString includeline = "#include <" + text + '>';
    Find::SearchResult* result = d->searchResultWindow()->startNewSearch();

    d->watcher.setFuture(QFuture<FileSearchResult>());

    //When result gets activated it invokes the openEditor function
    connect(result, SIGNAL(activated(Find::SearchResultItem)),
            this, SLOT(openEditor(Find::SearchResultItem)));

    d->searchResultWindow()->popup(true);

    // Let the watcher monitor the search results
    d->watcher.setFuture(Utils::findInFiles(includeline, files, findFlags));

    //Creates the Progres bar
    Core::FutureProgress* progress =
        Core::ICore::instance()->progressManager()->addTask(d->watcher.future(),
                "MySearch",
                Find::Constants::TASK_SEARCH,
                Core::ProgressManager::KeepOnFinish
                                                           );
    progress->setWidget(createProgressWidget());
    connect(progress, SIGNAL(clicked()), d->searchResultWindow(), SLOT(popup()));
}