* src/EditPerson.py: Start event_ref integration
* src/EventEdit.py: Start event_ref integration * src/ListModel.py: Start event_ref integration * src/PersonModel.py: Start event_ref integration * src/ListBox.py: Start event_ref integration svn: r4754
This commit is contained in:
parent
35ffafc48c
commit
778b584916
@ -1,3 +1,10 @@
|
||||
2005-06-01 Don Allingham <don@gramps-project.org>
|
||||
* src/EditPerson.py: Start event_ref integration
|
||||
* src/EventEdit.py: Start event_ref integration
|
||||
* src/ListModel.py: Start event_ref integration
|
||||
* src/PersonModel.py: Start event_ref integration
|
||||
* src/ListBox.py: Start event_ref integration
|
||||
|
||||
2005-06-01 Alex Roitman <shura@gramps-project.org>
|
||||
* src/AutoComp.py (StandardCustomSelector): Provide an option to
|
||||
use an existing ComboBoxEntry instance; add set_values method.
|
||||
|
@ -853,16 +853,16 @@ class EditPerson:
|
||||
self.person.set_birth_ref(None)
|
||||
self.person.set_death_ref(None)
|
||||
eref_list = self.event_box.data[:]
|
||||
for event_ref in eref_list:
|
||||
if event_ref and event_ref.ref:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_name() == "Birth":
|
||||
self.person.set_birth_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
if event.get_name() == "Death":
|
||||
self.person.set_death_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
eref_list = [event_ref for event_ref in self.event_box.data]
|
||||
print eref_list
|
||||
for (event_ref,event) in eref_list:
|
||||
print event.handle
|
||||
if event.get_type()[0] == RelLib.Event.BIRTH:
|
||||
self.person.set_birth_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
if event.get_type()[0] == RelLib.Event.DEATH:
|
||||
self.person.set_death_ref(event_ref)
|
||||
self.event_box.data.remove(event_ref)
|
||||
eref_list = [event_ref for (event_ref,event) in self.event_box.data]
|
||||
self.person.set_event_ref_list(eref_list)
|
||||
|
||||
def on_apply_person_clicked(self,obj):
|
||||
@ -1036,7 +1036,7 @@ class EditPerson:
|
||||
self.db.commit_person(self.person, trans)
|
||||
n = self.person.get_primary_name().get_regular_name()
|
||||
|
||||
for event in self.event_box.get_changed_objects():
|
||||
for (event_ref,event) in self.event_box.get_changed_objects():
|
||||
self.db.commit_event(event,trans)
|
||||
|
||||
self.db.transaction_commit(trans,_("Edit Person (%s)") % n)
|
||||
|
@ -178,7 +178,10 @@ class EventEditor:
|
||||
self.witnesslist, self, self.top, self.window, self.wlist,
|
||||
add_witness, edit_witness, del_witness)
|
||||
|
||||
AutoComp.fill_combo(self.event_menu,self.elist)
|
||||
#AutoComp.fill_combo(self.event_menu,self.elist)
|
||||
|
||||
self.eventmapper = AutoComp.StandardCustomSelector(
|
||||
Utils.personal_events, self.event_menu, RelLib.Event.CUSTOM)
|
||||
AutoComp.fill_entry(self.place_field,self.pmap.keys())
|
||||
|
||||
if event != None:
|
||||
@ -219,6 +222,7 @@ class EventEditor:
|
||||
self.window)
|
||||
if not event:
|
||||
event = RelLib.Event()
|
||||
event.set_handle(Utils.create_id())
|
||||
self.icon_list = self.top.get_widget("iconlist")
|
||||
self.gallery = ImageSelect.Gallery(event, self.db.commit_event,
|
||||
self.path, self.icon_list,
|
||||
@ -316,13 +320,7 @@ class EventEditor:
|
||||
|
||||
def on_event_edit_ok_clicked(self,obj):
|
||||
|
||||
ename = unicode(self.event_menu.child.get_text())
|
||||
|
||||
if not ename.strip():
|
||||
ErrorDialog(_("Event does not have a type"),
|
||||
_("You must specify an event type "
|
||||
"before you can save the event"))
|
||||
return
|
||||
event_data = self.eventmapper.get_values()
|
||||
|
||||
#self.date = self.dp.parse(unicode(self.date_field.get_text()))
|
||||
ecause = unicode(self.cause_field.get_text())
|
||||
@ -336,23 +334,24 @@ class EventEditor:
|
||||
edesc = unicode(self.descr_field.get_text())
|
||||
epriv = self.priv.get_active()
|
||||
|
||||
if ename not in self.elist:
|
||||
WarningDialog(
|
||||
_('New event type created'),
|
||||
_('The "%s" event type has been added to this database.\n'
|
||||
'It will now appear in the event menus for this database') % ename)
|
||||
self.elist.append(ename)
|
||||
self.elist.sort()
|
||||
# if ename not in self.elist:
|
||||
# WarningDialog(
|
||||
# _('New event type created'),
|
||||
# _('The "%s" event type has been added to this database.\n'
|
||||
# 'It will now appear in the event menus for this database') % ename)
|
||||
# self.elist.append(ename)
|
||||
# self.elist.sort()
|
||||
|
||||
just_added = False
|
||||
if self.event == None:
|
||||
self.event = RelLib.Event()
|
||||
self.event.set_handle(Utils.create_id())
|
||||
self.event.set_source_reference_list(self.srcreflist)
|
||||
self.event.set_witness_list(self.witnesslist)
|
||||
#self.event.set_witness_list(self.witnesslist)
|
||||
self.event.set_type(event_data)
|
||||
just_added = True
|
||||
|
||||
self.update_event(ename,self.date,eplace_obj,edesc,enote,eformat,
|
||||
self.update_event(event_data,self.date,eplace_obj,edesc,enote,eformat,
|
||||
epriv,ecause)
|
||||
|
||||
self.close(obj)
|
||||
@ -360,6 +359,8 @@ class EventEditor:
|
||||
self.callback(self.event)
|
||||
|
||||
def update_event(self,the_type,date,place,desc,note,format,priv,cause):
|
||||
print self.event
|
||||
|
||||
if place:
|
||||
if self.event.get_place_handle() != place.get_handle():
|
||||
self.event.set_place_handle(place.get_handle())
|
||||
@ -388,7 +389,7 @@ class EventEditor:
|
||||
dobj = self.event.get_date_object()
|
||||
|
||||
self.event.set_source_reference_list(self.srcreflist)
|
||||
self.event.set_witness_list(self.witnesslist)
|
||||
#self.event.set_witness_list(self.witnesslist)
|
||||
|
||||
if not dobj.is_equal(date):
|
||||
self.event.set_date_object(date)
|
||||
@ -412,8 +413,6 @@ class EventEditor:
|
||||
else:
|
||||
Utils.unbold_label(self.notes_label)
|
||||
|
||||
|
||||
|
||||
class EventRefEditor:
|
||||
def __init__(self, eventref, referent, database, update, parent):
|
||||
|
||||
|
@ -45,7 +45,7 @@ from ListModel import ListModel, NOSORT, COMBO, TEXT, TOGGLE
|
||||
from DdTargets import DdTargets
|
||||
|
||||
import const
|
||||
import TransTable
|
||||
import RelLib
|
||||
import UrlEdit
|
||||
import NameEdit
|
||||
import NoteEdit
|
||||
@ -82,6 +82,8 @@ class ListBox:
|
||||
return list(self.change_list)
|
||||
|
||||
def add_object(self,item):
|
||||
import traceback
|
||||
traceback.print_stack()
|
||||
self.data.append(item)
|
||||
self.change_list.add(item)
|
||||
|
||||
@ -242,17 +244,19 @@ class EventListBox(ReorderListBox):
|
||||
|
||||
def __init__(self,parent,person,obj,label,button_list):
|
||||
|
||||
self.trans = TransTable.TransTable(self.titles)
|
||||
|
||||
self.data = []
|
||||
if person.get_birth_ref():
|
||||
event = parent.db.get_event_from_handle(person.get_birth_ref().ref)
|
||||
self.data.append(event)
|
||||
if person.get_death_ref():
|
||||
event = parent.db.get_event_from_handle(person.get_death_ref().ref)
|
||||
self.data.append(event)
|
||||
birth_ref = person.get_birth_ref()
|
||||
death_ref = person.get_death_ref()
|
||||
if birth_ref:
|
||||
self.data.append((birth_ref,
|
||||
parent.db.get_event_from_handle(birth_ref.ref)))
|
||||
if death_ref:
|
||||
self.data.append((death_ref,
|
||||
parent.db.get_event_from_handle(death_ref.ref)))
|
||||
self
|
||||
for event_ref in person.get_event_ref_list():
|
||||
self.data.append(parent.db.get_event_from_handle(event_ref.ref))
|
||||
self.data.append((event_ref,
|
||||
parent.db.get_event_from_handle(event_ref.ref)))
|
||||
|
||||
eventnames = Utils.personal_events.values()
|
||||
|
||||
@ -270,26 +274,26 @@ class EventListBox(ReorderListBox):
|
||||
button_list, evalues, DdTargets.EVENT)
|
||||
|
||||
def set_name(self,index,value):
|
||||
self.data[index].set_name(value)
|
||||
self.data[index][1].set_name(value)
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def set_description(self,index,value):
|
||||
self.data[index].set_description(value)
|
||||
self.data[index][1].set_description(value)
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def set_place(self,index,value):
|
||||
self.data[index].set_description(value)
|
||||
self.data[index][1].set_description(value)
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def set_date(self,index,value):
|
||||
self.data[index].set_date(value)
|
||||
self.data[index][1].set_date(value)
|
||||
self.change_list.add(self.data[index])
|
||||
|
||||
def add(self,obj):
|
||||
"""Brings up the EventEditor for a new event"""
|
||||
EventEdit.EventEditor(
|
||||
self.parent, self.name, Utils.personal_events,
|
||||
Utils.personal_events, None, None, 0,
|
||||
None, None, False,
|
||||
self.edit_callback, noedit=self.db.readonly)
|
||||
|
||||
def update(self,obj):
|
||||
@ -299,11 +303,12 @@ class EventListBox(ReorderListBox):
|
||||
event = self.list_model.get_object(node)
|
||||
EventEdit.EventEditor(
|
||||
self.parent, self.name, Utils.personal_events,
|
||||
Utils.personal_events, event, None, 0,
|
||||
event, None, False,
|
||||
self.edit_callback, noedit=self.db.readonly)
|
||||
|
||||
def display_data(self,event):
|
||||
|
||||
def display_data(self,event_tuple):
|
||||
print event_tuple
|
||||
(event_ref, event) = event_tuple
|
||||
pid = event.get_place_handle()
|
||||
if pid:
|
||||
pname = self.db.get_place_from_handle(pid).get_title()
|
||||
@ -311,7 +316,12 @@ class EventListBox(ReorderListBox):
|
||||
pname = u''
|
||||
has_note = event.get_note()
|
||||
has_source = len(event.get_source_references())> 0
|
||||
return [const.display_pevent(event.get_name()),
|
||||
etype = event.get_type()
|
||||
if etype[0] == RelLib.Event.CUSTOM:
|
||||
name = etype[1]
|
||||
else:
|
||||
name = Utils.personal_events[etype[0]]
|
||||
return [name,
|
||||
event.get_description(), event.get_date(),
|
||||
pname, has_source, has_note]
|
||||
|
||||
@ -326,6 +336,20 @@ class EventListBox(ReorderListBox):
|
||||
foo.set_place_handle(place.get_handle())
|
||||
self.data.insert(row,foo.get_handle())
|
||||
|
||||
def edit_callback(self,data):
|
||||
self.changed = True
|
||||
ref = RelLib.EventRef()
|
||||
ref.ref = data
|
||||
new_data = (ref,data)
|
||||
self.change_list.add(new_data)
|
||||
if new_data not in self.data:
|
||||
self.data.append(new_data)
|
||||
self.redraw()
|
||||
try:
|
||||
self.list_model.select_iter(self.node_map[new_data])
|
||||
except:
|
||||
print "Edit callback failed"
|
||||
|
||||
class NameListBox(ReorderListBox):
|
||||
|
||||
def __init__(self,parent,person,obj,label,button_list):
|
||||
|
@ -42,7 +42,7 @@ class ListModel:
|
||||
self.mylist = []
|
||||
self.data_index = 0
|
||||
for l in dlist:
|
||||
if l[0] == TOGGLE:
|
||||
if l[3] == TOGGLE:
|
||||
self.mylist.append(TYPE_BOOLEAN)
|
||||
else:
|
||||
self.mylist.append(TYPE_STRING)
|
||||
|
@ -297,24 +297,27 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_birth_day(self,data,node):
|
||||
if data[_BIRTH_COL]:
|
||||
birth = self.db.get_event_from_handle(data[_BIRTH_COL])
|
||||
birth = self.db.get_event_from_handle(data[_BIRTH_COL].ref)
|
||||
if birth.get_date() and birth.get_date() != "":
|
||||
return cgi.escape(birth.get_date())
|
||||
|
||||
for event_handle in data[_EVENT_COL]:
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if event.name in ["Baptism", "Christening"] and event.get_date() != "":
|
||||
for event_ref in data[_EVENT_COL]:
|
||||
print event_ref, event_ref.ref
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
print "Event",event
|
||||
if (event.get_type() in [RelLib.Event.BAPTISM, RelLib.Event.CHRISTEN]
|
||||
and event.get_date() != ""):
|
||||
return "<i>" + cgi.escape(event.get_date()) + "</i>"
|
||||
|
||||
return u""
|
||||
|
||||
def column_death_day(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
death = self.db.get_event_from_handle(data[_DEATH_COL])
|
||||
death = self.db.get_event_from_handle(data[_DEATH_COL].ref)
|
||||
if death.get_date() and death.get_date() != "":
|
||||
return cgi.escape(death.get_date())
|
||||
|
||||
for event_handle in data[_EVENT_COL]:
|
||||
for event_handle in data[_EVENT_COL].ref:
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if event.name in ["Burial", "Cremation"] and event.get_date() != "":
|
||||
return "<i>" + cgi.escape(event.get_date()) + "</i>"
|
||||
@ -323,13 +326,13 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_cause_of_death(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
return self.db.get_event_from_handle(data[_DEATH_COL]).get_cause()
|
||||
return self.db.get_event_from_handle(data[_DEATH_COL].ref).get_cause()
|
||||
else:
|
||||
return u""
|
||||
|
||||
def column_birth_place(self,data,node):
|
||||
if data[_BIRTH_COL]:
|
||||
event = self.db.get_event_from_handle(data[_BIRTH_COL])
|
||||
event = self.db.get_event_from_handle(data[_BIRTH_COL].ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
@ -337,7 +340,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
if place_title != "":
|
||||
return cgi.escape(place_title)
|
||||
|
||||
for event_handle in data[_EVENT_COL]:
|
||||
for event_handle in data[_EVENT_COL].ref:
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if event.name in ["Baptism", "Christening"]:
|
||||
place_handle = event.get_place_handle()
|
||||
@ -350,7 +353,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_death_place(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
event = self.db.get_event_from_handle(data[_DEATH_COL])
|
||||
event = self.db.get_event_from_handle(data[_DEATH_COL].ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
@ -358,7 +361,7 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
if place_title != "":
|
||||
return cgi.escape(place_title)
|
||||
|
||||
for event_handle in data[_EVENT_COL]:
|
||||
for event_handle in data[_EVENT_COL].ref:
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
if event.name in ["Burial", "Cremation"]:
|
||||
place_handle = event.get_place_handle()
|
||||
|
Loading…
Reference in New Issue
Block a user