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>
Inherits: QObject

Public Types

enum AddMode { AddSortedByContent, AddSortedByPosition, 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 Utils::SearchResultItem &item)
void addResults(const Utils::SearchResultItems &items, Core::SearchResult::AddMode mode)
void finishSearch(bool canceled, const QString &reason = {})
void popup()
void restart()
void setReplaceEnabled(bool enabled)
void setSearchAgainEnabled(bool enabled)
void setTextToReplace(const QString &textToReplace)

Signals

void activated(const Utils::SearchResultItem &item)
void canceled()
void countChanged(int count)
void paused(bool paused)
void replaceButtonClicked(const QString &replaceText, const Utils::SearchResultItems &checkedItems, bool preserveCase)
void searchAgainRequested()
void visibilityChanged(bool visible)

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::AddSortedByContent0The search results are sorted alphabetically.
Core::SearchResult::AddSortedByPosition1The search results are sorted by the search results' reported line numbers.
Core::SearchResult::AddOrdered2The search results are ordered as they are reported.

Member Function Documentation

[signal] void SearchResult::activated(const Utils::SearchResultItem &item)

Indicates that the user activated the search result item by double-clicking it, for example.

[slot] void SearchResult::addResult(const Utils::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 Utils::SearchResultItems &items, Core::SearchResult::AddMode mode)

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

See also addResult().

QWidget *SearchResult::additionalReplaceWidget() const

Returns a UI for a global search and replace action.

See also setAdditionalReplaceWidget().

[signal] void SearchResult::canceled()

This signal is emitted if the user cancels the search.

int SearchResult::count() const

Returns the number of search hits.

[signal] void SearchResult::countChanged(int count)

This signal is emitted when the number of search hits changes to count.

[slot] void SearchResult::finishSearch(bool canceled, const QString &reason = {})

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

[signal] void SearchResult::paused(bool paused)

This signal is emitted when the search status is set to paused.

Opens the Search Results output pane with this search.

[signal] void SearchResult::replaceButtonClicked(const QString &replaceText, const Utils::SearchResultItems &checkedItems, bool preserveCase)

Indicates that the user initiated a text replace by selecting Replace All, for example.

The signal reports the text to use for replacement in replaceText, the list of search result items that were selected by the user in checkedItems, and whether a search and replace should preserve the case of the replaced strings in preserveCase. The handler of this signal should apply the replace only on the selected items.

[slot] void SearchResult::restart()

Removes all search results.

[signal] void SearchResult::searchAgainRequested()

This signal is emitted when the Search Again button is selected.

void SearchResult::setAdditionalReplaceWidget(QWidget *widget)

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

See also additionalReplaceWidget().

[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.

void SearchResult::setSearchAgainSupported(bool supported)

Sets whether the Seach Again button is enabled to supported.

[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().

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().

[signal] void SearchResult::visibilityChanged(bool visible)

This signal is emitted when the visibility of the search results changes to visible.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.