* src/Config/_GrampsConfigKeys.py: key for gen search depth
* src/GrampsCfg.py: Gramps preferences allows to set search depth of relationship. * src/Relationship.py: methods to change generation depth of search * src/plugins/rel_fr.py: remove depth use * src/plugins/all_relations.py: use depth, correct remark print error * src/plugins/rel_pl.py: remove depth use * src/DisplayState.py: hook to change relclass depth from GrampsCfg See also issue #1290 2007-11-22 Benny Malengier <benny.malengier@gramps-project.org> svn: r9385
This commit is contained in:
parent
0dca36536d
commit
28de76d2c0
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2007-11-22 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/Config/_GrampsConfigKeys.py: key for gen search depth
|
||||
* src/GrampsCfg.py: Gramps preferences allows to set search depth
|
||||
of relationship.
|
||||
* src/Relationship.py: methods to change generation depth of search
|
||||
* src/plugins/rel_fr.py: remove depth use
|
||||
* src/plugins/all_relations.py: use depth, correct remark print error
|
||||
* src/plugins/rel_pl.py: remove depth use
|
||||
* src/DisplayState.py: hook to change relclass depth from GrampsCfg
|
||||
See also issue #1290
|
||||
|
||||
2007-11-22 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/Relationship.py: remove old methods that are no longer used,
|
||||
get_relationship() and get_relationship_distance()
|
||||
|
@ -159,6 +159,7 @@ MAX_AGE_PROB_ALIVE = ('behavior', 'max-age-prob-alive', 1)
|
||||
MAX_SIB_AGE_DIFF = ('behavior', 'max-sib-age-diff', 1)
|
||||
MIN_GENERATION_YEARS = ('behavior', 'min-generation-years', 1)
|
||||
AVG_GENERATION_GAP = ('behavior', 'avg-generation-gap', 1)
|
||||
GENERATION_DEPTH = ('behavior', 'generation-depth', 1)
|
||||
|
||||
default_value = {
|
||||
DEFAULT_SOURCE : False,
|
||||
@ -274,4 +275,5 @@ default_value = {
|
||||
MAX_SIB_AGE_DIFF : 20,
|
||||
MIN_GENERATION_YEARS : 13,
|
||||
AVG_GENERATION_GAP : 20,
|
||||
GENERATION_DEPTH : 15,
|
||||
}
|
||||
|
@ -342,6 +342,14 @@ class DisplayState(gen.utils.GrampsDBCallback):
|
||||
Should be called after load or reload of plugins
|
||||
"""
|
||||
self.relationship = _PluginMgr.relationship_class()
|
||||
|
||||
def set_gendepth(self, value):
|
||||
""" Set the generations we search back for showing relationships
|
||||
on GRAMPS interface. Value must be integer > 0
|
||||
This method will be used by the preference editor when user changes
|
||||
the generations.
|
||||
"""
|
||||
self.relationship.set_depth(value)
|
||||
|
||||
def display_relationship(self, dbstate):
|
||||
''' Construct the relationship in order to show it in the statusbar
|
||||
|
@ -519,6 +519,9 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
||||
4, Config.RELEDITBTN)
|
||||
self.add_checkbox(table, _('Remember last view displayed'),
|
||||
5, Config.USE_LAST_VIEW)
|
||||
self.add_pos_int_entry(table,
|
||||
_('Number of generations for relationship determination'),
|
||||
6, Config.GENERATION_DEPTH, self.update_gen_depth)
|
||||
|
||||
return table
|
||||
|
||||
@ -552,6 +555,18 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
||||
xoptions=gtk.FILL)
|
||||
table.attach(entry, 1, 2, index, index+1, yoptions=0)
|
||||
|
||||
def add_pos_int_entry(self, table, label, index, constant, callback=None):
|
||||
''' entry field for positive integers
|
||||
'''
|
||||
lwidget = BasicLabel("%s: " % label)
|
||||
entry = gtk.Entry()
|
||||
entry.set_text(str(Config.get(constant)))
|
||||
if callback:
|
||||
entry.connect('changed', callback, constant)
|
||||
table.attach(lwidget, 1, 2, index, index+1, yoptions=0,
|
||||
xoptions=gtk.FILL)
|
||||
table.attach(entry, 2, 3, index, index+1, yoptions=0)
|
||||
|
||||
def add_color(self, table, label, index, constant):
|
||||
lwidget = BasicLabel("%s: " % label)
|
||||
hexval = Config.get(constant)
|
||||
@ -568,6 +583,25 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
|
||||
def update_entry(self, obj, constant):
|
||||
Config.set(constant, unicode(obj.get_text()))
|
||||
|
||||
def update_gen_depth(self, obj, constant):
|
||||
ok = True
|
||||
if not obj.get_text():
|
||||
return
|
||||
try:
|
||||
intval = int(obj.get_text())
|
||||
except:
|
||||
intval = Config.get(constant)
|
||||
ok = False
|
||||
if intval < 0 :
|
||||
intval = Config.get(constant)
|
||||
ok = False
|
||||
if ok:
|
||||
Config.set(constant, intval)
|
||||
#immediately use this value in displaystate.
|
||||
self.uistate.set_gendepth(intval)
|
||||
else:
|
||||
obj.set_text(str(intval))
|
||||
|
||||
def update_color(self, obj, constant, color_hex_label):
|
||||
color = obj.get_color()
|
||||
hexval = "#%02x%02x%02x" % (color.red/256,
|
||||
|
@ -30,6 +30,7 @@ import gen.lib
|
||||
import types
|
||||
from TransUtils import sgettext as _
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -339,7 +340,6 @@ _nephews_nieces_level = [ "",
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
MAX_DEPTH = 15
|
||||
|
||||
class RelationshipCalculator:
|
||||
|
||||
@ -386,6 +386,26 @@ class RelationshipCalculator:
|
||||
self.map_handle = None
|
||||
self.map_meta = None
|
||||
self.__db_connected = False
|
||||
self.depth = 15
|
||||
try:
|
||||
import Config
|
||||
self.set_depth(Config.get(Config.GENERATION_DEPTH))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
def set_depth(self, depth):
|
||||
''' set how deep relationships must be searched. Input must be an
|
||||
integer > 0
|
||||
'''
|
||||
if not depth == self.depth:
|
||||
self.depth = depth
|
||||
self.dirtymap = True
|
||||
|
||||
def get_depth(self):
|
||||
''' obtain depth of relationship search
|
||||
'''
|
||||
return self.depth
|
||||
|
||||
|
||||
DIST_FATHER = "distant %(step)sancestor%(inlaw)s (%(level)d generations)"
|
||||
|
||||
@ -628,8 +648,7 @@ class RelationshipCalculator:
|
||||
other_person,
|
||||
all_families=False,
|
||||
all_dist=False,
|
||||
only_birth=True,
|
||||
max_depth = MAX_DEPTH):
|
||||
only_birth=True):
|
||||
"""
|
||||
Returns if all_dist == True a 'tuple, string':
|
||||
(rank, person handle, firstRel_str, firstRel_fam,
|
||||
@ -680,13 +699,11 @@ class RelationshipCalculator:
|
||||
@param only_birth: if True only parents with birth relation are
|
||||
considered
|
||||
@type only_birth: bool
|
||||
@param max_depth: how many generations deep do we search?
|
||||
@type max_depth: int
|
||||
"""
|
||||
#data storage to communicate with recursive functions
|
||||
self.__maxDepthReached = False
|
||||
self.__loopDetected = False
|
||||
self.__max_depth = max_depth
|
||||
self.__max_depth = self.get_depth()
|
||||
self.__all_families = all_families
|
||||
self.__all_dist = all_dist
|
||||
self.__only_birth = only_birth
|
||||
@ -711,16 +728,17 @@ class RelationshipCalculator:
|
||||
and not self.dirtymap):
|
||||
firstMap = self.stored_map
|
||||
self.__maxDepthReached, self.__loopDetected, \
|
||||
self.__max_depth, self.__all_families,\
|
||||
self.__all_families,\
|
||||
self.__all_dist, self.__only_birth,\
|
||||
self.__crosslinks, self.__msg = self.map_meta
|
||||
self.__msg = list(self.__msg)
|
||||
else:
|
||||
self.__apply_filter(db, orig_person, '', [], firstMap)
|
||||
self.map_meta = (self.__maxDepthReached,
|
||||
self.__loopDetected,
|
||||
self.__max_depth, self.__all_families,
|
||||
self.__all_families,
|
||||
self.__all_dist, self.__only_birth,
|
||||
self.__crosslinks, self.__msg)
|
||||
self.__crosslinks, list(self.__msg))
|
||||
self.__apply_filter(db, other_person, '', [], secondMap,
|
||||
stoprecursemap = firstMap)
|
||||
except RuntimeError:
|
||||
@ -784,7 +802,7 @@ class RelationshipCalculator:
|
||||
if self.__maxDepthReached :
|
||||
self.__msg += [_('Family tree reaches back more than the maximum '
|
||||
'%d generations searched.\nIt is possible that '
|
||||
'relationships have been missed') % (max_depth)]
|
||||
'relationships have been missed') % (self.__max_depth)]
|
||||
|
||||
if common and not self.__all_dist :
|
||||
rank = common[0][0]
|
||||
@ -823,9 +841,9 @@ class RelationshipCalculator:
|
||||
|
||||
if depth > self.__max_depth:
|
||||
self.__maxDepthReached = True
|
||||
print 'Maximum ancestor generations ('+str(depth)+') reached', \
|
||||
'(' + rel_str + ').',\
|
||||
'Stopping relation algorithm.'
|
||||
#print 'Maximum ancestor generations ('+str(depth)+') reached', \
|
||||
# '(' + rel_str + ').',\
|
||||
# 'Stopping relation algorithm.'
|
||||
return
|
||||
depth += 1
|
||||
|
||||
|
@ -95,8 +95,7 @@ class AllRelReport():
|
||||
self.database, self.person, self.home_person,
|
||||
all_families=True,
|
||||
all_dist=True,
|
||||
only_birth=False,
|
||||
max_depth=20)
|
||||
only_birth=False)
|
||||
#all relations
|
||||
if (not common or common[0][0]== -1 ) and not is_spouse:
|
||||
rstr = _("%(person)s and %(active_person)s are not "
|
||||
@ -143,10 +142,9 @@ class AllRelReport():
|
||||
self.database, inlawpers, inlawhome,
|
||||
all_families=True,
|
||||
all_dist=True,
|
||||
only_birth=False,
|
||||
max_depth=20)
|
||||
only_birth=False)
|
||||
if msg:
|
||||
self.msg_list.append(msg)
|
||||
self.msg_list += msg
|
||||
if common and not common[0][0] == -1:
|
||||
if not inlawwritten:
|
||||
rstr = _("%(person)s and %(active_person)s have "
|
||||
@ -180,7 +178,7 @@ class AllRelReport():
|
||||
inlawa = inlawa, inlawb = inlawb,
|
||||
count = count, skip_list = skip,
|
||||
first = False)
|
||||
self.remarks(self.msg_list)
|
||||
self.remarks(self.msg_list, True)
|
||||
|
||||
def get_inlaws(self, person):
|
||||
inlaws = []
|
||||
@ -324,13 +322,17 @@ class AllRelReport():
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def remarks(self, msg_list):
|
||||
def remarks(self, msg_list, inlaw=False):
|
||||
if msg_list :
|
||||
sdoc = self.sdoc
|
||||
sdoc.paragraph("")
|
||||
sdoc.header1(_("Remarks"))
|
||||
if inlaw:
|
||||
sdoc.header1(_("Remarks with inlaw family"))
|
||||
else:
|
||||
sdoc.header1(_("Remarks"))
|
||||
sdoc.paragraph("")
|
||||
sdoc.paragraph(_("The following problems where encountered:"))
|
||||
|
||||
for msg in msg_list :
|
||||
sdoc.paragraph(msg)
|
||||
sdoc.paragraph("")
|
||||
|
@ -125,8 +125,6 @@ _nephews_nieces_level = [ "", "les neveux et les nièces",
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
MAX_DEPTH = 15
|
||||
|
||||
class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
|
||||
#sibling strings
|
||||
|
@ -494,7 +494,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
""" DEPRECATED -- DO NOT USE
|
||||
copied here from Relationship.py as no longer needed elsewhere
|
||||
"""
|
||||
if person == None or depth > MAX_DEPTH:
|
||||
if person == None or depth > 15:
|
||||
return
|
||||
depth += 1
|
||||
plist.append(person.handle)
|
||||
|
Loading…
Reference in New Issue
Block a user