Use backend to set dupe filter
This commit is contained in:
parent
6d9cfb85ab
commit
7b9cc017c4
@ -48,6 +48,8 @@ DeckTreeNode = pb.DeckTreeNode
|
|||||||
StockNoteType = pb.StockNoteType
|
StockNoteType = pb.StockNoteType
|
||||||
FilterToSearchIn = pb.FilterToSearchIn
|
FilterToSearchIn = pb.FilterToSearchIn
|
||||||
NamedFilter = pb.FilterToSearchIn.NamedFilter
|
NamedFilter = pb.FilterToSearchIn.NamedFilter
|
||||||
|
DupeIn = pb.FilterToSearchIn.DupeIn
|
||||||
|
BackendNoteTypeID = pb.NoteTypeID
|
||||||
ConcatSeparator = pb.ConcatenateSearchesIn.Separator
|
ConcatSeparator = pb.ConcatenateSearchesIn.Separator
|
||||||
SyncAuth = pb.SyncAuth
|
SyncAuth = pb.SyncAuth
|
||||||
SyncOutput = pb.SyncCollectionOut
|
SyncOutput = pb.SyncCollectionOut
|
||||||
|
@ -21,8 +21,10 @@ from anki.lang import without_unicode_isolation
|
|||||||
from anki.models import NoteType
|
from anki.models import NoteType
|
||||||
from anki.notes import Note
|
from anki.notes import Note
|
||||||
from anki.rsbackend import (
|
from anki.rsbackend import (
|
||||||
|
BackendNoteTypeID,
|
||||||
ConcatSeparator,
|
ConcatSeparator,
|
||||||
DeckTreeNode,
|
DeckTreeNode,
|
||||||
|
DupeIn,
|
||||||
FilterToSearchIn,
|
FilterToSearchIn,
|
||||||
InvalidInput,
|
InvalidInput,
|
||||||
NamedFilter,
|
NamedFilter,
|
||||||
@ -2016,6 +2018,17 @@ where id in %s"""
|
|||||||
# Edit: finding dupes
|
# Edit: finding dupes
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
# filter called by the editor
|
||||||
|
def search_dupe(self, mid: int, text: str):
|
||||||
|
self.form.searchEdit.lineEdit().setText(
|
||||||
|
self.col.backend.filter_to_search(
|
||||||
|
FilterToSearchIn(
|
||||||
|
dupe=DupeIn(mid=BackendNoteTypeID(ntid=mid), text=text)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.onSearchActivated()
|
||||||
|
|
||||||
def onFindDupes(self):
|
def onFindDupes(self):
|
||||||
self.editor.saveNow(self._onFindDupes)
|
self.editor.saveNow(self._onFindDupes)
|
||||||
|
|
||||||
|
@ -537,12 +537,8 @@ class Editor:
|
|||||||
self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
|
self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
|
||||||
|
|
||||||
def showDupes(self):
|
def showDupes(self):
|
||||||
contents = self.note.fields[0].replace('"', r"\"")
|
|
||||||
browser = aqt.dialogs.open("Browser", self.mw)
|
browser = aqt.dialogs.open("Browser", self.mw)
|
||||||
browser.form.searchEdit.lineEdit().setText(
|
browser.search_dupe(self.note.model()["id"], self.note.fields[0])
|
||||||
'"dupe:%s,%s"' % (self.note.model()["id"], contents)
|
|
||||||
)
|
|
||||||
browser.onSearchActivated()
|
|
||||||
|
|
||||||
def fieldsAreBlank(self, previousNote=None):
|
def fieldsAreBlank(self, previousNote=None):
|
||||||
if not self.note:
|
if not self.note:
|
||||||
|
Loading…
Reference in New Issue
Block a user