// Starts the search for the user's term. bool FindReplace::FindText( Searchable::Direction direction ) { bool found = false; clearMessage(); if ( !IsValidFindText() ) { return found; } SetCodeViewIfNeeded(); if ( GetLookWhere() == FindReplace::LookWhere_CurrentFile || m_LookWhereCurrentFile) { Searchable *searchable = GetAvailableSearchable(); if ( !searchable ) { return found; } found = searchable->FindNext( GetSearchRegex(), direction ); } else { found = FindInAllFiles( direction ); } if ( found ) { clearMessage(); } else { CannotFindSearchTerm(); } UpdatePreviousFindStrings(); return found; }
bool FindReplace::FindInAllFiles( Searchable::Direction direction ) { Searchable *searchable = 0; bool found = false; if ( IsCurrentFileInHTMLSelection() ) { searchable = GetAvailableSearchable(); if ( searchable ) { found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, false, false); } } if ( !found ) { // TODO: make this handle all types of files Resource *containing_resource = GetNextContainingHTMLResource( direction ); if ( containing_resource ) { // Save if editor or F&R has focus bool has_focus = HasFocus(); // Save selected resources since opening tabs changes selection QList<Resource *>selected_resources = GetHTMLFiles(); m_MainWindow.OpenResource( *containing_resource); while ( !m_MainWindow.GetCurrentContentTab().IsLoadingFinished() ) { // Make sure Qt processes events, signals and calls slots qApp->processEvents(); SleepFunctions::msleep( 100 ); } // Restore selection since opening tabs changes selection if ( GetLookWhere() == FindReplace::LookWhere_SelectedHTMLFiles && !m_SpellCheck) { m_MainWindow.SelectResources(selected_resources); } // Reset focus to F&R if it had it if (has_focus) { SetFocus(); } searchable = GetAvailableSearchable(); if ( searchable ) { found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, true, false ); } } else { if ( searchable ) { // Check the part of the original file above the cursor found = searchable->FindNext( GetSearchRegex(), direction, m_SpellCheck, false, false ); } } } return found; }