Core::SearchResult Class
class Core::SearchResultSearchResult 类用于报告用户交互,例如搜索结果项的激活。更多内容...
| Header: | #include <coreplugin/find/searchresultwindow.h> |
| Inherits: | QObject |
公共类型
| enum | AddMode { AddSortedByContent, AddSortedByPosition, AddOrdered } |
公共函数
| 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 |
公共槽
| 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) |
信号
| 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) |
成员类型文档
enum SearchResult::AddMode
此枚举类型用于指定搜索结果是否应进行排序:
| 常量 | 值 | 描述 |
|---|---|---|
Core::SearchResult::AddSortedByContent | 0 | 搜索结果按字母顺序排序。 |
Core::SearchResult::AddSortedByPosition | 1 | 搜索结果按其报告的行号进行排序。 |
Core::SearchResult::AddOrdered | 2 | 搜索结果按其报告的顺序排列。 |
成员函数文档
[signal] void SearchResult::activated(const Utils::SearchResultItem &item)
表示用户通过双击等方式激活了搜索结果item 。
[slot] void SearchResult::addResult(const Utils::SearchResultItem &item)
向Search Results 的输出窗格中添加一条结果行。
item.mainRange() 指定了应进行视觉标记的区域,该区域从搜索词的开头开始,直至其长度结束。item.path()、item.text() 会显示在结果行上。您可以将任意item.userData() 附加到搜索结果上,例如,当您需要响应搜索结果的信号时,即可使用该功能。
另请参阅 addResults()。
[slot] void SearchResult::addResults(const Utils::SearchResultItems &items, Core::SearchResult::AddMode mode)
使用mode 将搜索结果items 添加到Search Results 的输出窗格中。
另请参阅 addResult()。
QWidget *SearchResult::additionalReplaceWidget() const
返回用于全局搜索和替换操作的用户界面。
另请参阅 setAdditionalReplaceWidget()。
[signal] void SearchResult::canceled()
如果用户取消搜索,则会发出此信号。
int SearchResult::count() const
返回搜索结果的条数。
[signal] void SearchResult::countChanged(int count)
当搜索命中数变为count 时,会发出此信号。
[slot] void SearchResult::finishSearch(bool canceled, const QString &reason = {})
通知Search Results 输出窗格,当前搜索针对指定的reason 已canceled ,且用户界面应反映这一状态。
[signal] void SearchResult::paused(bool paused)
当搜索状态设置为paused 时,会发出此信号。
[slot] void SearchResult::popup()
使用此搜索条件打开Search Results 的输出窗格。
[signal] void SearchResult::replaceButtonClicked(const QString &replaceText, const Utils::SearchResultItems &checkedItems, bool preserveCase)
表示用户通过选择Replace All 等方式,发起了一次文本替换操作。
该信号报告了用于替换的文本(位于replaceText 中)、用户在checkedItems 中选中的搜索结果项列表,以及搜索和替换操作是否应保留被替换字符串的大小写(位于preserveCase 中)。该信号的处理程序应仅对选中的项应用替换操作。
[slot] void SearchResult::restart()
清除所有搜索结果。
[signal] void SearchResult::searchAgainRequested()
当选中“Search Again ”按钮时,会发出此信号。
void SearchResult::setAdditionalReplaceWidget(QWidget *widget)
将widget 设置为全局查找和替换操作的用户界面。
另请参阅 additionalReplaceWidget()。
[slot] void SearchResult::setReplaceEnabled(bool enabled)
设置“replace”是否为enabled ,并可由用户触发。
[slot] void SearchResult::setSearchAgainEnabled(bool enabled)
将“Seach Again ”按钮的启用状态设置为“enabled ”。
void SearchResult::setSearchAgainSupported(bool supported)
将“Seach Again ”按钮的启用状态设置为“supported ”。
[slot] void SearchResult::setTextToReplace(const QString &textToReplace)
将用户界面元素中的值设置为textToReplace ,该元素允许用户输入用于替换搜索结果中文本的文本。
另请参阅 textToReplace()。
void SearchResult::setUserData(const QVariant &data)
将一些随机的data 附加到此搜索中,供您日后使用。
另请参阅 userData()。
QString SearchResult::textToReplace() const
返回应替换搜索结果中文字内容的文本。
另请参阅 setTextToReplace()。
QVariant SearchResult::userData() const
返回通过调用setUserData() 附加到此搜索上的数据。
另请参阅 setUserData()。
[signal] void SearchResult::visibilityChanged(bool visible)
当搜索结果的可见性变为“visible ”时,会触发此信号。
Copyright © The Qt Company Ltd. and other contributors. 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.