* src/EditPerson.py: change sort mechanism to new Date sort value

* src/FamilyView.py: change sort mechanism to new Date sort valu
* src/Sort.py: remove unused sorting functions


svn: r3569
This commit is contained in:
Don Allingham 2004-09-23 02:25:07 +00:00
parent 8ccb4cebe9
commit 72880d4599
4 changed files with 21 additions and 36 deletions

View File

@ -1,3 +1,8 @@
2004-09-22 Don Allingham <dallingham@users.sourceforge.net>
* src/EditPerson.py: change sort mechanism to new Date sort value
* src/FamilyView.py: change sort mechanism to new Date sort valu
* src/Sort.py: remove unused sorting functions
2004-09-20 Alex Roitman <shura@alex.neuro.umn.edu> 2004-09-20 Alex Roitman <shura@alex.neuro.umn.edu>
* src/GrampsInMemDB.py: Remove unused modules. * src/GrampsInMemDB.py: Remove unused modules.

View File

@ -49,7 +49,6 @@ import const
import Utils import Utils
import GrampsCfg import GrampsCfg
import ImageSelect import ImageSelect
import Sort
import AutoComp import AutoComp
import ListModel import ListModel
import RelLib import RelLib
@ -1777,14 +1776,13 @@ class EditPerson:
"""Check any *valid* birthdates in the list to insure that they are in """Check any *valid* birthdates in the list to insure that they are in
numerically increasing order.""" numerically increasing order."""
inorder = True inorder = True
prev_date = "00000000" prev_date = 0
for i in range(len(list)): for i in range(len(list)):
child_handle = list[i] child_handle = list[i]
child = self.db.get_person_from_handle(child_handle) child = self.db.get_person_from_handle(child_handle)
if child.get_birth_handle(): if child.get_birth_handle():
event = self.db.get_event_from_handle(child.get_birth_handle()) event = self.db.get_event_from_handle(child.get_birth_handle())
bday = event.get_date_object() child_date = event.get_date_object().get_sort_value()
child_date = Sort.build_sort_date(bday)
else: else:
continue continue
if (prev_date <= child_date): # <= allows for twins if (prev_date <= child_date): # <= allows for twins
@ -1805,9 +1803,9 @@ class EditPerson:
event_handle = person.get_birth_handle() event_handle = person.get_birth_handle()
if event_handle: if event_handle:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_handle)
person_bday = Sort.build_sort_date(event.get_date_object()) person_bday = event.get_date_object().get_sort_value()
else: else:
person_bday = "99999999" person_bday = 0
# First, see if the person needs to be moved forward in the list # First, see if the person needs to be moved forward in the list
@ -1818,10 +1816,10 @@ class EditPerson:
event_handle = other.get_birth_handle() event_handle = other.get_birth_handle()
if event_handle: if event_handle:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_handle)
other_bday = Sort.build_sort_date(event.get_date_object()) other_bday = event.get_date_object().get_sort_value()
if (other_bday == "99999999"): if other_bday == 0:
continue; continue;
if (person_bday < other_bday): if person_bday < other_bday:
target = i target = i
else: else:
continue continue
@ -1833,10 +1831,10 @@ class EditPerson:
event_handle = other.get_birth_handle() event_handle = other.get_birth_handle()
if event_handle: if event_handle:
event = self.db.get_event_from_handle(event_handle) event = self.db.get_event_from_handle(event_handle)
other_bday = Sort.build_sort_date(event.get_date_object()) other_bday = event.get_date_object().get_sort_value()
if (other_bday == "99999999"): if other_bday == "99999999":
continue; continue;
if (person_bday > other_bday): if person_bday > other_bday:
target = i target = i
else: else:
continue continue

View File

@ -36,7 +36,6 @@ from gobject import TYPE_STRING, TYPE_INT
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import const import const
import Sort
import Utils import Utils
import GrampsCfg import GrampsCfg
import AddSpouse import AddSpouse
@ -1410,8 +1409,8 @@ class FamilyView:
def birth_dates_in_order(self,list): def birth_dates_in_order(self,list):
"""Check any *valid* birthdates in the list to insure that they are in """Check any *valid* birthdates in the list to insure that they are in
numerically increasing order.""" numerically increasing order."""
inorder = 1 inorder = True
prev_date = "00000000" prev_date = 0
for i in range(len(list)): for i in range(len(list)):
child_handle = list[i] child_handle = list[i]
child = self.parent.db.get_person_from_handle(child_handle) child = self.parent.db.get_person_from_handle(child_handle)
@ -1419,12 +1418,11 @@ class FamilyView:
birth = self.parent.db.get_event_from_handle(birth_handle) birth = self.parent.db.get_event_from_handle(birth_handle)
if not birth: if not birth:
continue continue
bday = birth.get_date_object() child_date = birth.get_date_object().get_sort_value()
child_date = Sort.build_sort_date(bday) if child_date == 0:
if (child_date == "99999999"):
continue continue
if (prev_date <= child_date): # <= allows for twins if prev_date <= child_date: # <= allows for twins
prev_date = child_date prev_date = child_date
else: else:
inorder = 0 inorder = False
return inorder return inorder

View File

@ -48,22 +48,6 @@ _prefix = {}
for i in _plist: for i in _plist:
_prefix[i] = 1 _prefix[i] = 1
def build_sort_name(n):
"""Builds a name from a RelLib.Name instance that is suitable for
use as a sort key in a GtkCList. The name is converted to upper case
to provide for case-insenstive sorting"""
if n.Surname:
return "%-25s%-30s%s" % (n.Surname.upper(),n.FirstName.upper(),n.Suffix.upper())
else:
return "@"
def build_sort_date(n):
"""Builds a date from a Date.Date instance that is suitable for
use as a sort key in a GtkCList. The resultant string is in the format
of YYYYMMDD. Unknown values are given as all nines, so that the
appear at the end"""
return "%010d" % n.get_sort_value()
class Sort: class Sort:
def __init__(self,database): def __init__(self,database):
self.database = database self.database = database