mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Add a way to pass information from browser_will_search to browser_did_search without having it going to the backend (#3945)
* Add a way to pass information from browser_will_search to browser_did_search without having it going to the backend * Allow None for SearchContext.properties * Adding myself in CONTRIBUTORS * Rename SearchContext.properties to SearchContext.addon_metadata * Revert "Adding myself in CONTRIBUTORS" This reverts commita993577279
. * Reapply "Adding myself in CONTRIBUTORS" This reverts commitf3ce51c83d
.
This commit is contained in:
parent
0aaa6383f8
commit
863fe3cd50
4 changed files with 10 additions and 0 deletions
|
@ -222,6 +222,7 @@ ikkz <ylei.mk@gmail.com>
|
|||
derivativeoflog7 <https://github.com/derivativeoflog7>
|
||||
rreemmii-dev <https://github.com/rreemmii-dev>
|
||||
babofitos <https://github.com/babofitos>
|
||||
Jonathan Schoreels <https://github.com/JSchoreels>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ class SearchContext:
|
|||
browser: aqt.browser.Browser
|
||||
order: bool | str | Column = True
|
||||
reverse: bool = False
|
||||
addon_metadata: dict | None = None
|
||||
# if set, provided ids will be used instead of the regular search
|
||||
ids: Sequence[ItemId] | None = None
|
||||
|
||||
|
|
|
@ -269,6 +269,7 @@ class DataModel(QAbstractTableModel):
|
|||
# invalid sort column in config
|
||||
context.order = self.columns["noteCrt"]
|
||||
context.reverse = self._state.sort_backwards
|
||||
context.addon_metadata = {}
|
||||
gui_hooks.browser_will_search(context)
|
||||
if context.ids is None:
|
||||
context.ids = self._state.find_items(
|
||||
|
|
|
@ -549,6 +549,10 @@ hooks = [
|
|||
You can modify context.search to change the text that is sent to the
|
||||
searching backend.
|
||||
|
||||
If you need to pass metadata to the browser_did_search hook, you can
|
||||
do it with context.addon_metadata. For example, to trigger filtering
|
||||
based on a new custom filter.
|
||||
|
||||
If you set context.ids to a list of ids, the regular search will
|
||||
not be performed, and the provided ids will be used instead.
|
||||
|
||||
|
@ -578,6 +582,9 @@ hooks = [
|
|||
backend did not recognize will be returned as an empty string, and can be
|
||||
replaced with custom content.
|
||||
|
||||
You can retrieve metadata passed from browser_will_search with
|
||||
context.addon_metadata (for example to trigger post-processing filtering).
|
||||
|
||||
Columns is a list of string values identifying what each column in the row
|
||||
represents.
|
||||
""",
|
||||
|
|
Loading…
Reference in a new issue