Merge pull request #584 from Arthur-Milchior/onModelchangeUsed
On modelchange used
This commit is contained in:
commit
9502fe790f
@ -100,20 +100,18 @@ class AddCards(QDialog):
|
|||||||
newFields = list(note.keys())
|
newFields = list(note.keys())
|
||||||
for n, f in enumerate(note.model()["flds"]):
|
for n, f in enumerate(note.model()["flds"]):
|
||||||
fieldName = f["name"]
|
fieldName = f["name"]
|
||||||
try:
|
|
||||||
oldFieldName = oldNote.model()["flds"][n]["name"]
|
|
||||||
except IndexError:
|
|
||||||
oldFieldName = None
|
|
||||||
# copy identical fields
|
# copy identical fields
|
||||||
if fieldName in oldFields:
|
if fieldName in oldFields:
|
||||||
note[fieldName] = oldNote[fieldName]
|
note[fieldName] = oldNote[fieldName]
|
||||||
# set non-identical fields by field index
|
elif n < len(oldNote.model()["flds"]):
|
||||||
elif oldFieldName and oldFieldName not in newFields:
|
# set non-identical fields by field index
|
||||||
try:
|
oldFieldName = oldNote.model()["flds"][n]["name"]
|
||||||
|
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
|
||||||
|
# When on model change is called, reset is necessarily called.
|
||||||
|
# Reset load note, so it is not required to load it here.
|
||||||
|
|
||||||
def onReset(self, model: None = None, keep: bool = False) -> None:
|
def onReset(self, model: None = None, keep: bool = False) -> None:
|
||||||
oldNote = self.editor.note
|
oldNote = self.editor.note
|
||||||
|
Loading…
Reference in New Issue
Block a user