2008-02-21 12:49:32 +05:30
|
|
|
#
|
2008-03-30 10:02:52 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
2008-02-21 12:49:32 +05:30
|
|
|
#
|
2010-10-23 04:52:33 +05:30
|
|
|
# Copyright (C) 2007-2009 Stephane Charette
|
|
|
|
# Copyright (C) 2008 Brian Matherly
|
|
|
|
# Copyright (C) 2010 Jakim Friant
|
|
|
|
# Copyright (C) 2010 Nick Hall
|
2008-02-21 12:49:32 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"Find people who are not related to the selected person"
|
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import locale
|
|
|
|
|
2008-02-21 12:49:32 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GNOME/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gobject
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2009-02-26 15:38:38 +05:30
|
|
|
import const
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import ngettext
|
2010-05-01 09:42:42 +05:30
|
|
|
from gui.plug import tool
|
|
|
|
from gen.plug.report import utils as ReportUtils
|
2009-12-15 11:26:12 +05:30
|
|
|
from gui.editors import EditPerson, EditFamily
|
2008-02-21 12:49:32 +05:30
|
|
|
import ManagedWindow
|
2009-06-19 20:53:58 +05:30
|
|
|
from gui.utils import ProgressMeter
|
2008-03-21 17:48:27 +05:30
|
|
|
import GrampsDisplay
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import sgettext as _
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2010-10-23 04:52:33 +05:30
|
|
|
from gen.lib import Tag
|
2011-02-20 16:22:06 +05:30
|
|
|
from gen.db import DbTxn
|
2008-02-21 12:49:32 +05:30
|
|
|
|
2008-03-21 17:48:27 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2009-02-26 15:38:38 +05:30
|
|
|
WIKI_HELP_PAGE = '%s_-_Tools' % const.URL_MANUAL_PAGE
|
2008-03-21 17:48:27 +05:30
|
|
|
WIKI_HELP_SEC = _('manual|Not_Related...')
|
2009-05-15 01:45:59 +05:30
|
|
|
|
2008-02-21 12:49:32 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2009-05-15 01:45:59 +05:30
|
|
|
# NotRelated class
|
2008-02-21 12:49:32 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2010-05-01 09:42:42 +05:30
|
|
|
class NotRelated(tool.ActivePersonTool, ManagedWindow.ManagedWindow) :
|
2008-02-21 12:49:32 +05:30
|
|
|
|
2008-03-30 10:02:52 +05:30
|
|
|
def __init__(self, dbstate, uistate, options_class, name, callback=None):
|
2010-05-01 09:42:42 +05:30
|
|
|
tool.ActivePersonTool.__init__(self, dbstate, uistate, options_class,
|
2010-01-11 00:49:33 +05:30
|
|
|
name)
|
2009-02-23 01:54:08 +05:30
|
|
|
|
|
|
|
if self.fail: # bug #2709 -- fail if we have no active person
|
|
|
|
return
|
|
|
|
|
2010-01-11 00:49:33 +05:30
|
|
|
person_handle = uistate.get_active('Person')
|
|
|
|
person = dbstate.db.get_person_from_handle(person_handle)
|
2008-02-21 12:49:32 +05:30
|
|
|
self.name = person.get_primary_name().get_regular_name()
|
|
|
|
self.title = _('Not related to "%s"') % self.name
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.uistate = uistate
|
|
|
|
self.db = dbstate.db
|
2009-04-14 00:26:50 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
topDialog = Glade()
|
2009-04-14 00:26:50 +05:30
|
|
|
|
|
|
|
topDialog.connect_signals({
|
2008-03-21 17:48:27 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
|
|
|
"on_help_clicked" : self.on_help_clicked,
|
2010-01-07 19:40:26 +05:30
|
|
|
"on_delete_event" : self.close,
|
2008-03-21 17:48:27 +05:30
|
|
|
})
|
2008-02-21 12:49:32 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
window = topDialog.toplevel
|
2009-04-14 00:26:50 +05:30
|
|
|
title = topDialog.get_object("title")
|
2008-02-21 12:49:32 +05:30
|
|
|
self.set_window(window, title, self.title)
|
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
self.tagcombo = topDialog.get_object("tagcombo")
|
|
|
|
tagmodel = gtk.ListStore(str)
|
|
|
|
self.tagcombo.set_model(tagmodel)
|
|
|
|
self.tagcombo.set_text_column(0)
|
|
|
|
tagmodel.append((_('ToDo'),))
|
|
|
|
tagmodel.append((_('NotRelated'),))
|
|
|
|
self.tagcombo.set_sensitive(False)
|
|
|
|
|
|
|
|
self.tagapply = topDialog.get_object("tagapply")
|
|
|
|
self.tagapply.set_sensitive(False)
|
|
|
|
self.tagapply.connect('clicked', self.applyTagClicked)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# start the progress indicator
|
2009-06-19 20:53:58 +05:30
|
|
|
self.progress = ProgressMeter(self.title,_('Starting'))
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# setup the columns
|
|
|
|
self.model = gtk.TreeStore(
|
|
|
|
gobject.TYPE_STRING, # 0==name
|
|
|
|
gobject.TYPE_STRING, # 1==person gid
|
|
|
|
gobject.TYPE_STRING, # 2==parents
|
2010-10-23 04:52:33 +05:30
|
|
|
gobject.TYPE_STRING, # 3==tags
|
2008-02-21 12:49:32 +05:30
|
|
|
gobject.TYPE_STRING) # 4==family gid (not shown to user)
|
|
|
|
|
|
|
|
# note -- don't assign the model to the tree until it has been populated,
|
|
|
|
# otherwise the screen updates are terribly slow while names are appended
|
2009-04-14 00:26:50 +05:30
|
|
|
self.treeView = topDialog.get_object("treeview")
|
2008-02-21 12:49:32 +05:30
|
|
|
col1 = gtk.TreeViewColumn(_('Name'), gtk.CellRendererText(), text=0)
|
|
|
|
col2 = gtk.TreeViewColumn(_('ID'), gtk.CellRendererText(), text=1)
|
|
|
|
col3 = gtk.TreeViewColumn(_('Parents'), gtk.CellRendererText(), text=2)
|
2010-10-23 04:52:33 +05:30
|
|
|
col4 = gtk.TreeViewColumn(_('Tags'), gtk.CellRendererText(), text=3)
|
2008-02-21 12:49:32 +05:30
|
|
|
col1.set_resizable(True)
|
|
|
|
col2.set_resizable(True)
|
|
|
|
col3.set_resizable(True)
|
|
|
|
col4.set_resizable(True)
|
|
|
|
col1.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
|
|
|
|
col2.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
|
|
|
|
col3.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
|
|
|
|
col4.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
|
|
|
|
col1.set_sort_column_id(0)
|
|
|
|
# col2.set_sort_column_id(1)
|
|
|
|
# col3.set_sort_column_id(2)
|
|
|
|
col4.set_sort_column_id(3)
|
|
|
|
self.treeView.append_column(col1)
|
|
|
|
self.treeView.append_column(col2)
|
|
|
|
self.treeView.append_column(col3)
|
|
|
|
self.treeView.append_column(col4)
|
|
|
|
self.treeSelection = self.treeView.get_selection()
|
|
|
|
self.treeSelection.set_mode(gtk.SELECTION_MULTIPLE)
|
|
|
|
self.treeSelection.set_select_function(self.selectIsAllowed, full=True)
|
|
|
|
self.treeSelection.connect('changed', self.rowSelectionChanged)
|
|
|
|
self.treeView.connect('row-activated', self.rowActivated)
|
|
|
|
|
|
|
|
# initialize a few variables we're going to need
|
|
|
|
self.numberOfPeopleInDatabase = self.db.get_number_of_people()
|
|
|
|
self.numberOfRelatedPeople = 0
|
|
|
|
self.numberOfUnrelatedPeople = 0
|
|
|
|
|
|
|
|
# create the sets used to track related and unrelated people
|
|
|
|
self.handlesOfPeopleToBeProcessed = set()
|
|
|
|
self.handlesOfPeopleAlreadyProcessed = set()
|
|
|
|
self.handlesOfPeopleNotRelated = set()
|
|
|
|
|
|
|
|
# build a set of all people related to the selected person
|
|
|
|
self.handlesOfPeopleToBeProcessed.add(person.get_handle())
|
|
|
|
self.findRelatedPeople()
|
|
|
|
|
|
|
|
# now that we have our list of related people, find everyone
|
|
|
|
# in the database who isn't on our list
|
|
|
|
self.findUnrelatedPeople()
|
|
|
|
|
|
|
|
# populate the treeview model with the names of unrelated people
|
|
|
|
if self.numberOfUnrelatedPeople == 0:
|
2008-09-28 14:57:40 +05:30
|
|
|
title.set_text(_('Everyone in the database is related to %s') % self.name)
|
2008-02-21 12:49:32 +05:30
|
|
|
else:
|
|
|
|
self.populateModel()
|
|
|
|
self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
|
|
|
self.treeView.set_model(self.model)
|
|
|
|
# self.treeView.set_row_separator_func(self.iterIsSeparator)
|
|
|
|
self.treeView.expand_all()
|
|
|
|
|
|
|
|
# done searching through the database, so close the progress bar
|
|
|
|
self.progress.close()
|
|
|
|
|
|
|
|
self.show()
|
|
|
|
|
|
|
|
|
|
|
|
def iterIsSeparator(self, model, iter) :
|
|
|
|
# return True only if the row is to be treated as a separator
|
|
|
|
if self.model.get_value(iter, 1) == '': # does the row have a GID?
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def selectIsAllowed(self, selection, model, path, isSelected) :
|
|
|
|
# return True/False depending on if the row being selected is a leaf node
|
|
|
|
iter = self.model.get_iter(path)
|
|
|
|
if self.model.get_value(iter, 1) == '': # does the row have a GID?
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def rowSelectionChanged(self, selection) :
|
|
|
|
state = selection.count_selected_rows() > 0
|
2010-10-23 04:52:33 +05:30
|
|
|
self.tagcombo.set_sensitive(state)
|
|
|
|
self.tagapply.set_sensitive(state)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
|
|
|
|
def rowActivated(self, treeView, path, column) :
|
|
|
|
# first we need to check that the row corresponds to a person
|
|
|
|
iter = self.model.get_iter(path)
|
|
|
|
personGid = self.model.get_value(iter, 1)
|
|
|
|
familyGid = self.model.get_value(iter, 4)
|
|
|
|
|
|
|
|
if familyGid != '': # do we have a family?
|
|
|
|
# get the parent family for this person
|
|
|
|
family = self.db.get_family_from_gramps_id(familyGid)
|
|
|
|
if family:
|
|
|
|
try:
|
|
|
|
EditFamily(self.dbstate, self.uistate, [], family)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
elif personGid != '': # do we have a person?
|
|
|
|
# get the person that corresponds to this GID
|
|
|
|
person = self.db.get_person_from_gramps_id(personGid)
|
|
|
|
if person:
|
|
|
|
try:
|
|
|
|
EditPerson(self.dbstate, self.uistate, [], person)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2009-02-23 01:54:08 +05:30
|
|
|
|
2008-03-21 17:48:27 +05:30
|
|
|
def on_help_clicked(self, obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2008-04-05 19:47:15 +05:30
|
|
|
GrampsDisplay.help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
def applyTagClicked(self, button) :
|
2008-02-21 12:49:32 +05:30
|
|
|
progress = None
|
|
|
|
rows = self.treeSelection.count_selected_rows()
|
2010-10-23 04:52:33 +05:30
|
|
|
tag_name = self.tagcombo.get_active_text()
|
|
|
|
|
|
|
|
# start the db transaction
|
2011-02-20 16:22:06 +05:30
|
|
|
with DbTxn("Tag not related", self.db) as transaction:
|
2011-02-01 03:24:58 +05:30
|
|
|
|
|
|
|
tag = self.db.get_tag_from_name(tag_name)
|
|
|
|
if not tag:
|
|
|
|
# create the tag if it doesn't already exist
|
|
|
|
tag = Tag()
|
|
|
|
tag.set_name(tag_name)
|
|
|
|
tag.set_priority(self.db.get_number_of_tags())
|
|
|
|
tag_handle = self.db.add_tag(tag, transaction)
|
|
|
|
else:
|
|
|
|
tag_handle = tag.get_handle()
|
|
|
|
|
|
|
|
# if more than 1 person is selected, use a progress indicator
|
|
|
|
if rows > 1:
|
|
|
|
progress = ProgressMeter(self.title,_('Starting'))
|
|
|
|
#TRANS: no singular form needed, as rows is always > 1
|
|
|
|
progress.set_pass(ngettext("Setting tag for %d person",
|
|
|
|
"Setting tag for %d people",
|
|
|
|
rows) % rows, rows)
|
|
|
|
|
|
|
|
|
|
|
|
# iterate through all of the selected rows
|
|
|
|
(model, paths) = self.treeSelection.get_selected_rows()
|
|
|
|
|
|
|
|
for path in paths:
|
|
|
|
if progress:
|
|
|
|
progress.step()
|
|
|
|
|
|
|
|
# for the current row, get the GID and the person from the database
|
|
|
|
iter = self.model.get_iter(path)
|
|
|
|
personGid = self.model.get_value(iter, 1)
|
|
|
|
person = self.db.get_person_from_gramps_id(personGid)
|
|
|
|
|
|
|
|
# add the tag to the person
|
|
|
|
person.add_tag(tag_handle)
|
|
|
|
|
|
|
|
# save this change
|
|
|
|
self.db.commit_person(person, transaction)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
2010-10-23 04:52:33 +05:30
|
|
|
|
|
|
|
# refresh the tags column
|
|
|
|
self.treeView.set_model(None)
|
|
|
|
for path in paths:
|
|
|
|
iter = self.model.get_iter(path)
|
|
|
|
personGid = self.model.get_value(iter, 1)
|
|
|
|
person = self.db.get_person_from_gramps_id(personGid)
|
|
|
|
self.model.set_value(iter, 3, self.get_tag_list(person))
|
|
|
|
self.treeView.set_model(self.model)
|
|
|
|
self.treeView.expand_all()
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
if progress:
|
|
|
|
progress.close()
|
|
|
|
|
|
|
|
def findRelatedPeople(self) :
|
|
|
|
|
2009-08-23 13:09:29 +05:30
|
|
|
#TRANS: No singular form is needed.
|
2011-01-24 21:57:23 +05:30
|
|
|
self.progress.set_pass(
|
|
|
|
ngettext("Finding relationships between %d person",
|
|
|
|
"Finding relationships between %d people",
|
|
|
|
self.numberOfPeopleInDatabase) %
|
|
|
|
self.numberOfPeopleInDatabase,
|
|
|
|
self.numberOfPeopleInDatabase)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# as long as we have people we haven't processed yet, keep looping
|
|
|
|
while len(self.handlesOfPeopleToBeProcessed) > 0:
|
|
|
|
handle = self.handlesOfPeopleToBeProcessed.pop()
|
|
|
|
|
|
|
|
### DEBUG DEBUG DEBUG
|
|
|
|
# if len(self.handlesOfPeopleAlreadyProcessed) > 50:
|
|
|
|
# break
|
|
|
|
###
|
|
|
|
|
|
|
|
# see if we've already processed this person
|
|
|
|
if handle in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
continue
|
|
|
|
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
|
|
|
|
# if we get here, then we're dealing with someone new
|
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
# remember that we've now seen this person
|
|
|
|
self.handlesOfPeopleAlreadyProcessed.add(handle)
|
|
|
|
|
|
|
|
# we have 3 things to do: find (1) spouses, (2) parents, and (3) children
|
|
|
|
|
|
|
|
# step 1 -- spouses
|
|
|
|
for familyHandle in person.get_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(familyHandle)
|
|
|
|
spouseHandle = ReportUtils.find_spouse(person, family)
|
2009-04-14 00:26:50 +05:30
|
|
|
if spouseHandle and \
|
|
|
|
spouseHandle not in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
self.handlesOfPeopleToBeProcessed.add(spouseHandle)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# step 2 -- parents
|
|
|
|
for familyHandle in person.get_parent_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(familyHandle)
|
|
|
|
fatherHandle = family.get_father_handle()
|
|
|
|
motherHandle = family.get_mother_handle()
|
2009-04-14 00:26:50 +05:30
|
|
|
if fatherHandle and \
|
|
|
|
fatherHandle not in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
self.handlesOfPeopleToBeProcessed.add(fatherHandle)
|
|
|
|
if motherHandle and \
|
|
|
|
motherHandle not in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
self.handlesOfPeopleToBeProcessed.add(motherHandle)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# step 3 -- children
|
|
|
|
for familyHandle in person.get_family_handle_list():
|
|
|
|
family = self.db.get_family_from_handle(familyHandle)
|
|
|
|
for childRef in family.get_child_ref_list():
|
|
|
|
childHandle = childRef.ref
|
2009-04-14 00:26:50 +05:30
|
|
|
if childHandle and \
|
|
|
|
childHandle not in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
self.handlesOfPeopleToBeProcessed.add(childHandle)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
|
|
|
|
def findUnrelatedPeople(self) :
|
|
|
|
|
|
|
|
# update our numbers
|
2009-04-14 00:26:50 +05:30
|
|
|
self.numberOfRelatedPeople = len(self.handlesOfPeopleAlreadyProcessed)
|
2011-01-25 00:25:52 +05:30
|
|
|
self.numberOfUnrelatedPeople = (self.numberOfPeopleInDatabase -
|
|
|
|
self.numberOfRelatedPeople)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
if self.numberOfUnrelatedPeople > 0:
|
|
|
|
# we have at least 1 "unrelated" person to find
|
|
|
|
|
2011-01-24 21:57:23 +05:30
|
|
|
self.progress.set_pass(
|
|
|
|
ngettext("Looking for %d person", "Looking for %d people",
|
|
|
|
self.numberOfUnrelatedPeople) %
|
|
|
|
self.numberOfUnrelatedPeople,
|
2009-08-23 13:09:29 +05:30
|
|
|
self.numberOfPeopleInDatabase)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# loop through everyone in the database
|
2009-07-04 01:53:41 +05:30
|
|
|
for handle in self.db.iter_person_handles():
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
# if this person is related, then skip to the next one
|
|
|
|
if handle in self.handlesOfPeopleAlreadyProcessed:
|
|
|
|
continue
|
|
|
|
|
|
|
|
### DEBUG DEBUG DEBUG
|
|
|
|
# if len(self.handlesOfPeopleNotRelated) > 10:
|
|
|
|
# break
|
|
|
|
###
|
|
|
|
|
|
|
|
# if we get here, we have someone who is "not related"
|
|
|
|
self.handlesOfPeopleNotRelated.add(handle)
|
|
|
|
|
|
|
|
|
|
|
|
def populateModel(self) :
|
|
|
|
|
2011-01-24 21:57:23 +05:30
|
|
|
self.progress.set_pass(
|
|
|
|
ngettext("Looking up the name of %d person",
|
|
|
|
"Looking up the names of %d people",
|
|
|
|
self.numberOfUnrelatedPeople) %
|
|
|
|
self.numberOfUnrelatedPeople,
|
2009-08-23 13:09:29 +05:30
|
|
|
self.numberOfUnrelatedPeople)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# loop through the entire list of unrelated people
|
|
|
|
for handle in self.handlesOfPeopleNotRelated:
|
|
|
|
self.progress.step()
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
primaryname = person.get_primary_name()
|
|
|
|
surname = primaryname.get_surname()
|
|
|
|
name = primaryname.get_name()
|
|
|
|
gid = person.get_gramps_id()
|
2010-10-23 04:52:33 +05:30
|
|
|
|
|
|
|
# Retrieve the sorted tag list
|
|
|
|
tag_list = self.get_tag_list(person)
|
2008-02-21 12:49:32 +05:30
|
|
|
|
|
|
|
# find the names of the parents
|
|
|
|
familygid = ''
|
|
|
|
parentNames = ''
|
|
|
|
parentFamilyHandle = person.get_main_parents_family_handle()
|
|
|
|
if parentFamilyHandle:
|
|
|
|
parentFamily = self.db.get_family_from_handle(parentFamilyHandle)
|
|
|
|
familygid = parentFamily.get_gramps_id()
|
|
|
|
fatherName = None
|
|
|
|
motherName = None
|
|
|
|
fatherHandle = parentFamily.get_father_handle()
|
|
|
|
if fatherHandle:
|
|
|
|
father = self.db.get_person_from_handle(fatherHandle)
|
|
|
|
fatherName = father.get_primary_name().get_first_name()
|
|
|
|
motherHandle = parentFamily.get_mother_handle()
|
|
|
|
if motherHandle:
|
|
|
|
mother = self.db.get_person_from_handle(motherHandle)
|
|
|
|
motherName = mother.get_primary_name().get_first_name()
|
|
|
|
|
|
|
|
# now that we have the names, come up with a label we can use
|
|
|
|
if fatherName:
|
|
|
|
parentNames += fatherName
|
|
|
|
if fatherName and motherName:
|
|
|
|
parentNames += ' & '
|
|
|
|
if motherName:
|
|
|
|
parentNames += motherName
|
|
|
|
|
|
|
|
# get the surname node (or create it if it doesn't exist)
|
|
|
|
|
|
|
|
# start with the root
|
|
|
|
iter = self.model.get_iter_root()
|
|
|
|
# look for a node with a matching surname
|
|
|
|
while iter:
|
|
|
|
if self.model.get_value(iter, 0) == surname:
|
|
|
|
break;
|
|
|
|
iter = self.model.iter_next(iter)
|
|
|
|
|
|
|
|
# if we don't have a valid iter, then create a new top-level node
|
|
|
|
if not iter:
|
|
|
|
iter = self.model.append(None, [surname, '', '', '', ''])
|
|
|
|
|
|
|
|
# finally, we now get to add this person to the model
|
2010-10-23 04:52:33 +05:30
|
|
|
self.model.append(iter, [name, gid, parentNames, tag_list,
|
|
|
|
familygid])
|
2008-02-21 12:49:32 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2008-02-21 12:49:32 +05:30
|
|
|
return (self.title, None)
|
2010-10-23 04:52:33 +05:30
|
|
|
|
|
|
|
def get_tag_list(self, person):
|
|
|
|
"""
|
|
|
|
Return a sorted list of tag names for the given person.
|
|
|
|
"""
|
|
|
|
tags = []
|
|
|
|
for handle in person.get_tag_list():
|
|
|
|
tag = self.db.get_tag_from_handle(handle)
|
|
|
|
tags.append(tag.get_name())
|
|
|
|
tags.sort(key=locale.strxfrm)
|
|
|
|
return ', '.join(tags)
|
|
|
|
|
2008-03-30 10:02:52 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# NotRelatedOptions
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2010-05-01 09:42:42 +05:30
|
|
|
class NotRelatedOptions(tool.ToolOptions):
|
2008-03-30 10:02:52 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
def __init__(self, name, person_id=None):
|
|
|
|
""" Initialize the options class """
|
2010-05-01 09:42:42 +05:30
|
|
|
tool.ToolOptions.__init__(self, name, person_id)
|