* src/plugins/OnThisDay.py: date sortable
* src/plugins/SameSurnames.py: date sortable * src/plugins/siblings.py: date sortable * src/Simple/_SimpleAccess.py: simple method to get date_obj * src/Simple/_SimpleTable.py: manual override of link_col; removed call to quick_reports (could have been recursive) 2008-01-15 Douglas S. Blank <dblank@cs.brynmawr.edu> svn: r9831
This commit is contained in:
parent
e304069be8
commit
2cddb31ef2
@ -1,3 +1,11 @@
|
||||
2008-01-15 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/plugins/OnThisDay.py: date sortable
|
||||
* src/plugins/SameSurnames.py: date sortable
|
||||
* src/plugins/siblings.py: date sortable
|
||||
* src/Simple/_SimpleAccess.py: simple method to get date_obj
|
||||
* src/Simple/_SimpleTable.py: manual override of link_col;
|
||||
removed call to quick_reports (could have been recursive)
|
||||
|
||||
2008-01-15 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||
* src/PluginUtils/_Tool.py (Tool.__init__): pass in dbstate
|
||||
* src/PluginUtils/__init__.py (MenuToolOptions.__init__):
|
||||
|
@ -240,6 +240,32 @@ class SimpleAccess:
|
||||
return DateHandler.displayer.display(date_obj)
|
||||
return u''
|
||||
|
||||
def __event_date_obj(self, person, func):
|
||||
"""
|
||||
Returns the date associated with the person
|
||||
|
||||
@param person: Person object
|
||||
@type person: L{gen.lib.Person}
|
||||
@param func: function used to extract the associated date information
|
||||
@type func: function
|
||||
@return: Returns the date
|
||||
@rtype: l{gen.lib.Date}
|
||||
"""
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
|
||||
if person:
|
||||
ref = func(person)
|
||||
if ref:
|
||||
event_handle = ref.get_reference_handle()
|
||||
if event_handle:
|
||||
event = self.dbase.get_event_from_handle(event_handle)
|
||||
date_obj = event.get_date_object()
|
||||
if date_obj:
|
||||
return date_obj
|
||||
else:
|
||||
return gen.lib.Date()
|
||||
return gen.lib.Date()
|
||||
|
||||
def __event_place(self, person, func):
|
||||
"""
|
||||
Returns a string describing the place associated with the person
|
||||
@ -441,6 +467,17 @@ class SimpleAccess:
|
||||
"""
|
||||
return self.__event_date(person, gen.lib.Person.get_birth_ref)
|
||||
|
||||
def birth_date_obj(self, person):
|
||||
"""
|
||||
Returns the date when the person's birth.
|
||||
|
||||
@param person: Person object
|
||||
@type person: L{gen.lib.Person}
|
||||
@return: Returns the date when the person's birth.
|
||||
@rtype: L{gen.lib.Date}
|
||||
"""
|
||||
return self.__event_date_obj(person, gen.lib.Person.get_birth_ref)
|
||||
|
||||
def birth_place(self, person):
|
||||
"""
|
||||
Returns a string indicating the place of the person's birth.
|
||||
@ -463,6 +500,17 @@ class SimpleAccess:
|
||||
"""
|
||||
return self.__event_date(person, gen.lib.Person.get_death_ref)
|
||||
|
||||
def death_date_obj(self, person):
|
||||
"""
|
||||
Returns the date when the person's death.
|
||||
|
||||
@param person: Person object
|
||||
@type person: L{gen.lib.Person}
|
||||
@return: Returns the date when the person's death.
|
||||
@rtype: L{gen.lib.Date}
|
||||
"""
|
||||
return self.__event_date_obj(person, gen.lib.Person.get_death_ref)
|
||||
|
||||
def death_place(self, person):
|
||||
"""
|
||||
Returns a string indicating the place of the person's death.
|
||||
|
@ -45,6 +45,7 @@ class SimpleTable:
|
||||
self.__link = []
|
||||
self.__sort_col = None
|
||||
self.__sort_reverse = False
|
||||
self.__link_col = None
|
||||
|
||||
def get_row_count(self):
|
||||
return len(self.__rows)
|
||||
@ -60,7 +61,6 @@ class SimpleTable:
|
||||
"""
|
||||
Handle events on tables. obj is a treeview
|
||||
"""
|
||||
from QuickReports import run_quick_report_by_name
|
||||
from Editors import (EditPerson, EditEvent, EditFamily, EditSource,
|
||||
EditPlace, EditRepository)
|
||||
selection = obj.get_selection()
|
||||
@ -118,11 +118,6 @@ class SimpleTable:
|
||||
return True # handled event
|
||||
except Errors.WindowActiveError:
|
||||
pass
|
||||
elif objclass == 'Date':
|
||||
run_quick_report_by_name(self.gui.dbstate,
|
||||
self.gui.uistate,
|
||||
'onthisday',
|
||||
date)
|
||||
return False # didn't handle event
|
||||
|
||||
def on_table_click(self, obj):
|
||||
@ -148,20 +143,28 @@ class SimpleTable:
|
||||
"""
|
||||
self.__sort_vals[col].append(val)
|
||||
|
||||
def set_link_col(self, col):
|
||||
"""
|
||||
Manually sets the column that defines link.
|
||||
"""
|
||||
self.__link_col = col
|
||||
|
||||
def row(self, *data):
|
||||
"""
|
||||
Add a row of data.
|
||||
"""
|
||||
retval = []
|
||||
link = None
|
||||
for item in data:
|
||||
for col in range(len(data)):
|
||||
item = data[col]
|
||||
# FIXME: add better text representations of these objects
|
||||
if type(item) in [str, unicode]:
|
||||
retval.append(item)
|
||||
elif isinstance(item, gen.lib.Person):
|
||||
name = self.access.name(item)
|
||||
retval.append(name)
|
||||
link = ('Person', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Person', item.handle)
|
||||
elif isinstance(item, gen.lib.Family):
|
||||
father = self.access.father(item)
|
||||
mother = self.access.mother(item)
|
||||
@ -176,30 +179,39 @@ class SimpleTable:
|
||||
else:
|
||||
text += " " + _("Unknown mother")
|
||||
retval.append(text)
|
||||
link = ('Family', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Family', item.handle)
|
||||
elif isinstance(item, gen.lib.Source):
|
||||
retval.append(_('Source'))
|
||||
link = ('Souce', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Souce', item.handle)
|
||||
elif isinstance(item, gen.lib.Event):
|
||||
name = self.access.event_type(item)
|
||||
retval.append(name)
|
||||
link = ('Event', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Event', item.handle)
|
||||
elif isinstance(item, gen.lib.MediaObject):
|
||||
retval.append(_('Media'))
|
||||
link = ('Media', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Media', item.handle)
|
||||
elif isinstance(item, gen.lib.Place):
|
||||
retval.append(_('Place'))
|
||||
link = ('Place', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Place', item.handle)
|
||||
elif isinstance(item, gen.lib.Repository):
|
||||
retval.append(_('Repository'))
|
||||
link = ('Repository', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Repository', item.handle)
|
||||
elif isinstance(item, gen.lib.Note):
|
||||
retval.append(_('Note'))
|
||||
link = ('Note', item.handle)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Note', item.handle)
|
||||
elif isinstance(item, gen.lib.Date):
|
||||
text = DateHandler.displayer.display(item)
|
||||
retval.append(text)
|
||||
link = ('Date', item)
|
||||
self.row_sort_val(col, item.sortval)
|
||||
if (self.__link_col == col or link == None):
|
||||
link = ('Date', item)
|
||||
else:
|
||||
raise AttributeError, ("unknown object type: '%s': %s" %
|
||||
(item, type(item)))
|
||||
|
@ -64,8 +64,11 @@ def run(database, document, main_event):
|
||||
sdb = SimpleAccess(database)
|
||||
sdoc = SimpleDoc(document)
|
||||
stab = SimpleTable(sdb, sdoc)
|
||||
stab.set_link_col(3)
|
||||
yeartab = SimpleTable(sdb, sdoc)
|
||||
yeartab.set_link_col(3)
|
||||
histab = SimpleTable(sdb, sdoc)
|
||||
histab.set_link_col(3)
|
||||
|
||||
# display the title
|
||||
sdoc.title(_("Events of %(date)s") %
|
||||
|
@ -68,7 +68,8 @@ def run(database, document, person):
|
||||
matches = 0
|
||||
for person_handle in people:
|
||||
person = database.get_person_from_handle(person_handle)
|
||||
stab.row(person, sdb.birth_date(person), str(person.get_primary_name().get_type()))
|
||||
stab.row(person, sdb.birth_date_obj(person),
|
||||
str(person.get_primary_name().get_type()))
|
||||
matches += 1
|
||||
sdoc.paragraph(_("There are %d people with a matching name, or alternate name.\n") % matches)
|
||||
stab.write()
|
||||
|
@ -58,7 +58,7 @@ def run(database, document, person):
|
||||
# pass row the child object to make link:
|
||||
stab.row(child,
|
||||
sdb.gender(child),
|
||||
sdb.birth_date(child),
|
||||
sdb.birth_date_obj(child),
|
||||
rel_str)
|
||||
stab.write()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user