Merge pull request #731 from Arthur-Milchior/search_context_has_model

Search_model has context
This commit is contained in:
Damien Elmes 2020-08-14 22:24:07 +10:00 committed by GitHub
commit b15d87296d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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