Пример #1
0
// Replaces the user's search term with the user's
// replacement text if a match is selected. If it's not,
// calls Find in the direction specified so it becomes selected.
bool FindReplace::ReplaceText( Searchable::Direction direction )
{
    bool found = false;

    clearMessage();

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

    SetCodeViewIfNeeded( true );

    Searchable *searchable = GetAvailableSearchable();

    if ( searchable )
    {
        // If we have the matching text selected, replace it
        // This will not do anything if matching text is not selected.
        found = searchable->ReplaceSelected( GetSearchRegex(), ui.cbReplace->lineEdit()->text(), direction );
    }

    if ( direction == Searchable::Direction_Up)
    {
        if (FindPrevious()) {
            found = true;
        };
    }
    else
    {
        if (FindNext()) {
            found = true;
        }
    }

    UpdatePreviousFindStrings();
    UpdatePreviousReplaceStrings();

    return found;
}