Restrict Place view Name col to the primary name (#673)
while allowing searchbar to find alt and primary names related to Issue #9276 while allowing searchbar to find alt and primary names. Currently, the Place View and Place Selector name column shows a comma separated list of the primary and alt names for a place. With the advent of GeoNames and Gov data, the alt names lists are getting populated with (sometimes long) lists of (sometimes duplicated) names. This doesn't look very good in the view. I've gotten a couple of email complaints about this. The Name column was originally extended (for Gramps50) to include alt names to allow the use of the top search bar (enabled when sidebar is turned off via 'View/Sidebar'), to perform a search through all the alt names as well as primary name. https://gramps-project.org/bugs/view.php?id=9276 This PR creates a new (hidden) column in the place model containing the full name list, and reverts the 'Name' column to the primary name. It also modifies the PlaceSelector and PlaceView classes to cause the search bar to use the new (hidden) column.
This commit is contained in:
parent
d01afb3000
commit
bb1d59a29d
@ -74,5 +74,17 @@ class SelectPlace(BaseSelector):
|
||||
def get_from_handle_func(self):
|
||||
return self.db.get_place_from_handle
|
||||
|
||||
def setup_filter(self):
|
||||
"""Build the default filters and add them to the filter menu.
|
||||
This overrides the baseselector method because we use the hidden
|
||||
COL_SEARCH (11) that has alt names as well as primary name for name
|
||||
searching"""
|
||||
cols = [(pair[3],
|
||||
pair[1] if pair[1] else 11,
|
||||
pair[0] in self.exact_search())
|
||||
for pair in self.column_order() if pair[0]
|
||||
]
|
||||
self.search_bar.setup_filter(cols)
|
||||
|
||||
WIKI_HELP_PAGE = URL_MANUAL_SECT2
|
||||
WIKI_HELP_SEC = _('manual|Select_Place_selector')
|
||||
|
@ -81,7 +81,8 @@ class PlaceBaseModel:
|
||||
self.column_private,
|
||||
self.column_tags,
|
||||
self.column_change,
|
||||
self.column_tag_color
|
||||
self.column_tag_color,
|
||||
self.search_name,
|
||||
]
|
||||
self.smap = [
|
||||
self.column_name,
|
||||
@ -94,7 +95,8 @@ class PlaceBaseModel:
|
||||
self.column_private,
|
||||
self.column_tags,
|
||||
self.sort_change,
|
||||
self.column_tag_color
|
||||
self.column_tag_color,
|
||||
self.search_name,
|
||||
]
|
||||
|
||||
def destroy(self):
|
||||
@ -127,8 +129,13 @@ class PlaceBaseModel:
|
||||
return value
|
||||
|
||||
def column_name(self, data):
|
||||
# need for spacing on the french translation
|
||||
return _(',').join([data[6][0]] + [name[0] for name in data[7]])
|
||||
""" Return the primary name """
|
||||
return data[6][0]
|
||||
|
||||
def search_name(self, data):
|
||||
""" The search name includes all alt names to enable finding by alt name
|
||||
"""
|
||||
return ','.join([data[6][0]] + [name[0] for name in data[7]])
|
||||
|
||||
def column_longitude(self, data):
|
||||
if not data[3]:
|
||||
|
@ -79,6 +79,7 @@ class PlaceBaseView(ListView):
|
||||
COL_PRIV = 7
|
||||
COL_TAGS = 8
|
||||
COL_CHAN = 9
|
||||
COL_SEARCH = 11
|
||||
# column definitions
|
||||
COLUMNS = [
|
||||
(_('Name'), TEXT, None),
|
||||
@ -138,6 +139,17 @@ class PlaceBaseView(ListView):
|
||||
def navigation_type(self):
|
||||
return 'Place'
|
||||
|
||||
def setup_filter(self):
|
||||
"""Build the default filters and add them to the filter menu.
|
||||
This overrides the listview method because we use the hidden
|
||||
COL_SEARCH that has alt names as well as primary name for name
|
||||
searching"""
|
||||
self.search_bar.setup_filter(
|
||||
[(self.COLUMNS[pair[1]][0],
|
||||
self.COL_SEARCH if pair[1] == self.COL_NAME else pair[1],
|
||||
pair[1] in self.exact_search())
|
||||
for pair in self.column_order() if pair[0]])
|
||||
|
||||
def define_actions(self):
|
||||
ListView.define_actions(self)
|
||||
self._add_toolmenu_action('MapsList', _('Loading...'),
|
||||
|
Loading…
Reference in New Issue
Block a user