mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Search_model has context
I have an add-on which allow to open multiple windows. So would like to know which browser has done the search. This would allow me to have browser with various setting. In particular, I've an add-on which allow to show a single line by note, and I would like for some browser to have this feature on and for some other to have this feature off.
This commit is contained in:
parent
c3f8f7dd94
commit
ae078d4fd0
1 changed files with 2 additions and 1 deletions
|
@ -70,6 +70,7 @@ class FindDupesDialog:
|
||||||
@dataclass
|
@dataclass
|
||||||
class SearchContext:
|
class SearchContext:
|
||||||
search: str
|
search: str
|
||||||
|
browser: Browser
|
||||||
order: Union[bool, str] = True
|
order: Union[bool, str] = True
|
||||||
# if set, provided card ids will be used instead of the regular search
|
# if set, provided card ids will be used instead of the regular search
|
||||||
card_ids: Optional[Sequence[int]] = None
|
card_ids: Optional[Sequence[int]] = None
|
||||||
|
@ -181,7 +182,7 @@ class DataModel(QAbstractTableModel):
|
||||||
self.cards = []
|
self.cards = []
|
||||||
error_message: Optional[str] = None
|
error_message: Optional[str] = None
|
||||||
try:
|
try:
|
||||||
ctx = SearchContext(search=txt)
|
ctx = SearchContext(search=txt, browser=self.browser)
|
||||||
gui_hooks.browser_will_search(ctx)
|
gui_hooks.browser_will_search(ctx)
|
||||||
if ctx.card_ids is None:
|
if ctx.card_ids is None:
|
||||||
ctx.card_ids = self.col.find_cards(ctx.search, order=ctx.order)
|
ctx.card_ids = self.col.find_cards(ctx.search, order=ctx.order)
|
||||||
|
|
Loading…
Reference in a new issue