コード例 #1
0
ファイル: search_thread.cpp プロジェクト: HTshandou/codelite
void SearchThread::DoSearchFiles(ThreadRequest *req)
{
    SearchData *data = static_cast<SearchData*>(req);

    // Get all files
    if ( data->GetRootDirs().IsEmpty() )
        return;

    if ( data->GetFindString().IsEmpty() )
        return;

    StopSearch(false);
    wxArrayString fileList;
    GetFiles(data, fileList);

    wxStopWatch sw;

    // Send startup message to main thread
    if ( m_notifiedWindow || data->GetOwner() ) {
        wxCommandEvent event(wxEVT_SEARCH_THREAD_SEARCHSTARTED, GetId());
        event.SetClientData(new SearchData(*data));
        //set the rquested output tab
        event.SetInt(data->UseNewTab() ? 1 : 0);
        if (data->GetOwner()) {
            ::wxPostEvent(data->GetOwner(), event);
        } else {
            // since we are in if ( m_notifiedWindow || data->GetOwner() ) block...
            ::wxPostEvent(m_notifiedWindow, event);
        }
    }

    for (size_t i=0; i<fileList.Count(); i++) {
        m_summary.SetNumFileScanned((int)i+1);

        // give user chance to cancel the search ...
        if ( TestStopSearch() ) {
            // Send cancel event
            SendEvent(wxEVT_SEARCH_THREAD_SEARCHCANCELED, data->GetOwner());
            StopSearch(false);
            break;
        }
        DoSearchFile(fileList.Item(i), data);
    }
}
コード例 #2
0
ファイル: search_thread.cpp プロジェクト: HTshandou/codelite
void SearchThread::ProcessRequest(ThreadRequest *req)
{
    wxStopWatch sw;
    m_summary = SearchSummary();
    DoSearchFiles(req);
    m_summary.SetElapsedTime(sw.Time());

    SearchData *sd = (SearchData*)req;
    // Send search end event
    SendEvent(wxEVT_SEARCH_THREAD_SEARCHEND, sd->GetOwner());
}