Store original object during editor initialisation
This commit is contained in:
parent
715277d9ac
commit
40ca8a2da4
@ -769,10 +769,9 @@ class EditPerson(EditPrimary):
|
|||||||
f.set_child_ref_list(new_order)
|
f.set_child_ref_list(new_order)
|
||||||
|
|
||||||
error = False
|
error = False
|
||||||
if not self.added:
|
if self.original:
|
||||||
original = self.db.get_person_from_handle(self.obj.handle)
|
|
||||||
(female, male, unknown) = _select_gender[self.obj.get_gender()]
|
(female, male, unknown) = _select_gender[self.obj.get_gender()]
|
||||||
if male and original.get_gender() != Person.MALE:
|
if male and self.original.get_gender() != Person.MALE:
|
||||||
for tmp_handle in self.obj.get_family_handle_list():
|
for tmp_handle in self.obj.get_family_handle_list():
|
||||||
temp_family = self.db.get_family_from_handle(tmp_handle)
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
||||||
if self.obj == temp_family.get_mother_handle():
|
if self.obj == temp_family.get_mother_handle():
|
||||||
@ -781,7 +780,7 @@ class EditPerson(EditPrimary):
|
|||||||
else:
|
else:
|
||||||
temp_family.set_mother_handle(None)
|
temp_family.set_mother_handle(None)
|
||||||
temp_family.set_father_handle(self.obj)
|
temp_family.set_father_handle(self.obj)
|
||||||
elif female and original != Person.FEMALE:
|
elif female and self.original != Person.FEMALE:
|
||||||
for tmp_handle in self.obj.get_family_handle_list():
|
for tmp_handle in self.obj.get_family_handle_list():
|
||||||
temp_family = self.db.get_family_from_handle(tmp_handle)
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
||||||
if self.obj == temp_family.get_father_handle():
|
if self.obj == temp_family.get_father_handle():
|
||||||
@ -790,7 +789,7 @@ class EditPerson(EditPrimary):
|
|||||||
else:
|
else:
|
||||||
temp_family.set_father_handle(None)
|
temp_family.set_father_handle(None)
|
||||||
temp_family.set_mother_handle(self.obj)
|
temp_family.set_mother_handle(self.obj)
|
||||||
elif unknown and original.get_gender() != Person.UNKNOWN:
|
elif unknown and self.original.get_gender() != Person.UNKNOWN:
|
||||||
for tmp_handle in self.obj.get_family_handle_list():
|
for tmp_handle in self.obj.get_family_handle_list():
|
||||||
temp_family = self.db.get_family_from_handle(tmp_handle)
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
||||||
if self.obj == temp_family.get_father_handle():
|
if self.obj == temp_family.get_father_handle():
|
||||||
|
@ -78,6 +78,10 @@ class EditPrimary(ManagedWindow, DbGUIElement):
|
|||||||
ManagedWindow.__init__(self, uistate, track, obj)
|
ManagedWindow.__init__(self, uistate, track, obj)
|
||||||
DbGUIElement.__init__(self, self.db)
|
DbGUIElement.__init__(self, self.db)
|
||||||
|
|
||||||
|
self.original = None
|
||||||
|
if self.obj.handle:
|
||||||
|
self.original = self.get_from_handle(self.obj.handle)
|
||||||
|
|
||||||
self._local_init()
|
self._local_init()
|
||||||
self._set_size()
|
self._set_size()
|
||||||
self._create_tabbed_pages()
|
self._create_tabbed_pages()
|
||||||
@ -251,16 +255,11 @@ class EditPrimary(ManagedWindow, DbGUIElement):
|
|||||||
def data_has_changed(self):
|
def data_has_changed(self):
|
||||||
if self.db.readonly:
|
if self.db.readonly:
|
||||||
return False
|
return False
|
||||||
elif self.obj.handle:
|
if self.original:
|
||||||
orig = self.get_from_handle(self.obj.handle)
|
cmp_obj = self.original
|
||||||
if orig:
|
|
||||||
cmp_obj = orig
|
|
||||||
else:
|
|
||||||
cmp_obj = self.empty_object()
|
|
||||||
return cmp_obj.serialize()[1:] != self.obj.serialize()[1:]
|
|
||||||
else:
|
else:
|
||||||
cmp_obj = self.empty_object()
|
cmp_obj = self.empty_object()
|
||||||
return cmp_obj.serialize()[1:] != self.obj.serialize()[1:]
|
return cmp_obj.serialize()[1:] != self.obj.serialize()[1:]
|
||||||
|
|
||||||
def save(self, *obj):
|
def save(self, *obj):
|
||||||
""" Save changes and close. Inheriting classes must implement this
|
""" Save changes and close. Inheriting classes must implement this
|
||||||
|
Loading…
Reference in New Issue
Block a user