Allow nodes with handles at higher levels in the tree

svn: r13921
This commit is contained in:
Nick Hall 2009-12-26 19:42:22 +00:00
parent e8042007ff
commit 5422931318
2 changed files with 52 additions and 39 deletions

View File

@ -86,37 +86,49 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
handle The handle of the gramps object.
data The object data.
"""
try:
level1 = data[5][0][4]
except TypeError:
level1 = _('Unknown level1')
if not level1:
level1 = _('Unknown level1')
try:
level2 = data[5][0][3]
except TypeError:
level2 = _('Unknown level2')
if not level2:
level2 = _('Unknown level2')
if data[5] is None:
# No primary location
level = [''] * 5
else:
level = [data[5][0][i] for i in range(4,-1,-1)]
try:
level3 = data[5][0][2]
except TypeError:
level3 = _('Unknown level3')
if not level3:
level3 = _('Unknown level3')
node1 = (level1, )
node2 = (level2, level1)
node3 = (level3, level2, level1)
node1 = (level[0], )
node2 = (level[1], level[0])
node3 = (level[2], level[1], level[0])
sort_key = self.sort_func(data)
self.add_node(None, node1, level1, None, add_parent=False)
self.add_node(node1, node2, level2, None, add_parent=False)
self.add_node(node2, node3, level3, None, add_parent=False)
self.add_node(node3, handle, sort_key, handle, add_parent=False)
if not (level[3] or level[4]):
if level[2]:
self.add_node(None, node1, level[0], None, add_parent=False)
self.add_node(node1, node2, level[1], None, add_parent=False)
self.add_node(node2, handle, level[2], handle, add_parent=False)
elif level[1]:
self.add_node(None, node1, level[0], None, add_parent=False)
self.add_node(node1, handle, level[1], handle, add_parent=False)
elif level[0]:
self.add_node(None, handle, level[0], handle, add_parent=False)
else:
self.add_node(None, handle, sort_key, handle, add_parent=False)
else:
self.add_node(None, node1, level[0], None, add_parent=False)
self.add_node(node1, node2, level[1], None, add_parent=False)
self.add_node(node2, node3, level[2], None, add_parent=False)
self.add_node(node3, handle, sort_key, handle, add_parent=False)
def column_name(self, data):
if data[5] is not None:
level = [data[5][0][i] for i in range(4,-1,-1)]
if not (level[3] or level[4]):
return unicode(level[2] or level[1] or level[0])
elif level[3] and level[4]:
return unicode(level[3] + ', ' + level[4])
elif level[3] or level[4]:
return unicode(level[3] or level[4])
else:
return unicode(data[2])
return unicode(data[2])
def column_header(self, node):
"""
Return a column heading. This is called for nodes with no associated

View File

@ -140,21 +140,22 @@ class PlaceTreeView(PlaceBaseView):
level1 = level2 = level3 = u""
if len(pathlist) == 1:
path = pathlist[0]
node = model.on_get_iter(path)
parent = model.on_iter_parent(node)
value = model.on_get_value(node, 0)
if len(path) == 1:
level1 = model.on_get_iter(path)[0]
level1 = value
elif len(path) == 2:
level2 = model.on_get_iter(path)[0]
level1 = model.on_get_iter(path)[1]
level2 = value
level1 = parent[0]
elif len(path) == 3:
node = model.on_get_iter(path)
level3 = node[0]
level2 = node[1]
level1 = model.on_iter_parent(node)[1]
level3 = value
level2 = parent[0]
level1 = parent[1]
else:
node = model.on_iter_parent(model.on_get_iter(path))
level3 = node[0]
level2 = node[1]
level1 = model.on_iter_parent(node)[1]
level3 = parent[0]
level2 = parent[1]
level1 = parent[2]
try:
place.get_main_location().set_country(level1)