diff --git a/src/Date.py b/src/Date.py index bcaf0c10a..43b0422dc 100644 --- a/src/Date.py +++ b/src/Date.py @@ -49,11 +49,20 @@ class Date: fmt = re.compile(r"\s*" + from_str + r"\s+(.+)\s+" + to_str + r"\s+(.+)\s*$", re.IGNORECASE) - def __init__(self): - self.start = SingleDate() - self.stop = None - self.range = 0 - self.text = "" + def __init__(self,source=None): + if source: + self.start = SingleDate(source.start) + if source.start: + self.stop = SingleDate(source.stop) + else: + self.stop = None + self.range = source.range + self.text = source.text + else: + self.start = SingleDate() + self.stop = None + self.range = 0 + self.text = "" def get_start_date(self): return self.start @@ -312,11 +321,17 @@ class SingleDate: # # #-------------------------------------------------------------------- - def __init__(self): - self.month = -1 - self.day = -1 - self.year = -1 - self.mode = SingleDate.exact + def __init__(self,source=None): + if source: + self.month = source.month + self.day = source.day + self.year = source.year + self.mode = source.mode + else: + self.month = -1 + self.day = -1 + self.year = -1 + self.mode = SingleDate.exact #-------------------------------------------------------------------- # diff --git a/src/EditPerson.glade b/src/EditPerson.glade index 721790b36..56becd00b 100644 --- a/src/EditPerson.glade +++ b/src/EditPerson.glade @@ -1334,7 +1334,7 @@ True select_row - on_nameList_select_row + on_name_list_select_row Mon, 18 Dec 2000 22:29:26 GMT 2 @@ -1715,7 +1715,7 @@ True select_row - on_eventList_select_row + on_event_select_row Fri, 01 Dec 2000 02:58:20 GMT 4 @@ -1801,7 +1801,7 @@ True clicked - on_eventAddBtn_clicked + on_event_add_clicked eventList Fri, 01 Dec 2000 00:29:52 GMT @@ -1817,7 +1817,7 @@ True clicked - on_eventUpdateBtn_clicked + on_event_update_clicked eventList Fri, 01 Dec 2000 02:58:32 GMT @@ -1833,7 +1833,7 @@ True clicked - on_eventDeleteBtn_clicked + on_event_delete_clicked eventList Thu, 25 Jan 2001 19:57:23 GMT @@ -3217,7 +3217,7 @@ editPerson Thu, 19 Oct 2000 19:25:50 GMT - GNOME_STOCK_BUTTON_CLOSE + GNOME_STOCK_BUTTON_CANCEL GTK_RELIEF_NORMAL diff --git a/src/EditPerson.py b/src/EditPerson.py index 163d3bd1a..a748b5be1 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -131,6 +131,8 @@ class EditPerson: self.name_note = self.get_widget("name_note") self.name_source = self.get_widget("name_source") + self.elist = person.getEventList()[:] + self.selectedIcon = -1 self.top_window.signal_autoconnect({ @@ -140,9 +142,9 @@ class EditPerson: "on_name_source_clicked" : on_name_source_clicked, "on_birth_note_clicked" : on_birth_note_clicked, "on_birth_source_clicked" : on_birth_source_clicked, - "on_eventAddBtn_clicked" : on_event_add_clicked, - "on_eventDeleteBtn_clicked" : on_event_delete_clicked, - "on_nameList_select_row" : on_name_list_select_row, + "on_event_add_clicked" : on_event_add_clicked, + "on_event_delete_clicked" : on_event_delete_clicked, + "on_name_list_select_row" : on_name_list_select_row, "on_browse_clicked": on_browse_clicked, "on_web_list_select_row" : on_web_list_select_row, "on_attr_list_select_row" : on_attr_list_select_row, @@ -159,8 +161,8 @@ class EditPerson: "on_update_address_clicked" : on_update_address_clicked, "on_delete_address_clicked" : on_delete_address_clicked, "on_add_address_clicked" : on_add_address_clicked, - "on_eventUpdateBtn_clicked" : on_event_update_clicked, - "on_eventList_select_row" : on_event_select_row, + "on_event_update_clicked" : on_event_update_clicked, + "on_event_select_row" : on_event_select_row, "on_editperson_switch_page" : on_switch_page, "destroy_passed_object" : utils.destroy_passed_object, "on_makeprimary_clicked" : on_primary_photo_clicked, @@ -422,7 +424,7 @@ class EditPerson: self.event_list.clear() self.event_index = 0 - for event in self.person.getEventList(): + for event in self.elist: attr = "" if Config.show_detail: if event.getNote() != "": @@ -486,6 +488,13 @@ class EditPerson: def load_photo(self,photo): self.get_widget("personPix").load_file(photo) + #------------------------------------------------------------------------- + # + # + # + #------------------------------------------------------------------------- + def update_events(self): + self.person.setEventList(self.elist) #------------------------------------------------------------------------- # @@ -819,14 +828,13 @@ def on_event_delete_clicked(obj): if row < 0: return - list = edit_person_obj.person.getEventList() - del list[row] + del edit_person_obj.elist[row] - if row > len(list)-1: + if row > len(edit_person_obj.elist)-1: obj.set_data(INDEX,row-1) edit_person_obj.redraw_event_list() - utils.modified() + edit_person_obj.events_changed = 1 #------------------------------------------------------------------------- # @@ -945,25 +953,28 @@ def on_primary_photo_clicked(obj): # #------------------------------------------------------------------------- def update_event(event,name,date,place,desc,note): + changed = 0 if event.getPlace() != place: event.setPlace(place) - utils.modified() + changed = 1 if event.getName() != const.save_pevent(name): event.setName(const.save_pevent(name)) - utils.modified() + changed = 1 if event.getDescription() != desc: event.setDescription(desc) - utils.modified() + changed = 1 if event.getNote() != note: event.setNote(note) - utils.modified() + changed = 1 if event.getDate() != date: event.setDate(date) - utils.modified() + changed = 1 + + return changed #------------------------------------------------------------------------- # @@ -1011,7 +1022,7 @@ def on_apply_person_clicked(obj): edit_person_obj = obj.get_data(EDITPERSON) person = edit_person_obj.person - surname = edit_person_obj.surname.get_text() + surname = edit_person_obj.surname_field.get_text() suffix = edit_person_obj.suffix.get_text() given = edit_person_obj.given.get_text() nick = edit_person_obj.nick.get_text() @@ -1103,8 +1114,11 @@ def on_apply_person_clicked(obj): person.setNote(text) utils.modified() + edit_person_obj.update_events() + if edit_person_obj.events_changed: + utils.modified() + utils.destroy_passed_object(obj) - edit_person_obj.callback(edit_person_obj) #------------------------------------------------------------------------- @@ -1470,9 +1484,11 @@ def on_event_edit_apply_clicked(obj): if event == None: event = Event() - ee.parent.person.addEvent(event) + ee.parent.elist.append(event) + + if update_event(event,ename,edate,eplace,edesc,enote): + ee.parent.events_changed = 1 - update_event(event,ename,edate,eplace,edesc,enote) ee.parent.redraw_event_list() #------------------------------------------------------------------------- diff --git a/src/RelLib.py b/src/RelLib.py index 5d0a1400e..ba5703e67 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -399,6 +399,9 @@ class Person: def getEventList(self) : return self.EventList + def setEventList(self,list) : + self.EventList = list + def addFamily(self,family) : self.FamilyList.append(family) @@ -490,13 +493,27 @@ class Person: #------------------------------------------------------------------------- class Event: - def __init__(self): - self.place = "" - self.date = Date() - self.description = "" - self.name = "" - self.source_ref = None - self.note = None + def __init__(self,source=None): + if source: + self.place = source.place + self.date = Date(source.date) + self.description = source.description + self.name = source.name + if source.source_ref: + self.source_ref = SourceRef(source.source_ref) + else: + self.source_ref = None + if source.note: + self.note = Note(source.note) + else: + self.source_ref = None + else: + self.place = "" + self.date = Date() + self.description = "" + self.name = "" + self.source_ref = None + self.note = None def set(self,name,date,place,description): self.name = name @@ -754,12 +771,19 @@ class Source: # #------------------------------------------------------------------------- class SourceRef: - def __init__(self): - self.ref = None - self.page = "" - self.date = Date() - self.comments = Note() - self.text = "" + def __init__(self,source=None): + if source: + self.ref = source.ref + self.page = source.page + self.date = Date(source.date) + self.comments = Note(source.comments.get()) + self.text = source.text + else: + self.ref = None + self.page = "" + self.date = Date() + self.comments = Note() + self.text = "" def setBase(self,ref): self.ref = ref