* 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>
|
2008-01-15 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
* src/PluginUtils/_Tool.py (Tool.__init__): pass in dbstate
|
* src/PluginUtils/_Tool.py (Tool.__init__): pass in dbstate
|
||||||
* src/PluginUtils/__init__.py (MenuToolOptions.__init__):
|
* src/PluginUtils/__init__.py (MenuToolOptions.__init__):
|
||||||
|
@ -240,6 +240,32 @@ class SimpleAccess:
|
|||||||
return DateHandler.displayer.display(date_obj)
|
return DateHandler.displayer.display(date_obj)
|
||||||
return u''
|
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):
|
def __event_place(self, person, func):
|
||||||
"""
|
"""
|
||||||
Returns a string describing the place associated with the person
|
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)
|
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):
|
def birth_place(self, person):
|
||||||
"""
|
"""
|
||||||
Returns a string indicating the place of the person's birth.
|
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)
|
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):
|
def death_place(self, person):
|
||||||
"""
|
"""
|
||||||
Returns a string indicating the place of the person's death.
|
Returns a string indicating the place of the person's death.
|
||||||
|
@ -45,6 +45,7 @@ class SimpleTable:
|
|||||||
self.__link = []
|
self.__link = []
|
||||||
self.__sort_col = None
|
self.__sort_col = None
|
||||||
self.__sort_reverse = False
|
self.__sort_reverse = False
|
||||||
|
self.__link_col = None
|
||||||
|
|
||||||
def get_row_count(self):
|
def get_row_count(self):
|
||||||
return len(self.__rows)
|
return len(self.__rows)
|
||||||
@ -60,7 +61,6 @@ class SimpleTable:
|
|||||||
"""
|
"""
|
||||||
Handle events on tables. obj is a treeview
|
Handle events on tables. obj is a treeview
|
||||||
"""
|
"""
|
||||||
from QuickReports import run_quick_report_by_name
|
|
||||||
from Editors import (EditPerson, EditEvent, EditFamily, EditSource,
|
from Editors import (EditPerson, EditEvent, EditFamily, EditSource,
|
||||||
EditPlace, EditRepository)
|
EditPlace, EditRepository)
|
||||||
selection = obj.get_selection()
|
selection = obj.get_selection()
|
||||||
@ -118,11 +118,6 @@ class SimpleTable:
|
|||||||
return True # handled event
|
return True # handled event
|
||||||
except Errors.WindowActiveError:
|
except Errors.WindowActiveError:
|
||||||
pass
|
pass
|
||||||
elif objclass == 'Date':
|
|
||||||
run_quick_report_by_name(self.gui.dbstate,
|
|
||||||
self.gui.uistate,
|
|
||||||
'onthisday',
|
|
||||||
date)
|
|
||||||
return False # didn't handle event
|
return False # didn't handle event
|
||||||
|
|
||||||
def on_table_click(self, obj):
|
def on_table_click(self, obj):
|
||||||
@ -148,19 +143,27 @@ class SimpleTable:
|
|||||||
"""
|
"""
|
||||||
self.__sort_vals[col].append(val)
|
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):
|
def row(self, *data):
|
||||||
"""
|
"""
|
||||||
Add a row of data.
|
Add a row of data.
|
||||||
"""
|
"""
|
||||||
retval = []
|
retval = []
|
||||||
link = None
|
link = None
|
||||||
for item in data:
|
for col in range(len(data)):
|
||||||
|
item = data[col]
|
||||||
# FIXME: add better text representations of these objects
|
# FIXME: add better text representations of these objects
|
||||||
if type(item) in [str, unicode]:
|
if type(item) in [str, unicode]:
|
||||||
retval.append(item)
|
retval.append(item)
|
||||||
elif isinstance(item, gen.lib.Person):
|
elif isinstance(item, gen.lib.Person):
|
||||||
name = self.access.name(item)
|
name = self.access.name(item)
|
||||||
retval.append(name)
|
retval.append(name)
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Person', item.handle)
|
link = ('Person', item.handle)
|
||||||
elif isinstance(item, gen.lib.Family):
|
elif isinstance(item, gen.lib.Family):
|
||||||
father = self.access.father(item)
|
father = self.access.father(item)
|
||||||
@ -176,29 +179,38 @@ class SimpleTable:
|
|||||||
else:
|
else:
|
||||||
text += " " + _("Unknown mother")
|
text += " " + _("Unknown mother")
|
||||||
retval.append(text)
|
retval.append(text)
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Family', item.handle)
|
link = ('Family', item.handle)
|
||||||
elif isinstance(item, gen.lib.Source):
|
elif isinstance(item, gen.lib.Source):
|
||||||
retval.append(_('Source'))
|
retval.append(_('Source'))
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Souce', item.handle)
|
link = ('Souce', item.handle)
|
||||||
elif isinstance(item, gen.lib.Event):
|
elif isinstance(item, gen.lib.Event):
|
||||||
name = self.access.event_type(item)
|
name = self.access.event_type(item)
|
||||||
retval.append(name)
|
retval.append(name)
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Event', item.handle)
|
link = ('Event', item.handle)
|
||||||
elif isinstance(item, gen.lib.MediaObject):
|
elif isinstance(item, gen.lib.MediaObject):
|
||||||
retval.append(_('Media'))
|
retval.append(_('Media'))
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Media', item.handle)
|
link = ('Media', item.handle)
|
||||||
elif isinstance(item, gen.lib.Place):
|
elif isinstance(item, gen.lib.Place):
|
||||||
retval.append(_('Place'))
|
retval.append(_('Place'))
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Place', item.handle)
|
link = ('Place', item.handle)
|
||||||
elif isinstance(item, gen.lib.Repository):
|
elif isinstance(item, gen.lib.Repository):
|
||||||
retval.append(_('Repository'))
|
retval.append(_('Repository'))
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Repository', item.handle)
|
link = ('Repository', item.handle)
|
||||||
elif isinstance(item, gen.lib.Note):
|
elif isinstance(item, gen.lib.Note):
|
||||||
retval.append(_('Note'))
|
retval.append(_('Note'))
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Note', item.handle)
|
link = ('Note', item.handle)
|
||||||
elif isinstance(item, gen.lib.Date):
|
elif isinstance(item, gen.lib.Date):
|
||||||
text = DateHandler.displayer.display(item)
|
text = DateHandler.displayer.display(item)
|
||||||
retval.append(text)
|
retval.append(text)
|
||||||
|
self.row_sort_val(col, item.sortval)
|
||||||
|
if (self.__link_col == col or link == None):
|
||||||
link = ('Date', item)
|
link = ('Date', item)
|
||||||
else:
|
else:
|
||||||
raise AttributeError, ("unknown object type: '%s': %s" %
|
raise AttributeError, ("unknown object type: '%s': %s" %
|
||||||
|
@ -64,8 +64,11 @@ def run(database, document, main_event):
|
|||||||
sdb = SimpleAccess(database)
|
sdb = SimpleAccess(database)
|
||||||
sdoc = SimpleDoc(document)
|
sdoc = SimpleDoc(document)
|
||||||
stab = SimpleTable(sdb, sdoc)
|
stab = SimpleTable(sdb, sdoc)
|
||||||
|
stab.set_link_col(3)
|
||||||
yeartab = SimpleTable(sdb, sdoc)
|
yeartab = SimpleTable(sdb, sdoc)
|
||||||
|
yeartab.set_link_col(3)
|
||||||
histab = SimpleTable(sdb, sdoc)
|
histab = SimpleTable(sdb, sdoc)
|
||||||
|
histab.set_link_col(3)
|
||||||
|
|
||||||
# display the title
|
# display the title
|
||||||
sdoc.title(_("Events of %(date)s") %
|
sdoc.title(_("Events of %(date)s") %
|
||||||
|
@ -68,7 +68,8 @@ def run(database, document, person):
|
|||||||
matches = 0
|
matches = 0
|
||||||
for person_handle in people:
|
for person_handle in people:
|
||||||
person = database.get_person_from_handle(person_handle)
|
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
|
matches += 1
|
||||||
sdoc.paragraph(_("There are %d people with a matching name, or alternate name.\n") % matches)
|
sdoc.paragraph(_("There are %d people with a matching name, or alternate name.\n") % matches)
|
||||||
stab.write()
|
stab.write()
|
||||||
|
@ -58,7 +58,7 @@ def run(database, document, person):
|
|||||||
# pass row the child object to make link:
|
# pass row the child object to make link:
|
||||||
stab.row(child,
|
stab.row(child,
|
||||||
sdb.gender(child),
|
sdb.gender(child),
|
||||||
sdb.birth_date(child),
|
sdb.birth_date_obj(child),
|
||||||
rel_str)
|
rel_str)
|
||||||
stab.write()
|
stab.write()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user