Speed up Event displaytab and gramplet
This commit is contained in:
parent
490fb1ea3b
commit
a21cb546f7
@ -51,6 +51,7 @@ from gramps.gen.datehandler import get_date, get_date_valid
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.utils.db import get_participant_from_event
|
||||
from gramps.gen.display.place import displayer as place_displayer
|
||||
from gramps.gen.proxy.cache import CacheProxyDb
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -101,7 +102,7 @@ class EventRefModel(Gtk.TreeStore):
|
||||
self.start_date = kwargs.get("start_date", None)
|
||||
typeobjs = (x[1] for x in self.COLS)
|
||||
Gtk.TreeStore.__init__(self, *typeobjs)
|
||||
self.db = db
|
||||
self.db = CacheProxyDb(db)
|
||||
self.groups = groups
|
||||
for index, group in enumerate(event_list):
|
||||
parentiter = self.append(None, row=self.row_group(index, group))
|
||||
|
@ -41,6 +41,7 @@ from gramps.gen.utils.db import (get_participant_from_event,
|
||||
get_marriage_or_fallback)
|
||||
from gramps.gen.errors import WindowActiveError
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.proxy.cache import CacheProxyDb
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
@ -51,6 +52,7 @@ class Events(Gramplet, DbGUIElement):
|
||||
def __init__(self, gui, nav_group=0):
|
||||
Gramplet.__init__(self, gui, nav_group)
|
||||
DbGUIElement.__init__(self, self.dbstate.db)
|
||||
self.db = None
|
||||
|
||||
"""
|
||||
Displays the events for a person or family.
|
||||
@ -99,14 +101,14 @@ class Events(Gramplet, DbGUIElement):
|
||||
Add an event to the model.
|
||||
"""
|
||||
self.callman.register_handles({'event': [event_ref.ref]})
|
||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
event_date = get_date(event)
|
||||
event_sort = '%012d' % event.get_date_object().get_sort_value()
|
||||
person_age = self.column_age(event)
|
||||
person_age_sort = self.column_sort_age(event)
|
||||
place = place_displayer.display_event(self.dbstate.db, event)
|
||||
place = place_displayer.display_event(self.db, event)
|
||||
|
||||
participants = get_participant_from_event(self.dbstate.db,
|
||||
participants = get_participant_from_event(self.db,
|
||||
event_ref.ref)
|
||||
|
||||
self.model.add((event.get_handle(),
|
||||
@ -191,24 +193,26 @@ class PersonEvents(Events):
|
||||
def main(self): # return false finishes
|
||||
active_handle = self.get_active('Person')
|
||||
|
||||
self.db = CacheProxyDb(self.dbstate.db)
|
||||
self.model.clear()
|
||||
self.callman.unregister_all()
|
||||
if active_handle:
|
||||
self.display_person(active_handle)
|
||||
else:
|
||||
self.set_has_data(False)
|
||||
self.db = None
|
||||
|
||||
def display_person(self, active_handle):
|
||||
"""
|
||||
Display the events for the active person.
|
||||
"""
|
||||
active_person = self.dbstate.db.get_person_from_handle(active_handle)
|
||||
active_person = self.db.get_person_from_handle(active_handle)
|
||||
if active_person:
|
||||
self.cached_start_date = self.get_start_date()
|
||||
for event_ref in active_person.get_event_ref_list():
|
||||
self.add_event_ref(event_ref)
|
||||
for family_handle in active_person.get_family_handle_list():
|
||||
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||
family = self.db.get_family_from_handle(family_handle)
|
||||
self.display_family(family, active_person)
|
||||
else:
|
||||
self.cached_start_date = None
|
||||
@ -220,7 +224,7 @@ class PersonEvents(Events):
|
||||
"""
|
||||
spouse_handle = find_spouse(active_person, family)
|
||||
if spouse_handle:
|
||||
spouse = self.dbstate.db.get_person_from_handle(spouse_handle)
|
||||
spouse = self.db.get_person_from_handle(spouse_handle)
|
||||
else:
|
||||
spouse = None
|
||||
if family:
|
||||
@ -233,8 +237,8 @@ class PersonEvents(Events):
|
||||
something close to birth.
|
||||
"""
|
||||
active_handle = self.get_active('Person')
|
||||
active = self.dbstate.db.get_person_from_handle(active_handle)
|
||||
event = get_birth_or_fallback(self.dbstate.db, active)
|
||||
active = self.db.get_person_from_handle(active_handle)
|
||||
event = get_birth_or_fallback(self.db, active)
|
||||
return event.get_date_object() if event else None
|
||||
|
||||
class FamilyEvents(Events):
|
||||
@ -264,18 +268,20 @@ class FamilyEvents(Events):
|
||||
def main(self): # return false finishes
|
||||
active_handle = self.get_active('Family')
|
||||
|
||||
self.db = CacheProxyDb(self.dbstate.db)
|
||||
self.model.clear()
|
||||
self.callman.unregister_all()
|
||||
if active_handle:
|
||||
self.display_family(active_handle)
|
||||
else:
|
||||
self.set_has_data(False)
|
||||
self.db = None
|
||||
|
||||
def display_family(self, active_handle):
|
||||
"""
|
||||
Display the events for the active family.
|
||||
"""
|
||||
active_family = self.dbstate.db.get_family_from_handle(active_handle)
|
||||
active_family = self.db.get_family_from_handle(active_handle)
|
||||
self.cached_start_date = self.get_start_date()
|
||||
for event_ref in active_family.get_event_ref_list():
|
||||
self.add_event_ref(event_ref)
|
||||
@ -287,7 +293,7 @@ class FamilyEvents(Events):
|
||||
something close to marriage.
|
||||
"""
|
||||
active_handle = self.get_active('Family')
|
||||
active = self.dbstate.db.get_family_from_handle(active_handle)
|
||||
event = get_marriage_or_fallback(self.dbstate.db, active)
|
||||
active = self.db.get_family_from_handle(active_handle)
|
||||
event = get_marriage_or_fallback(self.db, active)
|
||||
return event.get_date_object() if event else None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user