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 { 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 QString &fileName, const QString &lineText, Search::TextRange mainRange, const QVariant &userData = QVariant(), SearchResultColor::Style style = SearchResultColor::Style::Default)
void addResult(const QString &fileName, int lineNumber, const QString &lineText, int searchTermStart, int searchTermLength, const QVariant &userData = QVariant(), SearchResultColor::Style style = SearchResultColor::Style::Default)
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)

Signals

void activated(const Core::SearchResultItem &item)
void cancelled()
void countChanged(int count)
void paused(bool paused)
void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase)
void requestEnabledCheck()
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::AddSorted0The search results are sorted.
Core::SearchResult::AddOrdered1The search results are ordered.

Member Function Documentation

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

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

[slot] void SearchResult::addResult(const QString &fileName, const QString &lineText, Search::TextRange mainRange, const QVariant &userData = QVariant(), SearchResultColor::Style style = SearchResultColor::Style::Default)

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

mainRange specifies the region from the beginning of the search term through its length that should be visually marked. fileName and lineText are shown on the result line. You can attach arbitrary 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::addResult(const QString &fileName, int lineNumber, const QString &lineText, int searchTermStart, int searchTermLength, const QVariant &userData = QVariant(), SearchResultColor::Style style = SearchResultColor::Style::Default)

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

fileName, lineNumber, and lineText are shown on the result line. searchTermStart and searchTermLength specify the region that should be visually marked (string position and length in lineText). You can attach arbitrary 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().

[signal] void SearchResult::cancelled()

This signal is emitted if the user cancels the search.

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

Notifies the Search Results output pane that the current search has been canceled, 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 QList<Core::SearchResultItem> &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.

[signal] void SearchResult::requestEnabledCheck()

This signal is emitted when the enabled status of search results is requested.

[slot] void SearchResult::restart()

Removes all search results.

[signal] void SearchResult::searchAgainRequested()

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

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

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

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

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

© 2020 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.