From d51147acc1a261a0b3f47a6521e58660ee629642 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 30 Oct 2001 20:37:56 +0000 Subject: [PATCH] Fixed EventCmp handling of files, sort on place fields svn: r527 --- gramps/NEWS | 1 + gramps/src/gramps.glade | 449 +++++++++++++++++++++++++++++-- gramps/src/gramps_main.py | 102 +++++-- gramps/src/plugins/EventCmp.py | 13 +- gramps/src/plugins/ReorderIds.py | 32 ++- 5 files changed, 544 insertions(+), 53 deletions(-) diff --git a/gramps/NEWS b/gramps/NEWS index f0cc7cf22..12b42f2ff 100644 --- a/gramps/NEWS +++ b/gramps/NEWS @@ -40,6 +40,7 @@ Version 0.6.0pre a dotted line). * Reordering GRAMPS' ids attempts to preserve the integer originally assigned to the object. +* The person view can be sorted by GRAMPS id. Version 0.5.1 * Bug fixes diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index 5a685975b..b89b150a9 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -909,16 +909,73 @@ - GtkLabel + GtkHBox CList:title - glabel5 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 + hbox38 + True + 0 + + + GtkHBox + CList:title + hbox39 + True + 0 + + 0 + False + False + + + + GtkHBox + hbox40 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label275 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + idSort + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + @@ -2406,17 +2463,363 @@ on_place_list_button_press_event Fri, 17 Aug 2001 23:00:19 GMT - 6 - 236,47,102,88,77,80 + + click_column + on_place_list_click_column + Tue, 30 Oct 2001 18:18:53 GMT + + 12 + 222,47,102,88,77,80,5,5,5,5,5,5 GTK_SELECTION_EXTENDED True GTK_SHADOW_IN + + GtkHBox + CList:title + hbox41 + True + 0 + + + GtkHBox + hbox42 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + place_title + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + place_arrow + 10 + 10 + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox43 + True + 0 + + + GtkHBox + hbox44 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label283 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + place_id_arrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox45 + True + 0 + + + GtkHBox + hbox46 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label284 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + city_arrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox47 + True + 0 + + + GtkHBox + hbox48 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label285 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + county_arrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox49 + True + 0 + + + GtkHBox + hbox50 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label286 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + state_arrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + + + GtkHBox + CList:title + hbox51 + True + 0 + + + GtkHBox + hbox52 + False + 0 + + 0 + False + False + + + + GtkLabel + CList:title + label287 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + + + + GtkArrow + country_arrow + 10 + 10 + False + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 5 + False + True + + + + + GtkLabel CList:title - label232 - + label276 + GTK_JUSTIFY_CENTER False 0.5 @@ -2428,8 +2831,8 @@ GtkLabel CList:title - label233a - + label277 + GTK_JUSTIFY_CENTER False 0.5 @@ -2441,8 +2844,8 @@ GtkLabel CList:title - label233b - + label278 + GTK_JUSTIFY_CENTER False 0.5 @@ -2454,8 +2857,8 @@ GtkLabel CList:title - label233c - + label279 + GTK_JUSTIFY_CENTER False 0.5 @@ -2467,8 +2870,8 @@ GtkLabel CList:title - label233d - + label280 + GTK_JUSTIFY_CENTER False 0.5 @@ -2480,8 +2883,8 @@ GtkLabel CList:title - label233e - + label281 + GTK_JUSTIFY_CENTER False 0.5 diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 74ae32cc2..81f9d5a78 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -109,12 +109,23 @@ mdetails = None preview = None database = None nameArrow = None +idArrow = None deathArrow = None dateArrow = None + +place_arrow = None +place_id_arrow= None +city_arrow = None +county_arrow = None +state_arrow = None +country_arrow = None + canvas = None merge_button = None sort_column = 5 sort_direct = SORT_ASCENDING +p_sort_column = 0 +p_sort_direct = SORT_ASCENDING DataFilter = Filter.Filter("") c_birth_order = 0 c_name = 1 @@ -939,11 +950,13 @@ def on_person_list_select_row(obj,row,b,c): #------------------------------------------------------------------------- def on_person_list_click_column(obj,column): if column == 0: - change_sort(5,gtop.get_widget("nameSort")) + change_sort(5,nameArrow) + elif column == 1: + change_sort(1,idArrow) elif column == 3: - change_sort(6,gtop.get_widget("dateSort")) + change_sort(6,dateArrow) elif column == 4: - change_sort(7,gtop.get_widget("deathSort")) + change_sort(7,deathArrow) else: return @@ -952,6 +965,41 @@ def on_person_list_click_column(obj,column): row = person_list.find_row_from_data(id2col[active_person]) person_list.moveto(row) + +def on_place_list_click_column(obj,column): + global p_sort_direct, p_sort_column + + obj.freeze() + if len(obj.selection): + sel = obj.get_row_data(obj.selection[0]) + else: + sel = None + + place_arrows = [ place_arrow, place_id_arrow, city_arrow, + county_arrow, state_arrow, country_arrow ] + + for a in place_arrows: + a.hide() + arrow = place_arrows[column] + if p_sort_column == column: + if p_sort_direct == SORT_DESCENDING: + p_sort_direct = SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + else: + p_sort_direct = SORT_DESCENDING + arrow.set(GTK.ARROW_UP,2) + else: + p_sort_direct = SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) + p_sort_column = column + place_list.set_sort_type(p_sort_direct) + place_list.set_sort_column(p_sort_column + 6) + arrow.show() + place_list.sort() + if sel: + place_list.moveto(place_list.find_row_from_data(sel)) + obj.thaw() + #------------------------------------------------------------------------- # # @@ -961,9 +1009,9 @@ def change_sort(column,arrow): global sort_direct global sort_column - nameArrow.hide() - deathArrow.hide() - dateArrow.hide() + for a in [ nameArrow, deathArrow, dateArrow, idArrow ]: + if arrow != a: + a.hide() arrow.show() if sort_column == column: @@ -975,6 +1023,7 @@ def change_sort(column,arrow): arrow.set(GTK.ARROW_UP,2) else: sort_direct = SORT_ASCENDING + arrow.set(GTK.ARROW_DOWN,2) sort_column = column person_list.set_sort_type(sort_direct) person_list.set_sort_column(sort_column) @@ -1347,21 +1396,21 @@ def on_media_activate(obj): def on_notebook1_switch_page(obj,junk,page): if page == 0: goto_active_person() - merge_button.show() + merge_button.set_sensitive(1) elif page == 1: - merge_button.hide() + merge_button.set_sensitive(0) load_family() elif page == 2: - merge_button.hide() + merge_button.set_sensitive(0) load_canvas() elif page == 3: - merge_button.hide() + merge_button.set_sensitive(0) load_sources() elif page == 4: - merge_button.show() + merge_button.set_sensitive(1) load_places() elif page == 5: - merge_button.hide() + merge_button.set_sensitive(0) load_media() #------------------------------------------------------------------------- @@ -1381,10 +1430,7 @@ def load_places(): index = 0 places = database.getPlaceMap().values() - nlist = map(lambda x: (string.upper(x.get_title()),x),places) - nlist.sort() - places = map(lambda(key,x): x, nlist) - + u = string.upper for src in places: title = src.get_title() id = src.getId() @@ -1393,7 +1439,8 @@ def load_places(): county = mloc.get_county() state = mloc.get_state() country = mloc.get_country() - place_list.append([title,id,city,county,state,country]) + place_list.append([title,id,city,county,state,country, + u(title), u(id), u(city), u(county), u(state), u(country)]) place_list.set_row_data(index,src) index = index + 1 @@ -2601,8 +2648,10 @@ def main(arg): global statusbar,notebook global person_list, source_list, place_list, canvas, media_list global topWindow, preview, merge_button - global nameArrow, dateArrow, deathArrow + global nameArrow, dateArrow, deathArrow, idArrow global cNameArrow, cDateArrow + global place_arrow, place_id_arrow, city_arrow, county_arrow + global state_arrow, country_arrow global mid, mtype, mdesc, mpath, mdetails rc_parse(const.gtkrcFile) @@ -2635,9 +2684,16 @@ def main(arg): filter_list = gtop.get_widget("filter_list") notebook = gtop.get_widget(NOTEBOOK) nameArrow = gtop.get_widget("nameSort") + idArrow = gtop.get_widget("idSort") dateArrow = gtop.get_widget("dateSort") deathArrow = gtop.get_widget("deathSort") merge_button= gtop.get_widget("merge") + place_arrow = gtop.get_widget("place_arrow") + place_id_arrow= gtop.get_widget("place_id_arrow") + city_arrow = gtop.get_widget("city_arrow") + county_arrow = gtop.get_widget("county_arrow") + state_arrow = gtop.get_widget("state_arrow") + country_arrow = gtop.get_widget("country_arrow") t = [ ('STRING', 0, 0), ('text/plain',0,0), @@ -2653,6 +2709,15 @@ def main(arg): person_list.set_sort_column(sort_column) person_list.set_sort_type(sort_direct) + place_list.set_column_visibility(6,0) + place_list.set_column_visibility(7,0) + place_list.set_column_visibility(8,0) + place_list.set_column_visibility(9,0) + place_list.set_column_visibility(10,0) + place_list.set_column_visibility(11,0) + place_list.set_sort_column(p_sort_column +6 ) + place_list.set_sort_type(p_sort_direct) + fw = gtop.get_widget('filter') filter_list.set_menu(Filter.build_filter_menu(on_filter_name_changed,fw)) @@ -2717,6 +2782,7 @@ def main(arg): "on_person_list_click_column" : on_person_list_click_column, "on_person_list_select_row" : on_person_list_select_row, "on_place_list_button_press_event" : on_place_list_button_press_event, + "on_place_list_click_column" : on_place_list_click_column, "on_main_key_release_event" : on_main_key_release_event, "on_add_media_clicked" : create_add_dialog, "on_media_activate" : on_media_activate, diff --git a/gramps/src/plugins/EventCmp.py b/gramps/src/plugins/EventCmp.py index 8a6e35fd8..9cc12d448 100644 --- a/gramps/src/plugins/EventCmp.py +++ b/gramps/src/plugins/EventCmp.py @@ -265,11 +265,14 @@ class ComplexFilterFile: def __init__(self,name): self.filters = {} self.fname = name - f = open(self.fname) - parser = make_parser() - parser.setContentHandler(ComplexFilterParser(self)) - parser.parse(f) - f.close() + try: + f = open(self.fname) + parser = make_parser() + parser.setContentHandler(ComplexFilterParser(self)) + parser.parse(f) + f.close() + except IOError: + pass def get_filter_names(self): return self.filters.keys() diff --git a/gramps/src/plugins/ReorderIds.py b/gramps/src/plugins/ReorderIds.py index 1bd01df1f..1815acad3 100644 --- a/gramps/src/plugins/ReorderIds.py +++ b/gramps/src/plugins/ReorderIds.py @@ -18,7 +18,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -"Database Processing/Reorder gramps IDs" +""" +Change id IDs of all the elements in the database to conform to the +scheme specified in the database's prefix ids +""" import re import utils @@ -28,13 +31,9 @@ _ = intl.gettext _findint = re.compile('^[^\d]*(\d+)[^\d]*') -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- def runTool(database,active_person,callback): - + """Changed person, family, object, source, and place ids""" + make_new_ids(database.getPersonMap(),database.iprefix) make_new_ids(database.getFamilyMap(),database.fprefix) make_new_ids(database.getObjectMap(),database.oprefix) @@ -45,11 +44,24 @@ def runTool(database,active_person,callback): def make_new_ids(data_map,prefix): + """Try to extract the old integer out of the id, and reuse it + if possible. Otherwise, blindly renumber those that can't.""" + dups = [] newids = [] + + # search all ids in the map for id in data_map.keys(): + + # attempt to extract integer, if we can't, treat it as a + # duplicate + match = _findint.match(id) if match: + # get the integer, build the new id. Make sure it + # hasn't already been chosen. If it has, put this + # in the duplicate id list + index = match.groups()[0] newid = prefix % int(index) if newid == id: @@ -62,6 +74,12 @@ def make_new_ids(data_map,prefix): data.setId(newid) data_map[newid] = data del data_map[id] + else: + dups.append(id) + + # go through the duplicates, looking for the first availble + # id that matches the new scheme. + index = 0 for id in dups: while 1: