From 2de7b58b657ceae3927892a290f0712607b77fa5 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 20 Oct 2001 15:03:23 +0000 Subject: [PATCH] Fixed sort.by_birthdate and added the ability to provide a template for IDs svn: r501 --- gramps/src/Config.py | 69 ++++++++- gramps/src/RelLib.py | 42 ++++-- gramps/src/config.glade | 303 ++++++++++++++++++++++++++++++++++++++ gramps/src/gramps_main.py | 7 +- gramps/src/sort.py | 14 ++ 5 files changed, 422 insertions(+), 13 deletions(-) diff --git a/gramps/src/Config.py b/gramps/src/Config.py index 42b0002e6..11f46a694 100644 --- a/gramps/src/Config.py +++ b/gramps/src/Config.py @@ -90,6 +90,11 @@ _name_format_list = [ owner = Researcher() prefsTop = None +iprefix = "I" +oprefix = "O" +sprefix = "S" +pprefix = "P" +fprefix = "F" autoload = 0 usetabs = 0 usevc = 0 @@ -153,6 +158,11 @@ def loadConfig(call): global owner global usetabs global usevc + global iprefix + global fprefix + global pprefix + global oprefix + global sprefix global vc_comment global uncompress global id_visible @@ -194,6 +204,12 @@ def loadConfig(call): output_preference = gnome.config.get_string("/gramps/config/outputPreference") _name_format = gnome.config.get_int("/gramps/config/nameFormat") + iprefix = gnome.config.get_string("/gramps/config/iprefix") + fprefix = gnome.config.get_string("/gramps/config/fprefix") + sprefix = gnome.config.get_string("/gramps/config/sprefix") + oprefix = gnome.config.get_string("/gramps/config/oprefix") + pprefix = gnome.config.get_string("/gramps/config/pprefix") + report_dir = gnome.config.get_string("/gramps/config/ReportDirectory") web_dir = gnome.config.get_string("/gramps/config/WebsiteDirectory") db_dir = gnome.config.get_string("/gramps/config/DbDirectory") @@ -239,6 +255,17 @@ def loadConfig(call): if output_preference == None: output_preference = "OpenOffice" + if iprefix == None: + iprefix = "I" + if fprefix == None: + fprefix = "F" + if sprefix == None: + sprefix = "S" + if pprefix == None: + pprefix = "P" + if oprefix == None: + oprefix = "O" + if display_attr == None: display_attr = 0 @@ -359,6 +386,11 @@ def on_propertybox_apply(obj,page): global owner global usetabs global usevc + global iprefix + global fprefix + global pprefix + global sprefix + global oprefix global vc_comment global uncompress global id_visible @@ -398,6 +430,22 @@ def on_propertybox_apply(obj,page): else: status_bar = 2 + iprefix = prefsTop.get_widget("iprefix").get_text() + if iprefix == "": + iprefix = "I" + sprefix = prefsTop.get_widget("sprefix").get_text() + if sprefix == "": + sprefix = "S" + oprefix = prefsTop.get_widget("oprefix").get_text() + if oprefix == "": + oprefix = "O" + fprefix = prefsTop.get_widget("fprefix").get_text() + if fprefix == "": + fprefix = "F" + pprefix = prefsTop.get_widget("pprefix").get_text() + if pprefix == "": + pprefix = "P" + dbdir_temp = prefsTop.get_widget("dbdir").get_full_path(1) if dbdir_temp != None and os.path.isdir(dbdir_temp): db_dir = os.path.normpath(dbdir_temp) + os.sep @@ -430,6 +478,11 @@ def on_propertybox_apply(obj,page): gnome.config.set_string("/gramps/config/ReportDirectory",report_dir) gnome.config.set_string("/gramps/config/WebsiteDirectory",web_dir) gnome.config.set_string("/gramps/config/DbDirectory",db_dir) + gnome.config.set_string("/gramps/config/iprefix",iprefix) + gnome.config.set_string("/gramps/config/fprefix",fprefix) + gnome.config.set_string("/gramps/config/pprefix",pprefix) + gnome.config.set_string("/gramps/config/oprefix",oprefix) + gnome.config.set_string("/gramps/config/sprefix",sprefix) # search for the active date format selection @@ -479,6 +532,13 @@ def on_propertybox_apply(obj,page): owner.set(name,addr,city,state,country,postal,phone,email) store_researcher(owner) + db = obj.get_data("db") + db.set_iprefix(iprefix) + db.set_fprefix(fprefix) + db.set_sprefix(sprefix) + db.set_oprefix(oprefix) + db.set_pprefix(pprefix) + # update the config file gnome.config.sync() @@ -540,7 +600,7 @@ def on_color_set(obj,r,g,b,a): # Create the property box, and set the elements off the current values # #------------------------------------------------------------------------- -def display_preferences_box(): +def display_preferences_box(db): global prefsTop prefsTop = libglade.GladeXML(const.configFile,"propertybox") @@ -554,6 +614,7 @@ def display_preferences_box(): }) pbox = prefsTop.get_widget("propertybox") + pbox.set_data("db",db) auto = prefsTop.get_widget("autoload") vis = prefsTop.get_widget("gid_visible") idedit = prefsTop.get_widget("gid_edit") @@ -573,6 +634,12 @@ def display_preferences_box(): vis.set_active(id_visible) idedit.set_active(id_edit) + prefsTop.get_widget("iprefix").set_text(iprefix) + prefsTop.get_widget("oprefix").set_text(oprefix) + prefsTop.get_widget("fprefix").set_text(fprefix) + prefsTop.get_widget("sprefix").set_text(sprefix) + prefsTop.get_widget("pprefix").set_text(pprefix) + if status_bar == 0: prefsTop.get_widget("stat1").set_active(1) elif status_bar == 1: diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index 3e37f7f11..a07c693d9 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -1019,7 +1019,7 @@ class Event(DataObj): return 0 if self.place != other.place: return 0 - if compare_dates(self.date,other.date): + if compare_dates(self.getDateObj(),other.getDateObj()): return 0 if self.description != other.description: return 0 @@ -1453,6 +1453,26 @@ class RelDataBase: def __init__(self): """creates a new RelDataBase""" self.new() + self.iprefix = "I%d" + self.sprefix = "S%d" + self.oprefix = "O%d" + self.pprefix = "P%d" + self.fprefix = "F%d" + + def set_iprefix(self,val): + self.iprefix = val + "%d" + + def set_sprefix(self,val): + self.sprefix = val + "%d" + + def set_oprefix(self,val): + self.oprefix = val + "%d" + + def set_pprefix(self,val): + self.pprefix = val + "%d" + + def set_fprefix(self,val): + self.fprefix = val + "%d" def new(self): """initializes the RelDataBase to empty values""" @@ -1592,10 +1612,10 @@ class RelDataBase: def addPerson(self,person): """adds a Person to the database, assigning a gramps' ID""" - index = "I%d" % self.pmapIndex + index = self.iprefix % self.pmapIndex while self.personMap.has_key(index): self.pmapIndex = self.pmapIndex + 1 - index = "I%d" % self.pmapIndex + index = self.iprefix % self.pmapIndex person.setId(index) self.personMap[index] = person self.pmapIndex = self.pmapIndex + 1 @@ -1643,10 +1663,10 @@ class RelDataBase: """adds a Source instance to the database, assigning it a gramps' ID number""" - index = "S%d" % self.smapIndex + index = self.sprefix % self.smapIndex while self.sourceMap.has_key(index): self.smapIndex = self.smapIndex + 1 - index = "S%d" % self.smapIndex + index = self.sprefix % self.smapIndex source.setId(index) self.sourceMap[index] = source self.smapIndex = self.smapIndex + 1 @@ -1693,10 +1713,10 @@ class RelDataBase: """adds an Object instance to the database, assigning it a gramps' ID number""" - index = "O%d" % self.omapIndex + index = self.oprefix % self.omapIndex while self.objectMap.has_key(index): self.omapIndex = self.omapIndex + 1 - index = "O%d" % self.omapIndex + index = self.oprefix % self.omapIndex object.setId(index) self.objectMap[index] = object self.omapIndex = self.omapIndex + 1 @@ -1743,10 +1763,10 @@ class RelDataBase: """adds a Place instance to the database, assigning it a gramps' ID number""" - index = "P%d" % self.lmapIndex + index = self.pprefix % self.lmapIndex while self.placeMap.has_key(index): self.lmapIndex = self.lmapIndex + 1 - index = "P%d" % self.lmapIndex + index = self.pprefix % self.lmapIndex place.setId(index) self.placeMap[index] = place self.lmapIndex = self.lmapIndex + 1 @@ -1792,10 +1812,10 @@ class RelDataBase: def newFamily(self): """adds a Family to the database, assigning a gramps' ID""" - index = "F%d" % self.fmapIndex + index = self.fprefix % self.fmapIndex while self.familyMap.has_key(index): self.fmapIndex = self.fmapIndex + 1 - index = "F%d" % self.fmapIndex + index = self.fprefix % self.fmapIndex self.fmapIndex = self.fmapIndex + 1 family = Family() family.setId(index) diff --git a/gramps/src/config.glade b/gramps/src/config.glade index 3777870bb..36c301f3a 100644 --- a/gramps/src/config.glade +++ b/gramps/src/config.glade @@ -585,6 +585,309 @@ + + + GtkFrame + frame9 + + 0 + GTK_SHADOW_ETCHED_IN + + 5 + True + True + + + + GtkTable + table28 + 3 + 4 + False + 0 + 0 + + + GtkLabel + label210 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 2 + 2 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkEntry + iprefix + True + + changed + on_object_toggled + propertybox + Sat, 20 Oct 2001 13:59:28 GMT + + True + True + 0 + I + + 1 + 2 + 0 + 1 + 2 + 2 + True + False + False + False + True + False + + + + + GtkEntry + sprefix + True + + changed + on_object_toggled + propertybox + Sat, 20 Oct 2001 14:00:46 GMT + + True + True + 0 + S + + 3 + 4 + 0 + 1 + 2 + 2 + True + False + False + False + True + False + + + + + GtkEntry + fprefix + True + + changed + on_object_toggled + propertybox + Sat, 20 Oct 2001 14:00:26 GMT + + True + True + 0 + F + + 1 + 2 + 1 + 2 + 2 + 2 + True + False + False + False + True + False + + + + + GtkEntry + oprefix + True + + changed + on_object_toggled + propertybox + Sat, 20 Oct 2001 14:01:09 GMT + + True + True + 0 + O + + 3 + 4 + 1 + 2 + 2 + 2 + True + False + False + False + True + False + + + + + GtkEntry + pprefix + True + + changed + on_object_toggled + propertybox + Sat, 20 Oct 2001 14:00:13 GMT + + True + True + 0 + P + + 1 + 2 + 2 + 3 + 2 + 2 + True + False + False + False + True + False + + + + + GtkLabel + label211 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 2 + 2 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label212 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 2 + 2 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label213 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 2 + 2 + + 2 + 3 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label214 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 2 + 2 + + 2 + 3 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + + + + diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 7b3df465d..6b55aa27d 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -2039,7 +2039,7 @@ def import_callback(obj,plugin_function): # #------------------------------------------------------------------------- def on_preferences_activate(obj): - Config.display_preferences_box() + Config.display_preferences_box(database) #------------------------------------------------------------------------- # @@ -2627,6 +2627,11 @@ def main(arg): person_list.set_column_visibility(1,Config.id_visible) notebook.set_show_tabs(Config.usetabs) + database.set_iprefix(Config.iprefix) + database.set_oprefix(Config.oprefix) + database.set_fprefix(Config.fprefix) + database.set_sprefix(Config.sprefix) + database.set_pprefix(Config.pprefix) child_list = gtop.get_widget("child_list") child_list.set_column_visibility(4,Config.show_detail) child_list.set_column_visibility(6,0) diff --git a/gramps/src/sort.py b/gramps/src/sort.py index 324df648a..e36737437 100644 --- a/gramps/src/sort.py +++ b/gramps/src/sort.py @@ -158,3 +158,17 @@ def by_last_name(first, second) : #------------------------------------------------------------------------- def by_last_name_backwards(first, second) : return by_last_name(second,first) + +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- +def by_birthdate(first, second) : + + date1 = first.getBirth().getDateObj() + date2 = second.getBirth().getDateObj() + val = compare_dates(date1,date2) + if val == 0: + return by_last_name(first,second) + return val