Пример #1
0
// Counts the number of occurrences of the user's
// term in the document.
int FindReplace::Count()
{
    clearMessage();

    if ( !IsValidFindText() )
    {
        return 0;
    }

    SetCodeViewIfNeeded( true );

    int count = 0;

    if ( GetLookWhere() == FindReplace::LookWhere_CurrentFile || m_LookWhereCurrentFile)
    {
        Searchable *searchable = GetAvailableSearchable();

        if ( !searchable )
        {
            return 0;
        }

        count = searchable->Count( GetSearchRegex() );
    }
    else
    {
        count = CountInFiles();
    }

    if ( count == 0 )
    {
        CannotFindSearchTerm();
    }
    else
    {
        QString message = tr( "%1 matches found", 0, count );
        ShowMessage( message.arg( count ) );
    }

    UpdatePreviousFindStrings();

    return count;
}