diff --git a/ChangeLog b/ChangeLog index 7ffeb1bd6..481da78bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-12-04 Don Allingham + * src/ChooseParents.py: use new cursor for interation + * src/DbPrompter.py: reformat + * src/GenericFilter.py: add disconnected rule + * src/GrampsBSDDB.py: provide cursor access for iteration + * src/GrampsDbBase.py: provide cursor access for iteration + * src/GrampsInMemDB.py: provide cursor access for iteration + * src/Makefile.am: add gramps.desktop to install list + * src/PeopleModel.py: use new cursor for faster iteration + * src/PeopleView.py: reimplement filtering + * src/ReadGedcom.py: removed used source counting + * src/gedcomimport.glade: remove source field + * src/gramps.glade: fixed spacing in message + * src/gramps_main.py: add disconnected filter + 2004-12-02 Don Allingham * src/EditPerson.py: hide window while closing updating info * src/FamilyView.py: Fix deleting of spouses and children diff --git a/src/ChooseParents.py b/src/ChooseParents.py index 6439983a1..d50deeff8 100644 --- a/src/ChooseParents.py +++ b/src/ChooseParents.py @@ -313,16 +313,19 @@ class ChooseParents: def redrawf(self): """Redraws the potential father list""" - self.father_nsort = PeopleModel.PeopleModel(self.db) - self.father_nsort.rebuild_data() - self.father_nsort.reset_visible() self.build_exclude_list() + self.father_nsort = PeopleModel.PeopleModel(self.db) - for pid in self.db.get_person_handles(sort_handles=False): - person = self.db.get_person_from_handle(pid) + cursor = self.db.get_person_cursor() + data = cursor.first() + while data: + person = RelLib.Person() + person.unserialize(data[1]) visible = self.father_filter(person) if visible: - self.father_nsort.set_visible(pid,visible) + self.father_nsort.set_visible(data[0],visible) + data = cursor.next() + cursor.close() self.father_model = gtk.TreeModelSort(self.father_nsort).filter_new() self.father_model.set_visible_column(PeopleModel.COLUMN_VIEW) @@ -337,15 +340,18 @@ class ChooseParents: def redrawm(self): """Redraws the potential mother list""" self.mother_nsort = PeopleModel.PeopleModel(self.db) - self.mother_nsort.rebuild_data() - self.mother_nsort.reset_visible() self.build_exclude_list() - for pid in self.db.get_person_handles(sort_handles=False): - person = self.db.get_person_from_handle(pid) + cursor = self.db.get_person_cursor() + data = cursor.first() + while data: + person = RelLib.Person() + person.unserialize(data[1]) visible = self.mother_filter(person) if visible: - self.mother_nsort.set_visible(pid,visible) + self.mother_nsort.set_visible(data[0],visible) + data = cursor.next() + cursor.close() self.mother_model = gtk.TreeModelSort(self.mother_nsort).filter_new() self.mother_model.set_visible_column(PeopleModel.COLUMN_VIEW) diff --git a/src/DbPrompter.py b/src/DbPrompter.py index eb74319c1..44829c4af 100644 --- a/src/DbPrompter.py +++ b/src/DbPrompter.py @@ -185,12 +185,13 @@ class ExistingDbPrompter: # and create an empty native database to import data in for (importData,mime_filter,mime_type,native_format) in Plugins._imports: if filetype == mime_type or the_file == mime_type: - QuestionDialog.OkDialog( _("Opening non-native format"), - _("New gramps database has to be set up " - "when opening non-native formats. The " - "following dialog will let you select " - "the new database."), - self.parent_window) + QuestionDialog.OkDialog( + _("Opening non-native format"), + _("New gramps database has to be set up " + "when opening non-native formats. The " + "following dialog will let you select " + "the new database."), + self.parent_window) prompter = NewNativeDbPrompter(self.parent,self.parent_window) if prompter.chooser(): importData(self.parent.db,filename) @@ -198,8 +199,9 @@ class ExistingDbPrompter: return True else: return False - QuestionDialog.ErrorDialog( _("Could not open file: %s") % filename, - _('The type "%s" is not in the list of known file types') % filetype ) + QuestionDialog.ErrorDialog( + _("Could not open file: %s") % filename, + _('The type "%s" is not in the list of known file types') % filetype ) #choose.destroy() return False @@ -283,8 +285,9 @@ class ImportDbPrompter: importData(self.parent.db,filename) self.parent.import_tool_callback() return True - QuestionDialog.ErrorDialog( _("Could not open file: %s") % filename, - _('The type "%s" is not in the list of known file types') % filetype ) + QuestionDialog.ErrorDialog( + _("Could not open file: %s") % filename, + _('The type "%s" is not in the list of known file types') % filetype ) choose.destroy() return False diff --git a/src/FamilyView.py b/src/FamilyView.py index 941522be5..34757042a 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -844,11 +844,9 @@ class FamilyView: for id in [father_id, mother_id]: if id: - print p.get_family_handle_list() p = self.db.find_person_from_handle(id) p.remove_family_handle(self.family.get_handle()) self.parent.db.commit_person(p,trans) - print p.get_family_handle_list() if len(self.person.get_family_handle_list()) > 0: handle = self.person.get_family_handle_list()[0] diff --git a/src/GenericFilter.py b/src/GenericFilter.py index bac7409ed..9cf505505 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -139,6 +139,30 @@ class Everyone(Rule): def apply(self,db,p_id): return 1 +#------------------------------------------------------------------------- +# +# Disconnected +# +#------------------------------------------------------------------------- +class Disconnected(Rule): + """Matches disconnected individuals""" + + labels = [] + + def name(self): + return 'Disconnected individuals' + + def category(self): + return _('General filters') + + def description(self): + return _('Matches individuals that have no relationships') + + def apply(self,db,p_id): + person = db.get_person_from_handle(p_id) + return (not person.get_main_parents_family_handle() and + not len(person.get_family_handle_list())) + #------------------------------------------------------------------------- # # RelationshipPathBetween diff --git a/src/GrampsBSDDB.py b/src/GrampsBSDDB.py index af4f868c5..1a102223e 100644 --- a/src/GrampsBSDDB.py +++ b/src/GrampsBSDDB.py @@ -60,6 +60,9 @@ class GrampsBSDDB(GrampsDbBase): dbmap.open(name, dbname, db.DB_HASH, db.DB_CREATE, 0666) return dbmap + def get_person_cursor(self): + return self.person_map.cursor() + def load(self,name,callback): if self.person_map: self.close() diff --git a/src/GrampsDbBase.py b/src/GrampsDbBase.py index 622e9173b..651ffeebc 100644 --- a/src/GrampsDbBase.py +++ b/src/GrampsDbBase.py @@ -114,6 +114,9 @@ class GrampsDbBase: self.place2title = {} self.name_groups = {} + def get_person_cursor(self): + assert False, "Needs to be overridden in the derived class" + def load(self,name,callback): """ Opens the specified database. The method needs to be overridden diff --git a/src/GrampsInMemDB.py b/src/GrampsInMemDB.py index 553871839..19bde89e4 100644 --- a/src/GrampsInMemDB.py +++ b/src/GrampsInMemDB.py @@ -27,6 +27,27 @@ import os import md5 import gtk + +class GrampsCursor: + + def __init__(self,src_map): + self.src_map = src_map + self.current = iter(src_map) + + def first(self): + self.current = iter(self.src_map) + return self.next() + + def next(self): + try: + index = self.current.next() + return (index,self.src_map[index]) + except StopIteration: + return None + + def close(self): + pass + #------------------------------------------------------------------------- # # GrampsInMemDB @@ -59,6 +80,9 @@ class GrampsInMemDB(GrampsDbBase): def load(self,name,callback): pass + def get_person_cursor(self): + return GrampsCursor(self.person_map) + def close(self): pass @@ -73,7 +97,7 @@ class GrampsInMemDB(GrampsDbBase): def get_surname_list(self): a = {} - for person_id in self.get_person_handles(sort_handles=False): + for person_id in iter(self.person_map): p = self.get_person_from_handle(person_id) a[p.get_primary_name().get_group_as()] = 1 vals = a.keys() diff --git a/src/Makefile.am b/src/Makefile.am index f69bc3336..e2b9b7e8b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -129,6 +129,7 @@ GRAPHICS = \ home.png\ logo.png\ gramps.png \ + gramps.desktop \ media.png\ people48.png\ place.png\ diff --git a/src/PeopleModel.py b/src/PeopleModel.py index 639d9e73c..b8a0550eb 100644 --- a/src/PeopleModel.py +++ b/src/PeopleModel.py @@ -93,9 +93,13 @@ class PeopleModel(gtk.GenericTreeModel): if not self.db.is_open(): return - for person_handle in self.db.get_person_handles(sort_handles=False): + cursor = self.db.get_person_cursor() - person = self.db.get_person_from_handle(person_handle) + data = cursor.first() + while data: + person = Person() + person_handle = data[0] + person.unserialize(data[1]) grp_as = person.get_primary_name().get_group_as() sn = person.get_primary_name().get_surname() if grp_as: @@ -108,6 +112,9 @@ class PeopleModel(gtk.GenericTreeModel): else: self.sname_sub[surname] = [person_handle] + data = cursor.next() + cursor.close() + self.top_path2iter = self.sname_sub.keys() self.top_path2iter.sort(locale.strcoll) for name in self.top_path2iter: diff --git a/src/PeopleView.py b/src/PeopleView.py index f0d222b79..9763498dc 100644 --- a/src/PeopleView.py +++ b/src/PeopleView.py @@ -116,13 +116,15 @@ class PeopleView: def build_tree(self): self.person_model = PeopleModel.PeopleModel(self.parent.db) - #self.sort_model = self.person_model.filter_new() - self.sort_model = self.person_model + #self.sort_model = self.person_model + self.sort_model = self.person_model.filter_new() + self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) self.person_tree.set_model(self.sort_model) def blist(self, store, path, node, id_list): - id_list.append(self.sort_model.get_value(node, - PeopleModel.COLUMN_INT_ID)) + id_list.append(self.sort_model.get_value( + node, + PeopleModel.COLUMN_INT_ID)) def get_selected_objects(self): mlist = [] @@ -146,8 +148,10 @@ class PeopleView: def change_db(self,db): self.build_columns() self.person_model = PeopleModel.PeopleModel(db) - #self.sort_model = self.person_model.filter_new() - self.sort_model = self.person_model + #self.sort_model = self.person_model + self.sort_model = self.person_model.filter_new() + self.sort_model.set_visible_column(PeopleModel.COLUMN_VIEW) + self.apply_filter() self.person_tree.set_model(self.sort_model) def remove_from_person_list(self,person): @@ -203,14 +207,18 @@ class PeopleView: def apply_filter(self,current_model=None): self.person_model.rebuild_data() self.parent.status_text(_('Updating display...')) - keys = self.DataFilter.apply(self.parent.db, - self.parent.db.get_person_handles(sort_handles=False)) + keys = self.DataFilter.apply( + self.parent.db, + self.parent.db.get_person_handles(sort_handles=False)) self.person_model.reset_visible() for person_handle in keys: - self.person_model.set_visible(person_handle,1) + self.person_model.set_visible(person_handle,True) - #self.sort_model.refilter() + print "Applying filter" + self.sort_model.refilter() + print "Done" self.parent.modify_statusbar() + print "exit" def on_plist_button_press(self,obj,event): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index 9717d3e6c..be1a4c39e 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -293,7 +293,6 @@ class GedcomParser: self.version_obj = window.get_widget("version") self.families_obj = window.get_widget("families") self.people_obj = window.get_widget("people") - self.source_obj = window.get_widget("sources") self.errors_obj = window.get_widget("errors") self.close_done = window.get_widget('close_done') self.error_text_obj = window.get_widget("error_text") @@ -607,8 +606,6 @@ class GedcomParser: elif matches[1] in ["SUBM","SUBN","OBJE","_EVENT_DEFN"]: self.ignore_sub_junk(1) elif matches[2] == "SOUR": - if self.source_count % UPDATE == 0 and self.window: - self.update(self.source_obj,str(self.source_count)) self.parse_source(matches[1],1) elif matches[2][0:4] == "NOTE": if self.nmap.has_key(matches[1]): diff --git a/src/gedcomimport.glade b/src/gedcomimport.glade index e1964e49b..926e54605 100644 --- a/src/gedcomimport.glade +++ b/src/gedcomimport.glade @@ -50,7 +50,7 @@ 12 True - 11 + 10 5 False 6 @@ -161,7 +161,7 @@ 0 True - * + * False @@ -204,8 +204,8 @@ 1 5 - 7 - 8 + 6 + 7 fill @@ -227,8 +227,8 @@ 0 5 - 6 - 7 + 5 + 6 fill @@ -251,8 +251,8 @@ 0 5 - 9 - 10 + 8 + 9 fill @@ -290,8 +290,8 @@ 1 5 - 10 - 11 + 9 + 10 fill @@ -305,7 +305,7 @@ 0 True - * + * False @@ -350,7 +350,7 @@ 10 True - * + * False @@ -371,7 +371,7 @@ 0 True - * + * False @@ -392,7 +392,7 @@ 10 True - * + * False @@ -437,7 +437,7 @@ 0 True - * + * False @@ -472,51 +472,6 @@ - - - - True - Sources: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 1 - 2 - 4 - 5 - fill - - - - - - - True - True - False - True - 0 - - True - * - False - - - 2 - 3 - 4 - 5 - - - 0 diff --git a/src/gramps.glade b/src/gramps.glade index a5c41c755..56f527f64 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -31792,7 +31792,7 @@ Family name Given name True - GRAMPS is loading the database you selected. Please wait. + GRAMPS is loading the database you selected. Please wait. False False GTK_JUSTIFY_LEFT diff --git a/src/gramps_main.py b/src/gramps_main.py index 9e9614028..f09176d06 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -846,6 +846,11 @@ class Gramps: all.add_rule(GenericFilter.IsMale([])) filter_list.append(all) + all = GenericFilter.GenericFilter() + all.set_name(_("Disconnected individuals")) + all.add_rule(GenericFilter.Disconnected([])) + filter_list.append(all) + all = GenericFilter.ParamFilter() all.set_name(_("Name contains...")) all.add_rule(GenericFilter.SearchName([]))