fix goto_handle on row update

change placetreeview somewhat, further to discuss


svn: r14024
This commit is contained in:
Benny Malengier 2010-01-10 20:11:18 +00:00
parent b503fa2e25
commit 2a36355a8b
4 changed files with 36 additions and 11 deletions

View File

@ -222,7 +222,7 @@ class ListView(NavigationView):
mcol = self.model.marker_column()
column.add_attribute(self.renderer, 'foreground', mcol)
if self.markup_required and pair[1] != 0:
if self.markup_required:
column.add_attribute(self.renderer, 'markup', pair[1])
else:
column.add_attribute(self.renderer, 'text', pair[1])
@ -406,7 +406,9 @@ class ListView(NavigationView):
if parent_node:
parent_path = self.model.on_get_path(parent_node)
if parent_path:
self.list.expand_row(parent_path, False)
for i in range(len(parent_path)):
expand_path = tuple([x for x in parent_path[:i+1]])
self.list.expand_row(expand_path, False)
path = self.model.on_get_path(node)
if path:

View File

@ -92,7 +92,8 @@ class PlaceBaseView(ListView):
FILTER_TYPE = "Place"
QR_CATEGORY = CATEGORY_QR_PLACE
def __init__(self, dbstate, uistate, title, model, nav_group):
def __init__(self, dbstate, uistate, title, model, nav_group,
markup=False):
signal_map = {
'place-add' : self.row_add,
@ -116,7 +117,7 @@ class PlaceBaseView(ListView):
dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks, nav_group,
multiple=True,
filter_class=PlaceSidebarFilter)
filter_class=PlaceSidebarFilter, markup=markup)
config.connect("interface.filter",
self.filter_toggle)

View File

@ -28,6 +28,7 @@ Place tree model.
# python modules
#
#-------------------------------------------------------------------------
import cgi
import logging
_LOG = logging.getLogger(".gui.views.treemodels.placetreemodel")
@ -53,6 +54,16 @@ from gui.views.treemodels.treebasemodel import TreeBaseModel
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# Constants
#
#-------------------------------------------------------------------------
COUNTRYLEVELS = {
'default': [_('<Countries>'), _('<States>'), _('<Counties>'),
_('<Places>')]
}
#-------------------------------------------------------------------------
#
# PlaceTreeModel
@ -96,6 +107,7 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
# No primary location
level = [''] * 5
else:
#country, state, county, city, street
level = [data[5][0][i] for i in range(4,-1,-1)]
node1 = (level[0], )
@ -107,12 +119,15 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
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)
self.add_node(node2, node3, level[2], None, add_parent=False)
self.add_node(node3, 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)
self.add_node(node1, node2, level[1], None, add_parent=False)
self.add_node(node2, handle, level[1], handle, add_parent=False)
elif level[0]:
self.add_node(None, handle, level[0], handle, add_parent=False)
self.add_node(None, node1, level[0], None, add_parent=False)
self.add_node(node1, handle, level[0], handle, add_parent=False)
else:
self.add_node(None, handle, sort_key, handle, add_parent=False)
@ -123,7 +138,9 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
self.add_node(node3, handle, sort_key, handle, add_parent=False)
def column_name(self, data):
if data[5] is not None:
if data[2]:
return unicode(data[2])
elif 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])
@ -132,7 +149,7 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
elif level[3] or level[4]:
return unicode(level[3] or level[4])
else:
return unicode(data[2])
return u"<i>%s<i>" % cgi.escape(_("<no name>"))
return unicode(data[2])
def column_header(self, node):
@ -140,4 +157,9 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
Return a column heading. This is called for nodes with no associated
Gramps handle.
"""
return node.name
if node.name:
return '<i>%s</i>' % cgi.escape(node.name)
else:
level = len(self.on_get_path(node))
return '<i>%s</i>' % cgi.escape(COUNTRYLEVELS['default'][level])

View File

@ -55,7 +55,7 @@ class PlaceTreeView(PlaceBaseView):
def __init__(self, dbstate, uistate):
PlaceBaseView.__init__(self, dbstate, uistate,
_('Tree'), PlaceTreeModel,
nav_group=0)
nav_group=0, markup=True)
def type_list(self):
"""