Fixed sort.by_birthdate and added the ability to provide a template for IDs

svn: r501
This commit is contained in:
Don Allingham 2001-10-20 15:03:23 +00:00
parent 2c265bc418
commit 58d5c07ce0
5 changed files with 422 additions and 13 deletions

View File

@ -90,6 +90,11 @@ _name_format_list = [
owner = Researcher() owner = Researcher()
prefsTop = None prefsTop = None
iprefix = "I"
oprefix = "O"
sprefix = "S"
pprefix = "P"
fprefix = "F"
autoload = 0 autoload = 0
usetabs = 0 usetabs = 0
usevc = 0 usevc = 0
@ -153,6 +158,11 @@ def loadConfig(call):
global owner global owner
global usetabs global usetabs
global usevc global usevc
global iprefix
global fprefix
global pprefix
global oprefix
global sprefix
global vc_comment global vc_comment
global uncompress global uncompress
global id_visible global id_visible
@ -194,6 +204,12 @@ def loadConfig(call):
output_preference = gnome.config.get_string("/gramps/config/outputPreference") output_preference = gnome.config.get_string("/gramps/config/outputPreference")
_name_format = gnome.config.get_int("/gramps/config/nameFormat") _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") report_dir = gnome.config.get_string("/gramps/config/ReportDirectory")
web_dir = gnome.config.get_string("/gramps/config/WebsiteDirectory") web_dir = gnome.config.get_string("/gramps/config/WebsiteDirectory")
db_dir = gnome.config.get_string("/gramps/config/DbDirectory") db_dir = gnome.config.get_string("/gramps/config/DbDirectory")
@ -239,6 +255,17 @@ def loadConfig(call):
if output_preference == None: if output_preference == None:
output_preference = "OpenOffice" 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: if display_attr == None:
display_attr = 0 display_attr = 0
@ -359,6 +386,11 @@ def on_propertybox_apply(obj,page):
global owner global owner
global usetabs global usetabs
global usevc global usevc
global iprefix
global fprefix
global pprefix
global sprefix
global oprefix
global vc_comment global vc_comment
global uncompress global uncompress
global id_visible global id_visible
@ -398,6 +430,22 @@ def on_propertybox_apply(obj,page):
else: else:
status_bar = 2 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) dbdir_temp = prefsTop.get_widget("dbdir").get_full_path(1)
if dbdir_temp != None and os.path.isdir(dbdir_temp): if dbdir_temp != None and os.path.isdir(dbdir_temp):
db_dir = os.path.normpath(dbdir_temp) + os.sep 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/ReportDirectory",report_dir)
gnome.config.set_string("/gramps/config/WebsiteDirectory",web_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/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 # 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) owner.set(name,addr,city,state,country,postal,phone,email)
store_researcher(owner) 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 # update the config file
gnome.config.sync() 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 # Create the property box, and set the elements off the current values
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def display_preferences_box(): def display_preferences_box(db):
global prefsTop global prefsTop
prefsTop = libglade.GladeXML(const.configFile,"propertybox") prefsTop = libglade.GladeXML(const.configFile,"propertybox")
@ -554,6 +614,7 @@ def display_preferences_box():
}) })
pbox = prefsTop.get_widget("propertybox") pbox = prefsTop.get_widget("propertybox")
pbox.set_data("db",db)
auto = prefsTop.get_widget("autoload") auto = prefsTop.get_widget("autoload")
vis = prefsTop.get_widget("gid_visible") vis = prefsTop.get_widget("gid_visible")
idedit = prefsTop.get_widget("gid_edit") idedit = prefsTop.get_widget("gid_edit")
@ -573,6 +634,12 @@ def display_preferences_box():
vis.set_active(id_visible) vis.set_active(id_visible)
idedit.set_active(id_edit) 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: if status_bar == 0:
prefsTop.get_widget("stat1").set_active(1) prefsTop.get_widget("stat1").set_active(1)
elif status_bar == 1: elif status_bar == 1:

View File

