2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-11 06:42:06 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2003-12-17 21:36:36 +05:30
|
|
|
# $Id$
|
|
|
|
|
2008-03-02 04:17:48 +05:30
|
|
|
"""Tools/Analysis and Exploration/Compare Individual Events"""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-01-15 10:55:50 +05:30
|
|
|
# python modules
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-02-19 01:37:09 +05:30
|
|
|
import gtk
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-04-16 00:56:07 +05:30
|
|
|
from Filters import GenericFilter, build_filter_model, Rules
|
2004-05-09 09:14:59 +05:30
|
|
|
import Sort
|
2003-01-15 10:55:50 +05:30
|
|
|
import Utils
|
2009-06-19 20:53:58 +05:30
|
|
|
from gui.utils import ProgressMeter
|
2008-02-19 01:37:09 +05:30
|
|
|
from docgen import ODSTab
|
2003-03-12 08:32:08 +05:30
|
|
|
import const
|
2006-07-30 09:04:10 +05:30
|
|
|
import Errors
|
2005-08-06 08:27:37 +05:30
|
|
|
import DateHandler
|
2003-01-15 10:55:50 +05:30
|
|
|
from QuestionDialog import WarningDialog
|
2008-10-02 09:32:10 +05:30
|
|
|
from PluginUtils import Tool
|
2007-03-26 02:05:33 +05:30
|
|
|
from ReportBase import ReportUtils
|
2008-04-18 15:10:27 +05:30
|
|
|
import GrampsDisplay
|
2006-04-26 00:06:52 +05:30
|
|
|
import ManagedWindow
|
2008-04-18 15:10:27 +05:30
|
|
|
from TransUtils import sgettext as _
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2008-04-18 15:10:27 +05:30
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-02-26 15:38:38 +05:30
|
|
|
WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE
|
2008-10-11 12:10:15 +05:30
|
|
|
WIKI_HELP_SEC = _('manual|Compare_Individual_Events...')
|
2003-01-15 10:55:50 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2008-04-18 15:10:27 +05:30
|
|
|
# EventCmp
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-05-21 22:49:50 +05:30
|
|
|
class TableReport(object):
|
2006-07-20 01:02:26 +05:30
|
|
|
"""
|
|
|
|
This class provides an interface for the spreadsheet table
|
|
|
|
used to save the data into the file.
|
|
|
|
"""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def __init__(self,filename,doc):
|
|
|
|
self.filename = filename
|
|
|
|
self.doc = doc
|
|
|
|
|
|
|
|
def initialize(self,cols):
|
|
|
|
self.doc.open(self.filename)
|
2007-02-06 10:49:16 +05:30
|
|
|
self.doc.start_page()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def finalize(self):
|
|
|
|
self.doc.end_page()
|
|
|
|
self.doc.close()
|
|
|
|
|
2006-08-25 05:49:06 +05:30
|
|
|
def write_table_data(self,data,skip_columns=[]):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
2006-08-25 05:49:06 +05:30
|
|
|
index = -1
|
2002-10-20 19:55:16 +05:30
|
|
|
for item in data:
|
2006-08-25 05:49:06 +05:30
|
|
|
index += 1
|
2007-02-06 10:49:16 +05:30
|
|
|
if index not in skip_columns:
|
|
|
|
self.doc.write_cell(item)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
def set_row(self,val):
|
|
|
|
self.row = val + 2
|
|
|
|
|
|
|
|
def write_table_head(self,data):
|
|
|
|
self.doc.start_row()
|
|
|
|
for item in data:
|
2007-02-06 10:49:16 +05:30
|
|
|
self.doc.write_cell(item)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-04-26 00:06:52 +05:30
|
|
|
class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow):
|
|
|
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
Tool.Tool.__init__(self,dbstate, options_class, name)
|
2006-04-26 00:06:52 +05:30
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.qual = 0
|
2009-04-16 00:56:07 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.filterDialog = Glade(toplevel="filters")
|
2009-04-16 00:56:07 +05:30
|
|
|
self.filterDialog.connect_signals({
|
2002-10-20 19:55:16 +05:30
|
|
|
"on_apply_clicked" : self.on_apply_clicked,
|
2003-03-12 08:32:08 +05:30
|
|
|
"on_editor_clicked" : self.filter_editor_clicked,
|
2006-04-26 00:06:52 +05:30
|
|
|
"on_filters_delete_event": self.close,
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"on_help_clicked" : self.on_help_clicked,
|
2004-05-10 10:24:10 +05:30
|
|
|
"destroy_passed_object" : self.close
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
window = self.filterDialog.toplevel
|
2009-04-16 00:56:07 +05:30
|
|
|
window.show()
|
|
|
|
self.filters = self.filterDialog.get_object("filter_list")
|
2004-05-10 10:24:10 +05:30
|
|
|
self.label = _('Event comparison filter selection')
|
2009-04-16 00:56:07 +05:30
|
|
|
self.set_window(window,self.filterDialog.get_object('title'),
|
2004-05-10 10:24:10 +05:30
|
|
|
self.label)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-08-01 21:39:17 +05:30
|
|
|
self.on_filters_changed('Person')
|
|
|
|
uistate.connect('filters-changed', self.on_filters_changed)
|
2004-05-10 10:24:10 +05:30
|
|
|
|
2006-04-26 00:06:52 +05:30
|
|
|
self.show()
|
2009-08-01 21:39:17 +05:30
|
|
|
|
|
|
|
|
|
|
|
def on_filters_changed(self, name_space):
|
|
|
|
if name_space == 'Person':
|
|
|
|
all_filter = GenericFilter()
|
|
|
|
all_filter.set_name(_("Entire Database"))
|
|
|
|
all_filter.add_rule(Rules.Person.Everyone([]))
|
|
|
|
self.filter_model = build_filter_model('Person', [all_filter])
|
|
|
|
self.filters.set_model(self.filter_model)
|
|
|
|
self.filters.set_active(0)
|
2004-05-10 10:24:10 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_help_clicked(self, obj):
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2008-04-18 15:10:27 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
2004-05-10 10:24:10 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2006-04-26 00:06:52 +05:30
|
|
|
return (_("Filter selection"),_("Event Comparison tool"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def filter_editor_clicked(self, obj):
|
2003-03-12 08:32:08 +05:30
|
|
|
import FilterEditor
|
2006-07-30 09:04:10 +05:30
|
|
|
try:
|
2007-09-08 11:24:02 +05:30
|
|
|
FilterEditor.FilterEditor('Person',const.CUSTOM_FILTERS,
|
2006-07-30 09:04:10 +05:30
|
|
|
self.dbstate,self.uistate)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2003-03-12 08:32:08 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_apply_clicked(self, obj):
|
2009-08-01 21:39:17 +05:30
|
|
|
cfilter = self.filter_model[self.filters.get_active()][1]
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-06-19 20:53:58 +05:30
|
|
|
progress_bar = ProgressMeter(_('Comparing events'),'')
|
2005-08-18 11:28:28 +05:30
|
|
|
progress_bar.set_pass(_('Selecting people'),1)
|
|
|
|
|
|
|
|
plist = cfilter.apply(self.db,
|
2009-07-04 01:53:41 +05:30
|
|
|
self.db.iter_person_handles())
|
2006-04-26 00:06:52 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
progress_bar.step()
|
|
|
|
progress_bar.close()
|
2009-04-16 00:56:07 +05:30
|
|
|
self.options.handler.options_dict['filter'] = self.filters.get_active()
|
2005-12-06 12:08:09 +05:30
|
|
|
# Save options
|
|
|
|
self.options.handler.save_options()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if len(plist) == 0:
|
2003-01-15 10:55:50 +05:30
|
|
|
WarningDialog(_("No matches were found"))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2006-04-26 00:06:52 +05:30
|
|
|
DisplayChart(self.dbstate,self.uistate,plist,self.track)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def by_value(first,second):
|
|
|
|
return cmp(second[0],first[0])
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def fix(line):
|
2008-01-07 22:49:17 +05:30
|
|
|
l = line.strip().replace('&','&').replace('>','>')
|
2002-11-08 09:12:25 +05:30
|
|
|
return l.replace(l,'<','<').replace(l,'"','"')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-26 00:06:52 +05:30
|
|
|
class DisplayChart(ManagedWindow.ManagedWindow):
|
|
|
|
def __init__(self,dbstate,uistate,people_list,track):
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
|
|
|
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
|
|
|
|
|
|
|
self.db = dbstate.db
|
2002-10-20 19:55:16 +05:30
|
|
|
self.my_list = people_list
|
|
|
|
self.row_data = []
|
2004-05-11 05:20:30 +05:30
|
|
|
self.save_form = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.topDialog = Glade()
|
2009-04-16 00:56:07 +05:30
|
|
|
self.topDialog.connect_signals({
|
2002-10-20 19:55:16 +05:30
|
|
|
"on_write_table" : self.on_write_table,
|
2004-05-11 05:20:30 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"on_help_clicked" : self.on_help_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
window = self.topDialog.toplevel
|
2009-04-16 00:56:07 +05:30
|
|
|
window.show()
|
|
|
|
self.set_window(window, self.topDialog.get_object('title'),
|
2006-04-26 00:06:52 +05:30
|
|
|
_('Event Comparison Results'))
|
|
|
|
|
2009-04-16 00:56:07 +05:30
|
|
|
self.eventlist = self.topDialog.get_object('treeview')
|
2004-05-09 09:14:59 +05:30
|
|
|
self.sort = Sort.Sort(self.db)
|
|
|
|
self.my_list.sort(self.sort.by_last_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.event_titles = self.make_event_titles()
|
2006-08-21 08:50:39 +05:30
|
|
|
|
2006-08-23 11:51:51 +05:30
|
|
|
self.table_titles = [_("Person"),_("ID")]
|
2006-08-21 08:50:39 +05:30
|
|
|
for event_name in self.event_titles:
|
|
|
|
self.table_titles.append(event_name + _(" Date"))
|
2006-08-23 11:51:51 +05:30
|
|
|
self.table_titles.append('sort') # This won't be shown in a tree
|
2006-08-21 08:50:39 +05:30
|
|
|
self.table_titles.append(event_name + _(" Place"))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.build_row_data()
|
2006-08-23 11:51:51 +05:30
|
|
|
self.draw_display()
|
2006-04-26 00:06:52 +05:30
|
|
|
self.show()
|
2004-05-11 05:20:30 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_help_clicked(self, obj):
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2008-04-18 15:10:27 +05:30
|
|
|
GrampsDisplay.help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
2004-05-11 05:20:30 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2006-04-26 00:06:52 +05:30
|
|
|
return (_("Event Comparison Results"),None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-08-23 11:51:51 +05:30
|
|
|
def draw_display(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-08-23 11:51:51 +05:30
|
|
|
model_index = 0
|
|
|
|
tree_index = 0
|
|
|
|
mylist = []
|
|
|
|
renderer = gtk.CellRendererText()
|
2006-08-21 08:50:39 +05:30
|
|
|
for title in self.table_titles:
|
2006-08-23 11:51:51 +05:30
|
|
|
mylist.append(str)
|
|
|
|
if title == 'sort':
|
|
|
|
# This will override the previously defined column
|
|
|
|
self.eventlist.get_column(
|
|
|
|
tree_index-1).set_sort_column_id(model_index)
|
|
|
|
else:
|
|
|
|
column = gtk.TreeViewColumn(title,renderer,text=model_index)
|
|
|
|
column.set_sort_column_id(model_index)
|
|
|
|
self.eventlist.append_column(column)
|
|
|
|
# This one numbers the tree columns: increment on new column
|
2009-09-11 00:19:48 +05:30
|
|
|
tree_index += 1
|
2006-08-23 11:51:51 +05:30
|
|
|
# This one numbers the model columns: always increment
|
2009-09-11 00:19:48 +05:30
|
|
|
model_index += 1
|
2006-08-23 11:51:51 +05:30
|
|
|
|
|
|
|
model = gtk.ListStore(*mylist)
|
|
|
|
self.eventlist.set_model(model)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
self.progress_bar.set_pass(_('Building display'),len(self.row_data))
|
2002-11-08 09:12:25 +05:30
|
|
|
for data in self.row_data:
|
2006-08-23 11:51:51 +05:30
|
|
|
model.append(row=list(data))
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress_bar.step()
|
|
|
|
self.progress_bar.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def build_row_data(self):
|
2009-06-19 20:53:58 +05:30
|
|
|
self.progress_bar = ProgressMeter(_('Comparing Events'),'')
|
2006-07-20 01:02:26 +05:30
|
|
|
self.progress_bar.set_pass(_('Building data'),len(self.my_list))
|
2004-05-09 09:14:59 +05:30
|
|
|
for individual_id in self.my_list:
|
2004-08-07 10:46:57 +05:30
|
|
|
individual = self.db.get_person_from_handle(individual_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
name = individual.get_primary_name().get_name()
|
2006-08-23 11:51:51 +05:30
|
|
|
gid = individual.get_gramps_id()
|
2006-07-20 01:02:26 +05:30
|
|
|
|
|
|
|
the_map = {}
|
2006-03-31 09:49:06 +05:30
|
|
|
for ievent_ref in individual.get_event_ref_list():
|
|
|
|
ievent = self.db.get_event_from_handle(ievent_ref.ref)
|
2006-04-26 00:06:52 +05:30
|
|
|
event_name = str(ievent.get_type())
|
2008-07-17 23:40:32 +05:30
|
|
|
if event_name in the_map:
|
2006-07-20 01:02:26 +05:30
|
|
|
the_map[event_name].append(ievent_ref.ref)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2006-07-20 01:02:26 +05:30
|
|
|
the_map[event_name] = [ievent_ref.ref]
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-04-16 00:56:07 +05:30
|
|
|
first = True
|
|
|
|
done = False
|
|
|
|
while not done:
|
|
|
|
added = False
|
|
|
|
tlist = [name, gid] if first else ["", ""]
|
|
|
|
|
2006-08-21 08:50:39 +05:30
|
|
|
for ename in self.event_titles:
|
2008-07-17 23:40:32 +05:30
|
|
|
if ename in the_map and len(the_map[ename]) > 0:
|
2006-07-20 01:02:26 +05:30
|
|
|
event_handle = the_map[ename][0]
|
|
|
|
del the_map[ename][0]
|
2009-04-16 00:56:07 +05:30
|
|
|
date = place = ""
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if event_handle:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
2005-08-06 08:27:37 +05:30
|
|
|
date = DateHandler.get_date(event)
|
2006-08-23 11:51:51 +05:30
|
|
|
sortdate = "%09d" % \
|
|
|
|
event.get_date_object().get_sort_value()
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2008-01-07 22:49:17 +05:30
|
|
|
place = self.db. \
|
|
|
|
get_place_from_handle(place_handle).get_title()
|
2009-04-16 00:56:07 +05:30
|
|
|
tlist += [date, sortdate, place]
|
|
|
|
added = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2009-04-16 00:56:07 +05:30
|
|
|
tlist += [""]*3
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if first:
|
2009-04-16 00:56:07 +05:30
|
|
|
first = False
|
2002-11-08 09:12:25 +05:30
|
|
|
self.row_data.append(tlist)
|
2009-04-16 00:56:07 +05:30
|
|
|
elif not added:
|
|
|
|
done = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2002-11-08 09:12:25 +05:30
|
|
|
self.row_data.append(tlist)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress_bar.step()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def make_event_titles(self):
|
2006-04-26 00:06:52 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the list of unique event types, along with the person's
|
2006-04-26 00:06:52 +05:30
|
|
|
name, birth, and death.
|
|
|
|
This should be the column titles of the report.
|
|
|
|
"""
|
2006-07-20 01:02:26 +05:30
|
|
|
the_map = {}
|
2004-05-09 09:14:59 +05:30
|
|
|
for individual_id in self.my_list:
|
2004-08-07 10:46:57 +05:30
|
|
|
individual = self.db.get_person_from_handle(individual_id)
|
2006-04-26 00:06:52 +05:30
|
|
|
for event_ref in individual.get_event_ref_list():
|
2006-03-31 09:49:06 +05:30
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2006-04-26 00:06:52 +05:30
|
|
|
name = str(event.get_type())
|
2002-10-20 19:55:16 +05:30
|
|
|
if not name:
|
|
|
|
break
|
2008-07-17 23:40:32 +05:30
|
|
|
if name in the_map:
|
2009-04-16 00:56:07 +05:30
|
|
|
the_map[name] += 1
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2006-07-20 01:02:26 +05:30
|
|
|
the_map[name] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2009-05-27 02:18:09 +05:30
|
|
|
unsort_list = sorted([(d, k) for k,d in the_map.iteritems()],by_value)
|
|
|
|
|
2004-05-09 09:14:59 +05:30
|
|
|
sort_list = [ item[1] for item in unsort_list ]
|
2006-08-25 05:49:06 +05:30
|
|
|
## Presently there's no Birth and Death. Instead there's Birth Date and
|
|
|
|
## Birth Place, as well as Death Date and Death Place.
|
|
|
|
## # Move birth and death to the begining of the list
|
2008-07-17 23:40:32 +05:30
|
|
|
## if _("Death") in the_map:
|
2006-08-25 05:49:06 +05:30
|
|
|
## sort_list.remove(_("Death"))
|
|
|
|
## sort_list = [_("Death")] + sort_list
|
2006-08-21 08:50:39 +05:30
|
|
|
|
2008-07-17 23:40:32 +05:30
|
|
|
## if _("Birth") in the_map:
|
2006-08-25 05:49:06 +05:30
|
|
|
## sort_list.remove(_("Birth"))
|
|
|
|
## sort_list = [_("Birth")] + sort_list
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-08-21 08:50:39 +05:30
|
|
|
return sort_list
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def on_write_table(self, obj):
|
2006-04-26 10:33:56 +05:30
|
|
|
f = gtk.FileChooserDialog(_("Select filename"),
|
|
|
|
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
buttons=(gtk.STOCK_CANCEL,
|
|
|
|
gtk.RESPONSE_CANCEL,
|
2006-04-28 10:03:28 +05:30
|
|
|
gtk.STOCK_SAVE,
|
2006-04-26 10:33:56 +05:30
|
|
|
gtk.RESPONSE_OK))
|
|
|
|
|
|
|
|
f.set_current_folder(os.getcwd())
|
|
|
|
status = f.run()
|
2007-01-31 07:33:37 +05:30
|
|
|
f.hide()
|
2006-04-26 10:33:56 +05:30
|
|
|
|
|
|
|
if status == gtk.RESPONSE_OK:
|
2009-02-24 10:11:23 +05:30
|
|
|
name = Utils.get_unicode_path(f.get_filename())
|
2008-01-08 01:37:52 +05:30
|
|
|
doc = ODSTab(len(self.row_data))
|
2006-04-26 10:33:56 +05:30
|
|
|
doc.creator(self.db.get_researcher().get_name())
|
2007-02-06 10:49:16 +05:30
|
|
|
|
|
|
|
spreadsheet = TableReport(name, doc)
|
2006-04-26 10:33:56 +05:30
|
|
|
|
2006-08-25 05:49:06 +05:30
|
|
|
new_titles = []
|
|
|
|
skip_columns = []
|
|
|
|
index = 0
|
|
|
|
for title in self.table_titles:
|
|
|
|
if title == 'sort':
|
|
|
|
skip_columns.append(index)
|
|
|
|
else:
|
|
|
|
new_titles.append(title)
|
|
|
|
index += 1
|
|
|
|
spreadsheet.initialize(len(new_titles))
|
|
|
|
|
|
|
|
spreadsheet.write_table_head(new_titles)
|
2006-04-26 10:33:56 +05:30
|
|
|
|
|
|
|
index = 0
|
|
|
|
for top in self.row_data:
|
|
|
|
spreadsheet.set_row(index%2)
|
2006-08-25 05:49:06 +05:30
|
|
|
index += 1
|
|
|
|
spreadsheet.write_table_data(top,skip_columns)
|
2006-04-26 10:33:56 +05:30
|
|
|
|
|
|
|
spreadsheet.finalize()
|
2007-01-31 07:33:37 +05:30
|
|
|
f.destroy()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class EventComparisonOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def __init__(self, name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self, name,person_id)
|
2005-12-06 12:08:09 +05:30
|
|
|
|
2007-03-26 02:05:33 +05:30
|
|
|
# Options specific for this report
|
|
|
|
self.options_dict = {
|
|
|
|
'filter' : 0,
|
|
|
|
}
|
|
|
|
filters = ReportUtils.get_person_filters(None)
|
|
|
|
self.options_help = {
|
|
|
|
'filter' : ("=num","Filter number.",
|
|
|
|
[ filt.get_name() for filt in filters ],
|
|
|
|
True ),
|
2005-12-06 12:08:09 +05:30
|
|
|
}
|