From 7592aa4d62298c57d3d6315a9c06003441c01a12 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 30 Jun 2004 04:06:10 +0000 Subject: [PATCH] * src/FamilyView.py: fix reordering of children * src/ChooseParents.py: get filters working again * src/AddSpouse.py: update display after addition of person * src/Utils.py: new id generation algorithm svn: r3245 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/AddSpouse.py | 24 ++++++++++++++++++++---- gramps2/src/ChooseParents.py | 34 ++++++++++++++++++++++++++++++++-- gramps2/src/FamilyView.py | 3 +++ gramps2/src/Utils.py | 30 +++++++++++++++++------------- 5 files changed, 78 insertions(+), 19 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index c2d090eda..418a2c013 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2004-06-29 Don Allingham + * src/FamilyView.py: fix reordering of children + * src/ChooseParents.py: get filters working again + * src/AddSpouse.py: update display after addition of person + * src/Utils.py: new id generation algorithm + 2004-06-28 Don Allingham * src/ChooseParents.py: fix parent selection * src/FamilyView.py: fix update of parents after selction diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py index e9a7970e2..e4c61162a 100644 --- a/gramps2/src/AddSpouse.py +++ b/gramps2/src/AddSpouse.py @@ -214,12 +214,28 @@ class AddSpouse: been closed. """ person = epo.person - if person.get_id() == "": - self.db.add_person(person) + trans = self.db.start_transaction() + id = person.get_id() + if id == "": + id = self.db.add_person(person,trans) else: - self.db.add_person_no_map(person,person.get_id()) + self.db.add_person_no_map(person,id,trans) + + person = self.db.try_to_find_person_from_id(id) + n = person.get_primary_name().get_name() + self.db.add_transaction(trans,_('Add Person (%s)' % n)) self.addperson(person) - self.update_data(person.get_id()) + self.update_data(id) + + self.slist = PeopleModel.PeopleModel(self.db) + self.slist.rebuild_data() + self.spouse_list.set_model(self.slist) + + path = self.slist.on_get_path(person.get_id()) + top_path = self.slist.on_get_path(person.get_primary_name().get_surname()) + self.spouse_list.expand_row(top_path,0) + self.selection.select_path(path) + #self.spouse_list.scroll_to_cell(path,None,1,0.5,0) #self.slist.center_selected() def select_spouse_clicked(self,obj): diff --git a/gramps2/src/ChooseParents.py b/gramps2/src/ChooseParents.py index 2270eadc6..c889eab92 100644 --- a/gramps2/src/ChooseParents.py +++ b/gramps2/src/ChooseParents.py @@ -300,8 +300,18 @@ class ChooseParents: """Redraws the potential father list""" self.father_nsort = PeopleModel.PeopleModel(self.db) self.father_nsort.rebuild_data() - self.father_model = gtk.TreeModelSort(self.father_nsort) + self.father_nsort.reset_visible() + + for pid in self.db.get_person_keys(): + person = self.db.try_to_find_person_from_id(pid) + visible = self.father_filter(person) + if visible: + self.father_nsort.set_visible(pid,visible) + + self.father_model = gtk.TreeModelSort(self.father_nsort).filter_new() + self.father_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.father_list.set_model(self.father_model) + self.father_model.refilter() if self.type == "Partners": self.flabel.set_label("%s" % _("Par_ent")) @@ -312,8 +322,18 @@ class ChooseParents: """Redraws the potential mother list""" self.mother_nsort = PeopleModel.PeopleModel(self.db) self.mother_nsort.rebuild_data() - self.mother_model = gtk.TreeModelSort(self.mother_nsort) + self.mother_nsort.reset_visible() + + for pid in self.db.get_person_keys(): + person = self.db.try_to_find_person_from_id(pid) + visible = self.mother_filter(person) + if visible: + self.mother_nsort.set_visible(pid,visible) + + self.mother_model = gtk.TreeModelSort(self.mother_nsort).filter_new() + self.mother_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.mother_list.set_model(self.mother_model) + self.mother_model.refilter() if self.type == "Partners": self.mlabel.set_label("%s" % _("Pa_rent")) @@ -547,8 +567,18 @@ class ChooseParents: self.parent_relation_changed(self.prel) elif person.get_gender() == RelLib.Person.male: self.redrawf() + path = self.father_model.on_get_path(id) + top_path = self.father_model.on_get_path(person.get_primary_name().get_surname()) + self.father_list.expand_row(top_path,0) + self.father_selection.select_path(path) + self.father_list.scroll_to_cell(path,None,1,0.5,0) else: self.redrawm() + path = self.mother_model.on_get_path(id) + top_path = self.mother_model.on_get_path(person.get_primary_name().get_surname()) + self.mother_list.expand_row(top_path,0) + self.mother_selection.select_path(path) + self.mother_list.scroll_to_cell(path,None,1,0.5,0) self.full_update() def add_parent_clicked(self,obj): diff --git a/gramps2/src/FamilyView.py b/gramps2/src/FamilyView.py index 6919b237d..aaf09cec3 100644 --- a/gramps2/src/FamilyView.py +++ b/gramps2/src/FamilyView.py @@ -1324,6 +1324,9 @@ class FamilyView: _("Children must be ordered by their birth dates.")) return self.family.set_child_id_list(list) + trans = self.parent.db.start_transaction() + self.parent.db.commit_family(self.family,trans) + self.parent.db.add_transaction(trans,_('Reorder children')) self.display_marriage(self.family) def drag_data_get(self,widget, context, sel_data, info, time): diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index c3d44853c..160404045 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -28,7 +28,6 @@ import string import os import locale -import time #------------------------------------------------------------------------- # @@ -54,15 +53,6 @@ import GrampsMime #------------------------------------------------------------------------- from gettext import gettext as _ -#------------------------------------------------------------------------- -# -# Random -# -#------------------------------------------------------------------------- -import random - -rand = random.Random(time.time()) - #------------------------------------------------------------------------- # # modified flag @@ -537,7 +527,21 @@ def unbold_label(label): label.set_text(text) label.set_use_markup(0) +#------------------------------------------------------------------------- +# +# create_id +# +#------------------------------------------------------------------------- +import random +import time +rand = random.Random(time.time()) + def create_id(): - return str("%08x%08x" % ( - int(time.time()*10000), - rand.randint(0,0x7fffffff))) + s = "" + for val in [ int(time.time()*10000) & 0x7fffffff, + rand.randint(0,0x7fffffff), + rand.randint(0,0x7fffffff)]: + while val != 0: + s += chr(val%57+65) + val = int(val/57) + return s