Fast sorting

svn: r297
This commit is contained in:
Don Allingham 2001-08-06 03:00:01 +00:00
parent 1feb641e12
commit ebfb8fbe0f
7 changed files with 938 additions and 827 deletions

View File

@ -387,6 +387,14 @@ class GrampsParser(handler.ContentHandler):
def start_created(self,attrs):
self.entries = int(attrs["people"]) + int(attrs["families"])
#---------------------------------------------------------------------
#
#
#
#---------------------------------------------------------------------
def start_pos(self,attrs):
self.person.position = (int(u2l(attrs["x"])), int(u2l(attrs["y"])))
#---------------------------------------------------------------------
#
#
@ -818,6 +826,7 @@ class GrampsParser(handler.ContentHandler):
"person" : (start_person, None),
"img" : (start_photo, None),
"place" : (None, stop_place),
"pos" : (start_pos, None),
"postal" : (None, stop_postal),
"researcher" : (None, stop_research),
"resname" : (None, stop_resname ),

View File

@ -454,6 +454,7 @@ class Person:
self.urls = []
self.note = None
self.paf_uid = ""
self.position = None
def setPrimaryName(self,name) :
self.PrimaryName = name
@ -627,7 +628,13 @@ class Person:
if self.note == None:
self.note = Note()
return self.note
def setPosition(self,pos):
self.position = pos
def getPosition(self):
return self.position
#-------------------------------------------------------------------------
#
#

View File

@ -293,7 +293,7 @@ def exportData(database, filename, callback):
write_line(g,"nick",person.getNickName(),3)
pos = person.getPosition()
if pos != None:
g.write(' <pos>%d %d</pos>\n'% pos)
g.write(' <pos x="%d" y="%d"/>\n'% pos)
dump_my_event(g,"Birth",person.getBirth(),3)
dump_my_event(g,"Death",person.getDeath(),3)
for event in person.getEventList():

View File

@ -706,8 +706,8 @@
<handler>on_person_list_click_column</handler>
<last_modification_time>Thu, 07 Dec 2000 14:37:54 GMT</last_modification_time>
</signal>
<columns>5</columns>
<column_widths>250,60,70,150,100</column_widths>
<columns>8</columns>
<column_widths>250,60,70,150,100,1,1,1</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
@ -907,6 +907,46 @@
</widget>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>sort1</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>sort2</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>sort3</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>

View File

