limit find&replace fields to selected notes

This commit is contained in:
Damien Elmes 2018-11-27 16:35:04 +10:00
parent ea9d2e2d64
commit 5bce218312
2 changed files with 14 additions and 1 deletions

View File

@ -539,6 +539,19 @@ def fieldNames(col, downcase=True):
return list(fields)
return names
def fieldNamesForNotes(col, nids):
downcasedNames = set()
origNames = []
mids = col.db.list("select distinct mid from notes where id in %s" % ids2str(nids))
for mid in mids:
model = col.models.get(mid)
for field in col.models.fieldNames(model):
if field.lower() not in downcasedNames:
downcasedNames.add(field.lower())
origNames.append(field)
return sorted(origNames, key=lambda x: x.lower())
# Find duplicates
##########################################################################
# returns array of ("dupestr", [nids])

View File

@ -1717,7 +1717,7 @@ update cards set usn=?, mod=?, did=? where id in """ + scids,
if not sf:
return
import anki.find
fields = sorted(anki.find.fieldNames(self.col, downcase=False))
fields = anki.find.fieldNamesForNotes(self.mw.col, sf)
d = QDialog(self)
frm = aqt.forms.findreplace.Ui_Dialog()
frm.setupUi(d)