fix some eventlist handling errors

svn: r4442
This commit is contained in:
Don Allingham 2005-04-28 22:21:20 +00:00
parent d3b7cda0e3
commit 45bd976f69
6 changed files with 36 additions and 43 deletions

View File

@ -1,3 +1,11 @@
2005-04-28 Don Allingham <don@gramps-project.org>
* src/EditPerson.py: remove dead logic for birth/death editing,
fix list handling
* src/EventEdit.py: fix callbacks for updating events
* src/GrampsDbBase.py: shorten handles
* src/Utils.py: shorten handles
* src/edit_person.glade: fix image spacing
2005-04-27 Don Allingham <don@gramps-project.org>
* src/EditPerson.py: rewrite of tabbed lists
* src/EventEdit.py: bold the label

View File

@ -208,22 +208,9 @@ class EditPerson:
self.prefix_label.set_text(_('Patronymic:'))
self.prefix_label.set_use_underline(True)
birth_handle = person.get_birth_handle()
if birth_handle:
self.orig_birth = self.db.get_event_from_handle(birth_handle)
else:
self.orig_birth = RelLib.Event()
self.orig_birth.set_name("Birth")
self.birth_handle = person.get_birth_handle()
self.death_handle = person.get_death_handle()
death_handle = person.get_death_handle()
if death_handle:
self.orig_death = self.db.get_event_from_handle(death_handle)
else:
self.orig_death = RelLib.Event()
self.orig_death.set_name("Death")
self.death = RelLib.Event(self.orig_death)
self.birth = RelLib.Event(self.orig_birth)
self.pname = RelLib.Name(person.get_primary_name())
self.gender.set_active(person.get_gender())
@ -848,13 +835,13 @@ class EditPerson:
def update_lists(self):
"""Updates the person's lists if anything has changed"""
if self.lists_changed:
#self.person.set_event_list(self.elist)
self.person.set_alternate_names(self.nlist)
self.person.set_url_list(self.ulist)
self.person.set_attribute_list(self.alist)
self.person.set_address_list(self.plist)
self.person.set_birth_handle(self.birth.get_handle())
self.person.set_death_handle(self.death.get_handle())
#self.person.set_event_list(self.elist)
# self.person.set_birth_handle(self.birth.get_handle())
# self.person.set_death_handle(self.death.get_handle())
def on_apply_person_clicked(self,obj):
@ -933,11 +920,11 @@ class EditPerson:
p = self.db.get_place_from_handle(key).get_display_info()
self.pdmap[p[0]] = key
if not self.orig_birth.are_equal(self.birth):
if self.orig_birth.is_empty():
self.db.add_event(self.birth,trans)
self.person.set_birth_handle(self.birth.get_handle())
self.db.commit_event(self.birth,trans)
# if not self.orig_birth.are_equal(self.birth):
# if self.orig_birth.is_empty():
# self.db.add_event(self.birth,trans)
# self.person.set_birth_handle(self.birth.get_handle())
# self.db.commit_event(self.birth,trans)
# Update each of the families child lists to reflect any
# change in ordering due to the new birth date
@ -1294,6 +1281,9 @@ class ListBox:
self.blist[0].connect('clicked',self.add)
self.blist[1].connect('clicked',self.update)
self.blist[2].connect('clicked',self.delete)
def add_object(self,item):
self.data.append(item)
def select_row(self,obj):
store, node = obj.get_selected()
@ -1337,6 +1327,7 @@ class ListBox:
try:
self.list_model.select_iter(self.node_map[str(data)])
except:
print self.node_map, data
print "Edit callback failed"
def set_label(self):
@ -1493,6 +1484,8 @@ class EventListBox(ReorderListBox):
self.node_map = {}
for handle in self.data:
event = self.db.get_event_from_handle(handle)
if not event:
print "couldn't find",handle
pname = place_title(self.db,event)
has_note = event.get_note()
has_source = len(event.get_source_references())> 0
@ -1500,7 +1493,7 @@ class EventListBox(ReorderListBox):
event.get_description(), event.get_date(),
pname, has_source, has_note]
node = self.list_model.add(data, event)
self.node_map[str(event)] = node
self.node_map[handle] = node
if self.data:
self.list_model.select_row(0)
self.set_label()

View File

@ -346,20 +346,22 @@ class EventEditor:
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.db.add_event(self.event,trans)
self.event.set_source_reference_list(self.srcreflist)
self.event.set_witness_list(self.witnesslist)
self.parent.elist.append(self.event.get_handle())
just_added = True
self.update_event(ename,self.date,eplace_obj,edesc,enote,eformat,
epriv,ecause,trans)
self.db.transaction_commit(trans,_("Edit Event"))
self.close(obj)
self.parent.redraw_event_list()
if self.callback:
self.callback(self.event)
self.callback(self.event.get_handle())
def update_event(self,name,date,place,desc,note,format,priv,cause,trans):
if place:

View File

@ -211,9 +211,8 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback):
pass
def create_id(self):
return "%08x%08x%08x" % ( int(time.time()*10000),
self.rand.randint(0,maxint),
self.rand.randint(0,maxint))
return "%08x%08x" % ( int(time.time()*10000),
self.rand.randint(0,maxint))
def get_person_cursor(self):
assert False, "Needs to be overridden in the derived class"

View File

@ -425,22 +425,12 @@ def unbold_label(label):
#-------------------------------------------------------------------------
import random
import time
from sys import maxint
rand = random.Random(time.time())
def create_id():
s = ""
for val in [ int(time.time()*10000) & 0x7fffffff,
rand.randint(0,0x7fffffff),
rand.randint(0,0x7fffffff)]:
while val != 0:
rem = val % 36
if rem <= 9:
s += chr(48+rem)
else:
s += chr(rem+55)
val = int(val/36)
return s
return "%08x%08x" % ( int(time.time()*10000),
rand.randint(0,maxint))
def probably_alive(person,db,current_year=None):
"""Returns true if the person may be alive.

View File

@ -283,6 +283,7 @@ Unknown</property>
<child>
<widget class="GtkFrame" id="frame5">
<property name="width_request">124</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>