Extending Qt Creator Manual | SearchResultWindow

Extending Qt Creator Manual 4.3.1

# SearchResultWindow Class

(Core::SearchResultWindow)

The SearchResultWindow class is the implementation of a commonly shared Search Results output pane. Use it to show search results to a user. More...

Header: | #include <SearchResultWindow>
Inherits: | Core::IOutputPane

- List of all members, including inherited members

## Public Types

enum | PreserveCaseMode { PreserveCaseEnabled, PreserveCaseDisabled }
enum | SearchMode { SearchOnly, SearchAndReplace }

## Public Functions

void | openNewSearchPanel()
void | setTabWidth(int width)
SearchResult * | startNewSearch(const QString &label, const QString &toolTip, const QString &searchTerm, SearchMode searchOrSearchAndReplace = SearchOnly, PreserveCaseMode preserveCaseMode = PreserveCaseEnabled, const QString &cfgGroup = QString())

- 14 public functions inherited from Core::IOutputPane

## Public Slots

virtual void | clearContents()

- 6 public slots inherited from Core::IOutputPane

## Static Public Members

SearchResultWindow * | instance()

### Additional Inherited Members

- 6 signals inherited from Core::IOutputPane

## Detailed Description

The SearchResultWindow class is the implementation of a commonly shared Search Results output pane. Use it to show search results to a user.

Whenever you want to show the user a list of search results, or want to present UI for a global search and replace, use the single instance of this class.

Except for being an implementation of a output pane, the SearchResultWindow has a few functions and one enum that allows other plugins to show their search results and hook into the user actions for selecting an entry and performing a global replace.

Whenever you start a search, call startNewSearch(SearchMode) to initialize the Search Results output pane. The parameter determines if the GUI for replacing should be shown. The function returns a SearchResult object that is your hook into the signals from user interaction for this search. When you produce search results, call addResults or addResult to add them to the Search Results output pane. After the search has finished call finishSearch to inform the Search Results output pane about it.

You will get activated signals via your SearchResult instance when the user selects a search result item, and, if you started the search with the SearchAndReplace option, the replaceButtonClicked signal when the user requests a replace.

## Member Type Documentation

### enum SearchResultWindow::PreserveCaseMode

### enum SearchResultWindow::SearchMode

This enum type specifies whether a search should show the replace UI or not:

Constant | Value | Description
--- | --- | ---
`Core::SearchResultWindow::SearchOnly` | `0` | The search does not support replace.
`Core::SearchResultWindow::SearchAndReplace` | `1` | The search supports replace, so show the UI for it.

## Member Function Documentation

### `[virtual slot]` void SearchResultWindow::clearContents()

Reimplemented from IOutputPane::clearContents().

Clears the current contents of the Search Results output pane.

### `[static]` SearchResultWindow *SearchResultWindow::instance()

Returns the single shared instance of the Search Results output pane.

### void SearchResultWindow::openNewSearchPanel()

### void SearchResultWindow::setTabWidth(int width)

### SearchResult *SearchResultWindow::startNewSearch(const QString &label, const QString &toolTip, const QString &searchTerm, SearchMode searchOrSearchAndReplace = SearchOnly, PreserveCaseMode preserveCaseMode = PreserveCaseEnabled, const QString &cfgGroup = QString())

Tells the Search Results output pane to start a new search.

The label should be a string that shortly describes the type of the search, that is, the search filter and possibly the most relevant search option, followed by a colon ':'. For example: `Project 'myproject':` The searchTerm is shown after the colon. The toolTip should elaborate on the search parameters, like file patterns that are searched and find flags. If cfgGroup is not empty, it will be used for storing the "do not ask again" setting of a "this change cannot be undone" warning (which is implicitly requested by passing a non-empty group). Returns a SearchResult object that is used for signaling user interaction with the results of this search. The search result window owns the returned SearchResult and might delete it any time, even while the search is running (for example, when the user clears the Search Results pane, or when the user opens so many other searches that this search falls out of the history).