onModelChange: replacing try by if

This commit is contained in:
Arthur Milchior 2020-04-26 16:53:23 +02:00
parent d427e1028b
commit f2fbf667cd

View file

@ -103,14 +103,11 @@ class AddCards(QDialog):
# copy identical fields # copy identical fields
if fieldName in oldFields: if fieldName in oldFields:
note[fieldName] = oldNote[fieldName] note[fieldName] = oldNote[fieldName]
else: elif n < len(oldNote.model()["flds"]):
# set non-identical fields by field index # set non-identical fields by field index
try: oldFieldName = oldNote.model()["flds"][n]["name"]
oldFieldName = oldNote.model()["flds"][n]["name"] if oldFieldName not in newFields:
if oldFieldName not in newFields: note.fields[n] = oldNote.fields[n]
note.fields[n] = oldNote.fields[n]
except IndexError:
pass
self.removeTempNote(oldNote) self.removeTempNote(oldNote)
self.editor.note = note self.editor.note = note
# When on model change is called, reset is necessarily called. # When on model change is called, reset is necessarily called.