Fix place format option in place report (#561)

* Fix place format option in place report

Resolves #10467.

* Use -1 instead of None for default place format

* adds New [Place format:] option on the [Report Options (2)] tab
This commit is contained in:
Nick Hall 2018-03-06 22:53:21 +00:00 committed by Sam Manzi
parent 433677c905
commit cf42e5a4b8
3 changed files with 10 additions and 8 deletions

View File

@ -75,7 +75,7 @@ class PlaceDisplay:
pf = PlaceFormat('Full', ':', '', 0, False)
self.place_formats.append(pf)
def display_event(self, db, event, fmt=None):
def display_event(self, db, event, fmt=-1):
if not event:
return ""
place_handle = event.get_place_handle()
@ -85,13 +85,13 @@ class PlaceDisplay:
else:
return ""
def display(self, db, place, date=None, fmt=None):
def display(self, db, place, date=None, fmt=-1):
if not place:
return ""
if not config.get('preferences.place-auto'):
return place.title
else:
if fmt is None:
if fmt == -1:
fmt = config.get('preferences.place-format')
pf = self.place_formats[fmt]
lang = pf.language

View File

@ -334,10 +334,9 @@ def add_place_format_option(menu, category):
Insert an option for changing the report's place format to a
report-specific format instead of the user's Edit=>Preferences choice
"""
place_format = EnumeratedListOption(_("Place format"), None)
place_format.add_item(None, _("Default"))
place_format = EnumeratedListOption(_("Place format"), -1)
place_format.add_item(-1, _("Default"))
for number, fmt in enumerate(_pd.get_formats()):
place_format.add_item(number, fmt.name)
place_format.set_help(_("Select the format to display places"))
menu.add_option(category, "place_format", place_format)
return place_format

View File

@ -198,7 +198,7 @@ class PlaceReport(Report):
place_names += ' (%s)' % place_name.get_language()
place_details += [self._("places|All Names: %s") % place_names,]
self.doc.start_paragraph("PLC-PlaceTitle")
place_title = _pd.display(self._db, place, self.place_format)
place_title = _pd.display(self._db, place, None, self.place_format)
self.doc.write_text(("%(nbr)s. %(place)s") % {'nbr' : place_nbr,
'place' : place_title})
self.doc.end_paragraph()
@ -427,7 +427,8 @@ class PlaceOptions(MenuReportOptions):
if subject:
subject += " + "
place = self.__db.get_place_from_gramps_id(place_id)
subject += _pd.display(self.__db, place, self.place_format)
subject += _pd.display(self.__db, place, None,
self.place_format)
return subject
def add_menu_options(self, menu):
@ -461,6 +462,8 @@ class PlaceOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category_name)
stdoptions.add_place_format_option(menu, category_name)
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_living_people_option(menu, category_name)