single try in onModelChange

This commit is contained in:
Arthur Milchior 2020-04-26 16:52:35 +02:00
parent 936bb31997
commit d427e1028b

View file

@ -100,16 +100,14 @@ class AddCards(QDialog):
newFields = list(note.keys())
for n, f in enumerate(note.model()["flds"]):
fieldName = f["name"]
try:
oldFieldName = oldNote.model()["flds"][n]["name"]
except IndexError:
oldFieldName = None
# copy identical fields
if fieldName in oldFields:
note[fieldName] = oldNote[fieldName]
else:
# set non-identical fields by field index
elif oldFieldName and oldFieldName not in newFields:
try:
oldFieldName = oldNote.model()["flds"][n]["name"]
if oldFieldName not in newFields:
note.fields[n] = oldNote.fields[n]
except IndexError:
pass