SearchResult Class

class Core::SearchResult

The SearchResult class reports user interaction, such as the activation of a search result item. More...

Header: #include <coreplugin/find/searchresultwindow.h>

Public Types

enum AddMode { AddSorted, AddOrdered }

Public Functions

QWidget *additionalReplaceWidget() const
int count() const
void setAdditionalReplaceWidget(QWidget *widget)
void setSearchAgainSupported(bool supported)
void setUserData(const QVariant &data)
QString textToReplace() const
QVariant userData() const

Public Slots

void addResult(const Core::SearchResultItem &item)
void addResults(const QList<Core::SearchResultItem> &items, Core::SearchResult::AddMode mode)
void finishSearch(bool canceled)
void popup()
void restart()
void setReplaceEnabled(bool enabled)
void setSearchAgainEnabled(bool enabled)
void setTextToReplace(const QString &textToReplace)

Detailed Description

Whenever a new search is initiated via startNewSearch, an instance of this class is returned to provide the initiator with the hooks for handling user interaction.

Member Type Documentation

enum SearchResult::AddMode

This enum type specifies whether the search results should be sorted or ordered:

ConstantValueDescription
Core::SearchResult::AddSorted0The search results are sorted.
Core::SearchResult::AddOrdered1The search results are ordered.

Member Function Documentation

[slot] void SearchResult::addResult(const Core::SearchResultItem &item)

Adds a single result line to the Search Results output pane.

item.mainRange() specifies the region from the beginning of the search term through its length that should be visually marked. item.path(), item.text() are shown on the result line. You can attach arbitrary item.userData() to the search result, which can be used, for example, when reacting to the signals of the search results for your search.

See also addResults().

[slot] void SearchResult::addResults(const QList<Core::SearchResultItem> &items, Core::SearchResult::AddMode mode)

Adds the search result items to the Search Results output pane using mode.

See also addResult().

[slot] void SearchResult::finishSearch(bool canceled)

Notifies the Search Results output pane that the current search has been canceled, and the UI should reflect that.

Opens the Search Results output pane with this search.

[slot] void SearchResult::restart()

Removes all search results.

[slot] void SearchResult::setReplaceEnabled(bool enabled)

Sets whether replace is enabled and can be triggered by the user

[slot] void SearchResult::setSearchAgainEnabled(bool enabled)

Sets whether the Seach Again button is enabled to enabled.

[slot] void SearchResult::setTextToReplace(const QString &textToReplace)

Sets the value in the UI element that allows the user to type the text that should replace text in search results to textToReplace.

See also textToReplace().

QWidget *SearchResult::additionalReplaceWidget() const

Returns a UI for a global search and replace action.

See also setAdditionalReplaceWidget().

int SearchResult::count() const

Returns the number of search hits.

void SearchResult::setAdditionalReplaceWidget(QWidget *widget)

Sets a widget as UI for a global search and replace action.

See also additionalReplaceWidget().

void SearchResult::setSearchAgainSupported(bool supported)

Sets whether the Seach Again button is enabled to supported.

void SearchResult::setUserData(const QVariant &data)

Attaches some random data to this search, that you can use later.

See also userData().

QString SearchResult::textToReplace() const

Returns the text that should replace the text in search results.

See also setTextToReplace().

QVariant SearchResult::userData() const

Returns the data that was attached to this search by calling setUserData().

See also setUserData().