From 1d9e6da05ab4bab7bdb4ac527bde4d0a956d7b77 Mon Sep 17 00:00:00 2001 From: Zsolt Foldvari Date: Thu, 27 Jul 2006 11:53:47 +0000 Subject: [PATCH] * src/ViewManager.py (post_load_newdb): Upgrade path for different grdb custom name format table versions * src/NameDisplay.py (register_custom_formats): Upgrade path for different grdb custom name format table versions 2006-07-27 Zsolt Foldvari svn: r7084 --- ChangeLog | 6 ++++++ src/NameDisplay.py | 13 ++++++++++++- src/ViewManager.py | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40e16f915..69942f0cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-27 Zsolt Foldvari + * src/ViewManager.py (post_load_newdb): Upgrade path for different + grdb custom name format table versions + * src/NameDisplay.py (register_custom_formats): Upgrade path for + different grdb custom name format table versions + 2006-07-27 Zsolt Foldvari * src/GrampsCfg.py: Custom name format support improvements. * src/Editors/_EditName.py: Custom name format support improvements. diff --git a/src/NameDisplay.py b/src/NameDisplay.py index 6142fb0d0..1f54850cd 100644 --- a/src/NameDisplay.py +++ b/src/NameDisplay.py @@ -119,8 +119,19 @@ class NameDisplay: self.raw_fn_array[0] = self.raw_fn_array[idx] def register_custom_formats(self,formats): - self.CUSTOM_FORMATS = formats[:] + # magic is needed due to different name format table structure + # in different revisions: + # r <= 7082: (number, name, format_string) + # r >= 7083: (number, name, format_string, active) + self.CUSTOM_FORMATS = [] + changed = False + for format in formats: + if len(format) == 3: + format = format + (1,) + changed = True + self.CUSTOM_FORMATS.append(format) self.set_format_fn() + return changed def update_custom_formats(self,num,name,str,act): i = 0 diff --git a/src/ViewManager.py b/src/ViewManager.py index 2b5976609..7dcb0196d 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -768,7 +768,9 @@ class ViewManager: self.state.db.set_researcher(owner) self.setup_bookmarks() - NameDisplay.displayer.register_custom_formats(self.state.db.name_formats) + + if NameDisplay.displayer.register_custom_formats(self.state.db.name_formats): + self.state.db.name_formats = NameDisplay.displayer.CUSTOM_FORMATS fmt_default = Config.get(Config.NAME_FORMAT) if fmt_default < 0: NameDisplay.displayer.set_format_default(fmt_default)