@ -1019,7 +1019,7 @@ class Event(DataObj):
return 0 return 0
if self.place != other.place: if self.place != other.place:
return 0 return 0
if compare_dates(self.date,other.date): if compare_dates(self.getDateObj(),other.getDateObj()):
return 0 return 0
if self.description != other.description: if self.description != other.description:
return 0 return 0
@ -1453,6 +1453,26 @@ class RelDataBase:
def __init__(self): def __init__(self):
"""creates a new RelDataBase""" """creates a new RelDataBase"""
self.new() 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): def new(self):
"""initializes the RelDataBase to empty values""" """initializes the RelDataBase to empty values"""
@ -1592,10 +1612,10 @@ class RelDataBase:
def addPerson(self,person): def addPerson(self,person):
"""adds a Person to the database, assigning a gramps' ID""" """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): while self.personMap.has_key(index):
self.pmapIndex = self.pmapIndex + 1 self.pmapIndex = self.pmapIndex + 1
index = "I%d" % self.pmapIndex index = self.iprefix % self.pmapIndex
person.setId(index) person.setId(index)
self.personMap[index] = person self.personMap[index] = person
self.pmapIndex = self.pmapIndex + 1 self.pmapIndex = self.pmapIndex + 1
@ -1643,10 +1663,10 @@ class RelDataBase:
"""adds a Source instance to the database, assigning it a gramps' """adds a Source instance to the database, assigning it a gramps'
ID number""" ID number"""
index = "S%d" % self.smapIndex index = self.sprefix % self.smapIndex
while self.sourceMap.has_key(index): while self.sourceMap.has_key(index):
self.smapIndex = self.smapIndex + 1 self.smapIndex = self.smapIndex + 1
index = "S%d" % self.smapIndex index = self.sprefix % self.smapIndex
source.setId(index) source.setId(index)
self.sourceMap[index] = source self.sourceMap[index] = source
self.smapIndex = self.smapIndex + 1 self.smapIndex = self.smapIndex + 1
@ -1693,10 +1713,10 @@ class RelDataBase:
"""adds an Object instance to the database, assigning it a gramps' """adds an Object instance to the database, assigning it a gramps'
ID number""" ID number"""
index = "O%d" % self.omapIndex index = self.oprefix % self.omapIndex
while self.objectMap.has_key(index): while self.objectMap.has_key(index):
self.omapIndex = self.omapIndex + 1 self.omapIndex = self.omapIndex + 1
index = "O%d" % self.omapIndex index = self.oprefix % self.omapIndex
object.setId(index) object.setId(index)
self.objectMap[index] = object self.objectMap[index] = object
self.omapIndex = self.omapIndex + 1 self.omapIndex = self.omapIndex + 1
@ -1743,10 +1763,10 @@ class RelDataBase:
"""adds a Place instance to the database, assigning it a gramps' """adds a Place instance to the database, assigning it a gramps'
ID number""" ID number"""
index = "P%d" % self.lmapIndex index = self.pprefix % self.lmapIndex
while self.placeMap.has_key(index): while self.placeMap.has_key(index):
self.lmapIndex = self.lmapIndex + 1 self.lmapIndex = self.lmapIndex + 1
index = "P%d" % self.lmapIndex index = self.pprefix % self.lmapIndex
place.setId(index) place.setId(index)
self.placeMap[index] = place self.placeMap[index] = place
self.lmapIndex = self.lmapIndex + 1 self.lmapIndex = self.lmapIndex + 1
@ -1792,10 +1812,10 @@ class RelDataBase:
def newFamily(self): def newFamily(self):
"""adds a Family to the database, assigning a gramps' ID""" """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): while self.familyMap.has_key(index):
self.fmapIndex = self.fmapIndex + 1 self.fmapIndex = self.fmapIndex + 1
index = "F%d" % self.fmapIndex index = self.fprefix % self.fmapIndex
self.fmapIndex = self.fmapIndex + 1 self.fmapIndex = self.fmapIndex + 1
family = Family() family = Family()
family.setId(index) family.setId(index)

View File

@ -585,6 +585,309 @@
</widget> </widget>
</widget> </widget>
</widget> </widget>
<widget>
<class>GtkFrame</class>
<name>frame9</name>
<label>GRAMPS id prefixes</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>5</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table28</name>
<rows>3</rows>
<columns>4</columns>
<homogeneous>False</homogeneous>
<row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<widget>
<class>GtkLabel</class>
<name>label210</name>
<label>Person</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>2</xpad>
<ypad>2</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>iprefix</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Sat, 20 Oct 2001 13:59:28 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>I</text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>2</xpad>
<ypad>2</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>sprefix</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Sat, 20 Oct 2001 14:00:46 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>S</text>
<child>
<left_attach>3</left_attach>
<right_attach>4</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>2</xpad>
<ypad>2</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>fprefix</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Sat, 20 Oct 2001 14:00:26 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>F</text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>2</xpad>
<ypad>2</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>oprefix</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Sat, 20 Oct 2001 14:01:09 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>O</text>
<child>
<left_attach>3</left_attach>
<right_attach>4</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>2</xpad>
<ypad>2</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>pprefix</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Sat, 20 Oct 2001 14:00:13 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>P</text>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>2</xpad>
<ypad>2</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label211</name>
<label>Family</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>2</xpad>
<ypad>2</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label212</name>
<label>Place</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>2</xpad>
<ypad>2</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label213</name>
<label>Source</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>2</xpad>
<ypad>2</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label214</name>
<label>Media Object</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>2</xpad>
<ypad>2</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</widget> </widget>
<widget> <widget>

View File

@ -2039,7 +2039,7 @@ def import_callback(obj,plugin_function):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def on_preferences_activate(obj): 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) person_list.set_column_visibility(1,Config.id_visible)
notebook.set_show_tabs(Config.usetabs) 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 = gtop.get_widget("child_list")
child_list.set_column_visibility(4,Config.show_detail) child_list.set_column_visibility(4,Config.show_detail)
child_list.set_column_visibility(6,0) child_list.set_column_visibility(6,0)

View File

@ -158,3 +158,17 @@ def by_last_name(first, second) :
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def by_last_name_backwards(first, second) : def by_last_name_backwards(first, second) :
return by_last_name(second,first) 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