diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index b2698b96c..986c35212 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -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: diff --git a/src/gui/views/placebaseview.py b/src/gui/views/placebaseview.py index b435d873f..c53e2db81 100644 --- a/src/gui/views/placebaseview.py +++ b/src/gui/views/placebaseview.py @@ -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) diff --git a/src/gui/views/treemodels/placetreemodel.py b/src/gui/views/treemodels/placetreemodel.py index 913fe0c8f..9bf307593 100644 --- a/src/gui/views/treemodels/placetreemodel.py +++ b/src/gui/views/treemodels/placetreemodel.py @@ -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': [_(''), _(''), _(''), + _('')] +} + #------------------------------------------------------------------------- # # 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"%s" % cgi.escape(_("")) 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 '%s' % cgi.escape(node.name) + else: + level = len(self.on_get_path(node)) + return '%s' % cgi.escape(COUNTRYLEVELS['default'][level]) + diff --git a/src/plugins/view/placetreeview.py b/src/plugins/view/placetreeview.py index aa6205fa4..6140b7627 100644 --- a/src/plugins/view/placetreeview.py +++ b/src/plugins/view/placetreeview.py @@ -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): """