Tighten the apply_filter, remove redundant call

svn: r154
This commit is contained in:
Don Allingham 2001-06-17 13:43:00 +00:00
parent 67b3f3c0c9
commit 2ab0ed773c

View File

@ -768,6 +768,11 @@ def read_file(filename):
statusbar.set_status("") statusbar.set_status("")
Config.save_last_file("") Config.save_last_file("")
for person in database.getPersonMap().values():
lastname = person.getPrimaryName().getSurname()
if lastname and lastname not in surnameList:
surnameList.append(lastname)
full_update() full_update()
statusbar.set_progress(0.0) statusbar.set_progress(0.0)
@ -1958,7 +1963,6 @@ def load_database(name):
Config.save_last_file(name) Config.save_last_file(name)
Main.get_widget("filter").set_text("") Main.get_widget("filter").set_text("")
active_person = database.getDefaultPerson() active_person = database.getDefaultPerson()
update_display(1)
return 1 return 1
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -1982,23 +1986,30 @@ def setup_bookmarks():
def displayError(msg): def displayError(msg):
topWindow.error(msg) topWindow.error(msg)
statusbar.set_status("") statusbar.set_status("")
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import time
def apply_filter(): def apply_filter():
t1 = time.time()
people = database.getPersonMap().values() people = database.getPersonMap().values()
names = [] names = []
altnames = []
for person in people: for person in people:
names.append((person.getPrimaryName(),person,0)) names.append((person.getPrimaryName(),person,0))
if Config.hide_altnames == 0: for name in person.getAlternateNames():
for name in person.getAlternateNames(): altnames.append((name,person,1))
names.append((name,person,1))
if Config.hide_altnames == 0:
names = names + altnames
names.sort(sortFunc) names.sort(sortFunc)
person_list.freeze() person_list.freeze()
@ -2007,29 +2018,30 @@ def apply_filter():
color_clist = ListColors.ColorList(person_list,1) color_clist = ListColors.ColorList(person_list,1)
i=0 i=0
datacomp = DataFilter.compare
clistadd = color_clist.add_with_data
gname = utils.phonebook_from_name
for name_tuple in names: for name_tuple in names:
person = name_tuple[1] person = name_tuple[1]
alt = name_tuple[2] alt = name_tuple[2]
name = name_tuple[0] name = name_tuple[0]
pname = utils.phonebook_from_name(name,alt) if datacomp(person):
lastname = name.getSurname()
if lastname and lastname not in surnameList:
surnameList.append(lastname)
if DataFilter.compare(person):
id2col[person] = i id2col[person] = i
if person.getGender(): if person.getGender():
gender = const.male gender = const.male
else: else:
gender = const.female gender = const.female
data = [pname,gender,birthday(person),deathday(person)] clistadd([gname(name,alt),gender,person.getBirth().getQuoteDate(),\
color_clist.add_with_data(data,person) person.getDeath().getQuoteDate()],person)
i = i + 1 i = i + 1
person_list.thaw() person_list.thaw()
t2 = time.time()
print "apply",t2-t1
if i > 0: if i > 0:
goto_active_person() goto_active_person()