mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Use backend nid filter in browser
This commit is contained in:
parent
bc52a54dfc
commit
407358ab68
3 changed files with 8 additions and 3 deletions
|
@ -35,6 +35,7 @@ from anki.rsbackend import ( # pylint: disable=unused-import
|
||||||
FormatTimeSpanContext,
|
FormatTimeSpanContext,
|
||||||
InvalidInput,
|
InvalidInput,
|
||||||
NamedFilter,
|
NamedFilter,
|
||||||
|
NoteIDs,
|
||||||
Progress,
|
Progress,
|
||||||
RustBackend,
|
RustBackend,
|
||||||
pb,
|
pb,
|
||||||
|
@ -503,6 +504,7 @@ class Collection:
|
||||||
forgot_in: Optional[int] = None,
|
forgot_in: Optional[int] = None,
|
||||||
added_in: Optional[int] = None,
|
added_in: Optional[int] = None,
|
||||||
due_in: Optional[int] = None,
|
due_in: Optional[int] = None,
|
||||||
|
nids: Optional[List[int]] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
filters = searches or []
|
filters = searches or []
|
||||||
|
|
||||||
|
@ -528,6 +530,8 @@ class Collection:
|
||||||
append_filter(FilterToSearchIn(added_in=added_in))
|
append_filter(FilterToSearchIn(added_in=added_in))
|
||||||
if due_in:
|
if due_in:
|
||||||
append_filter(FilterToSearchIn(due_in=due_in))
|
append_filter(FilterToSearchIn(due_in=due_in))
|
||||||
|
if nids:
|
||||||
|
append_filter(FilterToSearchIn(nids=NoteIDs(nids=nids)))
|
||||||
if concat_by_or:
|
if concat_by_or:
|
||||||
sep = ConcatSeparator.OR
|
sep = ConcatSeparator.OR
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -50,6 +50,7 @@ StockNoteType = pb.StockNoteType
|
||||||
FilterToSearchIn = pb.FilterToSearchIn
|
FilterToSearchIn = pb.FilterToSearchIn
|
||||||
NamedFilter = pb.FilterToSearchIn.NamedFilter
|
NamedFilter = pb.FilterToSearchIn.NamedFilter
|
||||||
DupeIn = pb.FilterToSearchIn.DupeIn
|
DupeIn = pb.FilterToSearchIn.DupeIn
|
||||||
|
NoteIDs = pb.NoteIDs
|
||||||
BackendNoteTypeID = pb.NoteTypeID
|
BackendNoteTypeID = pb.NoteTypeID
|
||||||
ConcatSeparator = pb.ConcatenateSearchesIn.Separator
|
ConcatSeparator = pb.ConcatenateSearchesIn.Separator
|
||||||
SyncAuth = pb.SyncAuth
|
SyncAuth = pb.SyncAuth
|
||||||
|
|
|
@ -659,7 +659,7 @@ class Browser(QMainWindow):
|
||||||
c = self.card = self.mw.reviewer.card
|
c = self.card = self.mw.reviewer.card
|
||||||
nid = c and c.nid or 0
|
nid = c and c.nid or 0
|
||||||
if nid:
|
if nid:
|
||||||
search = "nid:%d" % nid
|
search = self.col.search_string(nids=[nid])
|
||||||
search = gui_hooks.default_search(search, c)
|
search = gui_hooks.default_search(search, c)
|
||||||
self.model.search(search)
|
self.model.search(search)
|
||||||
self.focusCid(c.id)
|
self.focusCid(c.id)
|
||||||
|
@ -1494,7 +1494,7 @@ where id in %s"""
|
||||||
tv = self.form.tableView
|
tv = self.form.tableView
|
||||||
tv.selectionModel().clear()
|
tv.selectionModel().clear()
|
||||||
|
|
||||||
search = "nid:" + ",".join([str(x) for x in nids])
|
search = self.col.search_string(nids=nids)
|
||||||
self.search_for(search)
|
self.search_for(search)
|
||||||
|
|
||||||
tv.selectAll()
|
tv.selectAll()
|
||||||
|
@ -1705,7 +1705,7 @@ where id in %s"""
|
||||||
t += (
|
t += (
|
||||||
"""<li><a href=# onclick="pycmd('%s');return false;">%s</a>: %s</a>"""
|
"""<li><a href=# onclick="pycmd('%s');return false;">%s</a>: %s</a>"""
|
||||||
% (
|
% (
|
||||||
"nid:" + ",".join(str(id) for id in nids),
|
self.col.search_string(nids=nids).replace('"', '"'),
|
||||||
tr(TR.BROWSING_NOTE_COUNT, count=len(nids)),
|
tr(TR.BROWSING_NOTE_COUNT, count=len(nids)),
|
||||||
html.escape(val),
|
html.escape(val),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue