From 52e250979b48ddc83d248bc4fda47913aeeb16b4 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Fri, 7 Mar 2008 14:19:30 +0000 Subject: [PATCH] 2008-03-07 Douglas S. Blank * src/QuickReports.py: optionally pass in kwargs * src/plugins/DefaultGramplets.py: added generation summary to pedigree * src/plugins/FilterByName.py: new filter "people by list" * src/DataViews/GrampletView.py: handle "people by list" links svn: r10211 --- ChangeLog | 6 ++++++ src/DataViews/GrampletView.py | 8 ++++++++ src/QuickReports.py | 8 ++++---- src/plugins/DefaultGramplets.py | 27 ++++++++++++++++++++++++++- src/plugins/FilterByName.py | 10 +++++++++- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 95320ccb5..1ac13ed2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-03-07 Douglas S. Blank + * src/QuickReports.py: optionally pass in kwargs + * src/plugins/DefaultGramplets.py: added generation summary to pedigree + * src/plugins/FilterByName.py: new filter "people by list" + * src/DataViews/GrampletView.py: handle "people by list" links + 2008-03-07 Peter Landgren * src/GrampsCfg.py * src/Config/_GrampsConfigKeys.py diff --git a/src/DataViews/GrampletView.py b/src/DataViews/GrampletView.py index ef5851ec9..6178f7008 100644 --- a/src/DataViews/GrampletView.py +++ b/src/DataViews/GrampletView.py @@ -436,6 +436,14 @@ class Gramplet(object): self.gui.uistate, 'filterbyname', handle) + elif link_type == 'PersonList': + if event.button == 1: # left mouse + if event.type == gtk.gdk._2BUTTON_PRESS: # double + run_quick_report_by_name(self.gui.dbstate, + self.gui.uistate, + 'filterbyname', + 'list of people', + handles=handle) return True return False # did not handle event diff --git a/src/QuickReports.py b/src/QuickReports.py index ecdfcaf83..98a745bf1 100644 --- a/src/QuickReports.py +++ b/src/QuickReports.py @@ -108,7 +108,7 @@ def by_menu_name(first, second): def make_quick_report_callback(lst, category, dbstate, uistate, handle): return lambda x: run_report(dbstate, uistate, category, handle, lst[0]) -def run_quick_report_by_name(dbstate, uistate, report_name, handle): +def run_quick_report_by_name(dbstate, uistate, report_name, handle, **kwargs): from PluginUtils import quick_report_list # [0] - function # [1] - translated name @@ -121,7 +121,7 @@ def run_quick_report_by_name(dbstate, uistate, report_name, handle): report = item break if report: - run_report(dbstate, uistate, report[2], handle, report[0]) + run_report(dbstate, uistate, report[2], handle, report[0], **kwargs) else: raise AttributeError, ("No such quick report '%s'" % report_name) @@ -148,7 +148,7 @@ def run_quick_report_by_name_direct(report_name, database, document, handle): else: raise AttributeError, ("No such quick report '%s'" % report_name) -def run_report(dbstate, uistate, category, handle,func): +def run_report(dbstate, uistate, category, handle, func, **kwargs): from docgen import TextBufDoc from Simple import make_basic_stylesheet @@ -177,6 +177,6 @@ def run_report(dbstate, uistate, category, handle,func): obj = handle if obj: d.open("") - func(dbstate.db, d, obj) + func(dbstate.db, d, obj, **kwargs) d.close() diff --git a/src/plugins/DefaultGramplets.py b/src/plugins/DefaultGramplets.py index ace704603..c6f141cce 100644 --- a/src/plugins/DefaultGramplets.py +++ b/src/plugins/DefaultGramplets.py @@ -521,10 +521,16 @@ class PedigreeGramplet(Gramplet): self.link(name_displayer.display_name(person.get_primary_name()), 'Person', person.handle) self.append_text("\n") + if generation not in self._generations: + self._generations[generation] = [] + self._generations[generation].append(handle) elif what == "a": self.append_text("o------") self.render_text("%s" % name_displayer.display_name(person.get_primary_name())) self.append_text("\n") + if generation not in self._generations: + self._generations[generation] = [] + self._generations[generation].append(handle) elif what == "m": if len(family_list) > 0: family = self.dbstate.db.get_family_from_handle(family_list[0]) @@ -541,6 +547,7 @@ class PedigreeGramplet(Gramplet): Generator which will be run in the background. """ self._boxes = [0] * self.max_generations + self._generations = {} self.set_text("") active_person = self.dbstate.get_active_person() if not active_person: @@ -548,8 +555,26 @@ class PedigreeGramplet(Gramplet): #no wrap in Gramplet self.no_wrap() self.process_person(active_person.handle, 1, "f") # father - self.process_person(active_person.handle, 0, "a") # active + self.process_person(active_person.handle, 0, "a") # active #FIXME: should be 1? self.process_person(active_person.handle, 1, "m") # mother + gens = self._generations.keys() + gens.sort() + self.append_text(_("\nBreakdown by generation:\n")) + all = [active_person.handle] + for g in gens: + count = len(self._generations[g]) + handles = self._generations[g] + self.append_text(" ") + if g == 0: + self.link(_("Generation 1"), 'PersonList', handles) + self.append_text(_(" has 1 of 1 individual (100.00% complete)\n")) + else: + all.extend(handles) + self.link(_("Generation %d") % g, 'PersonList', handles) + self.append_text(_(" has %d of %d individuals (%.2f%% complete)\n") % + (count, 2**(g-1), float(count)/2**(g-1) * 100)) + self.link(_("All generations"), 'PersonList', all) + self.append_text(_(" have %d individuals\n") % len(all)) self.append_text("", scroll_to="begin") class StatsGramplet(Gramplet): diff --git a/src/plugins/FilterByName.py b/src/plugins/FilterByName.py index 291076e5f..9030b12ee 100644 --- a/src/plugins/FilterByName.py +++ b/src/plugins/FilterByName.py @@ -33,7 +33,7 @@ import DateHandler import posixpath from gettext import gettext as _ -def run(database, document, filter_name): +def run(database, document, filter_name, *args, **kwargs): """ Loops through the families that the person is a child in, and display the information about the other children. @@ -199,6 +199,14 @@ def run(database, document, filter_name): matches += 1 except: pass + elif (filter_name == 'list of people'): + stab.columns(_("Person"), _("Birth Date"), _("Name type")) + people = kwargs["handles"] + for person_handle in people: + person = database.get_person_from_handle(person_handle) + stab.row(person, sdb.birth_date_obj(person), + str(person.get_primary_name().get_type())) + matches += 1 else: raise AttributeError, ("invalid filter name: '%s'" % filter_name) sdoc.paragraph(_("Filter matched %d records.") % matches)