@ -104,7 +104,8 @@ family_window = None
queryTop = None
prefsTop = None
pv = {}
sortFunc = sort.fast_name_sort
sort_column = 5
sort_direct = SORT_ASCENDING
sbar_active = 1
DataFilter = Filter.create("")
@ -792,7 +793,7 @@ def load_sources():
if current_row == -1:
current_row = 0
source_list.select_row(current_row,0)
source_list.moveto(current_row,0)
source_list.moveto(current_row)
source_list.set_data("i",current_row)
source_list.thaw()
@ -1092,7 +1093,7 @@ def on_save_parents_clicked(obj):
mrel = const.childRelations[mrel]
frel = const.childRelations[frel]
type = save_frel(type)
type = const.save_frel(type)
if select_father or select_mother:
if select_mother.getGender() == Person.male and \
@ -1371,7 +1372,7 @@ def delete_spouse():
#
#-------------------------------------------------------------------------
def on_person_list_select_row(obj,a,b,c):
person = obj.get_row_data(a)
person,alt = obj.get_row_data(a)
obj.set_data("a",person)
change_active_person(person)
@ -1386,7 +1387,8 @@ def on_person_list_select_row(obj,a,b,c):
#
#-------------------------------------------------------------------------
def on_person_list_click_column(obj,column):
global sortFunc
global sort_column
global sort_direct
nameArrow = gtop.get_widget("nameSort")
dateArrow = gtop.get_widget("dateSort")
@ -1396,35 +1398,50 @@ def on_person_list_click_column(obj,column):
dateArrow.hide()
deathArrow.hide()
nameArrow.show()
if sortFunc != sort.fast_name_sort:
sortFunc = sort.fast_name_sort
nameArrow.set(GTK.ARROW_DOWN,2)
if sort_column == 5:
if sort_direct == SORT_DESCENDING:
sort_direct = SORT_ASCENDING
nameArrow.set(GTK.ARROW_DOWN,2)
else:
sort_direct = SORT_DESCENDING
nameArrow.set(GTK.ARROW_UP,2)
else:
sortFunc = sort.reverse_name_sort
nameArrow.set(GTK.ARROW_UP,2)
sort_direct = SORT_DESCENDING
sort_column = 5
elif column == 3:
nameArrow.hide()
deathArrow.hide()
dateArrow.show()
if sortFunc != sort.fast_birth_sort:
sortFunc = sort.fast_birth_sort
dateArrow.set(GTK.ARROW_DOWN,2)
if sort_column == 6:
if sort_direct == SORT_ASCENDING:
sort_direct = SORT_DESCENDING
dateArrow.set(GTK.ARROW_UP,2)
else:
sort_direct = SORT_ASCENDING
dateArrow.set(GTK.ARROW_DOWN,2)
else:
sortFunc = sort.reverse_birth_sort
dateArrow.set(GTK.ARROW_UP,2)
sort_direct = SORT_ASCENDING
sort_column = 6
elif column == 4:
nameArrow.hide()
deathArrow.show()
dateArrow.hide()
if sortFunc != sort.fast_death_sort:
sortFunc = sort.fast_death_sort
deathArrow.set(GTK.ARROW_DOWN,2)
if sort_column == 7:
if sort_direct == SORT_ASCENDING:
sort_direct = SORT_DESCENDING
deathArrow.set(GTK.ARROW_UP,2)
else:
sort_direct = SORT_ASCENDING
deathArrow.set(GTK.ARROW_DOWN,2)
else:
sortFunc = sort.reverse_death_sort
deathArrow.set(GTK.ARROW_UP,2)
sort_direct = SORT_ASCENDING
sort_column = 7
else:
return
apply_filter()
person_list.set_sort_type(sort_direct)
person_list.set_sort_column(sort_column)
person_list.sort()
person_list.moveto()
#-------------------------------------------------------------------------
#
@ -1647,10 +1664,7 @@ def on_notebook1_switch_page(obj,junk,page):
if not active_person:
return
if page == 0:
if id2col.has_key(active_person):
column = id2col[active_person]
person_list.select_row(column,0)
person_list.moveto(column,0)
goto_active_person()
elif page == 1:
load_family()
elif page == 2:
@ -2262,8 +2276,6 @@ def apply_filter():
if Config.hide_altnames == 0:
names = names + altnames
names = sortFunc(names)
person_list.freeze()
person_list.clear()
@ -2283,18 +2295,22 @@ def apply_filter():
name = name_tuple[0]
if datacomp(person):
pos = (person,alt)
if not alt:
id2col[person] = i
id2col[person] = pos
if person.getGender():
gender = const.male
else:
gender = const.female
bday = person.getBirth().getQuoteDate()
dday = person.getDeath().getQuoteDate()
clistadd([gname(name,alt),person.getId(), gender,bday, dday],\
person)
bday = person.getBirth().getDateObj()
dday = person.getDeath().getDateObj()
clistadd([gname(name,alt),person.getId(), gender,bday.getQuoteDate(),
dday.getQuoteDate(), sort.build_sort_name(name),
sort.build_sort_birth(bday), sort.build_sort_death(dday)], pos)
i = i + 1
person_list.sort()
person_list.moveto()
person_list.thaw()
if i > 0:
@ -2307,13 +2323,15 @@ def apply_filter():
#-------------------------------------------------------------------------
def goto_active_person():
if id2col.has_key(active_person):
column = id2col[active_person]
person_list.select_row(column,0)
person_list.moveto(column,0)
pos = id2col[active_person]
column = person_list.find_row_from_data(pos)
if column != -1:
person_list.select_row(column,0)
person_list.moveto(column)
else:
person_list.select_row(0,0)
person_list.moveto(0,0)
person = person_list.get_row_data(0)
person_list.moveto(0)
person,alt = person_list.get_row_data(0)
change_active_person(person)
#-------------------------------------------------------------------------
@ -2453,6 +2471,12 @@ def main(arg):
person_list = gtop.get_widget("person_list")
source_list = gtop.get_widget("source_list")
filter_list = gtop.get_widget("filter_list")
person_list.set_column_visibility(5,0)
person_list.set_column_visibility(6,0)
person_list.set_column_visibility(7,0)
person_list.set_sort_column(sort_column)
person_list.set_sort_type(sort_direct)
myMenu = GtkMenu()
for filter in Filter.filterList:

File diff suppressed because it is too large Load Diff

View File

@ -27,50 +27,42 @@ import string
#
#
#-------------------------------------------------------------------------
def build_sort_name(person):
n = person[0]
nm = "%-25s%-30s%s" % (n.Surname,n.FirstName,n.Suffix)
return (string.upper(nm),person)
def build_sort_name(n):
return "%-25s%-30s%s" % (n.Surname,n.FirstName,n.Suffix)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def build_sort_birth(person):
n = person[1].birth.date.start
y = n.year
def build_sort_birth(n):
y = n.start.year
if y == -1:
y = 9999
m = n.month
m = n.start.month
if m == -1:
m = 99
d = n.day
d = n.start.day
if d == -1:
d = 99
nm = "%04d%2d%2d" % (y,m,d)
return (nm,person)
return "%04d%2d%2d" % (y,m,d)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def build_sort_death(person):
n = person[1].death.date.start
y = n.year
def build_sort_death(n):
y = n.start.year
if y == -1:
y = 9999
m = n.month
m = n.start.month
if m == -1:
m = 99
d = n.day
d = n.start.day
if d == -1:
d = 99
nm = "%04d%2d%2d" % (y,m,d)
return (nm,person)
return "%04d%2d%2d" % (y,m,d)
#-------------------------------------------------------------------------
#