From 298827d843b0b56aa28091b5196a00e0ee94b936 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 27 Oct 2010 18:13:53 +0000 Subject: [PATCH] GEPS 006: Add Locality field to Location svn: r16063 --- src/Filters/Rules/Place/_HasPlace.py | 21 +++--- src/Filters/SideBar/_PlaceSidebarFilter.py | 28 +++++--- src/ToolTips.py | 1 + src/gen/db/upgrade.py | 15 ++++ src/gen/db/write.py | 10 +++ src/gen/lib/locationbase.py | 17 ++++- src/gen/plug/report/utils.py | 1 + src/gen/proxy/private.py | 7 +- src/glade/editlocation.glade | 64 ++++++++++++----- src/glade/editplace.glade | 69 ++++++++++++------- .../editors/displaytabs/locationembedlist.py | 13 ++-- src/gui/editors/displaytabs/locationmodel.py | 4 +- src/gui/editors/editlocation.py | 9 ++- src/gui/editors/editplace.py | 5 ++ src/gui/selectors/selectplace.py | 20 +++--- src/gui/views/treemodels/placemodel.py | 56 ++++++++------- src/plugins/export/ExportXml.py | 25 ++++--- src/plugins/import/ImportXml.py | 12 ++-- src/plugins/lib/libplaceview.py | 37 +++++----- src/plugins/textreport/PlaceReport.py | 1 + src/plugins/view/placetreeview.py | 38 +++++----- 21 files changed, 297 insertions(+), 156 deletions(-) diff --git a/src/Filters/Rules/Place/_HasPlace.py b/src/Filters/Rules/Place/_HasPlace.py index 6dd4c42e7..f4581944b 100644 --- a/src/Filters/Rules/Place/_HasPlace.py +++ b/src/Filters/Rules/Place/_HasPlace.py @@ -3,6 +3,7 @@ # # Copyright (C) 2002-2006 Donald N. Allingham # Copyright (C) 2008 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,12 +47,13 @@ class HasPlace(Rule): labels = [ _('Name:'), _('Street:'), - _('Church Parish:'), - _('ZIP/Postal Code:'), + _('Locality:'), _('City:'), _('County:'), _('State:'), _('Country:'), + _('ZIP/Postal Code:'), + _('Church Parish:'), ] name = _('Places matching parameters') description = _("Matches places with particular parameters") @@ -81,22 +83,25 @@ class HasPlace(Rule): if not self.match_substring(1, loc.get_street()): return False - if not self.match_substring(2, loc.get_parish()): + if not self.match_substring(2, loc.get_locality()): return False - if not self.match_substring(3, loc.get_postal_code()): + if not self.match_substring(3, loc.get_city()): return False - if not self.match_substring(4, loc.get_city()): + if not self.match_substring(4, loc.get_county()): return False - if not self.match_substring(5, loc.get_county()): + if not self.match_substring(5, loc.get_state()): return False - if not self.match_substring(6, loc.get_state()): + if not self.match_substring(6, loc.get_country()): return False - if not self.match_substring(7, loc.get_country()): + if not self.match_substring(7, loc.get_postal_code()): + return False + + if not self.match_substring(8, loc.get_parish()): return False # Nothing contradicted, so we're matching this location diff --git a/src/Filters/SideBar/_PlaceSidebarFilter.py b/src/Filters/SideBar/_PlaceSidebarFilter.py index 4688ab48b..258f6db6e 100644 --- a/src/Filters/SideBar/_PlaceSidebarFilter.py +++ b/src/Filters/SideBar/_PlaceSidebarFilter.py @@ -3,6 +3,7 @@ # # Copyright (C) 2002-2006 Donald N. Allingham # Copyright (C) 2008 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,12 +61,13 @@ class PlaceSidebarFilter(SidebarFilter): self.filter_id = gtk.Entry() self.filter_title = gtk.Entry() self.filter_street = gtk.Entry() - self.filter_parish = gtk.Entry() - self.filter_zip = gtk.Entry() + self.filter_locality = gtk.Entry() self.filter_city = gtk.Entry() self.filter_county = gtk.Entry() self.filter_state = gtk.Entry() self.filter_country = gtk.Entry() + self.filter_zip = gtk.Entry() + self.filter_parish = gtk.Entry() self.filter_note = gtk.Entry() self.filter_regex = gtk.CheckButton(_('Use regular expressions')) self.generic = gtk.ComboBox() @@ -83,12 +85,13 @@ class PlaceSidebarFilter(SidebarFilter): self.add_text_entry(_('ID'), self.filter_id) self.add_text_entry(_('Place Name'), self.filter_title) self.add_text_entry(_('Street'), self.filter_street) - self.add_text_entry(_('Church parish'), self.filter_parish) - self.add_text_entry(_('ZIP/Postal code'), self.filter_zip) + self.add_text_entry(_('Locality'), self.filter_locality) self.add_text_entry(_('City'), self.filter_city) self.add_text_entry(_('County'), self.filter_county) self.add_text_entry(_('State'), self.filter_state) self.add_text_entry(_('Country'), self.filter_country) + self.add_text_entry(_('ZIP/Postal code'), self.filter_zip) + self.add_text_entry(_('Church parish'), self.filter_parish) self.add_text_entry(_('Note'), self.filter_note) self.add_filter_entry(_('Custom filter'), self.generic) self.add_entry(None, self.filter_regex) @@ -97,12 +100,13 @@ class PlaceSidebarFilter(SidebarFilter): self.filter_id.set_text('') self.filter_title.set_text('') self.filter_street.set_text('') - self.filter_parish.set_text('') - self.filter_zip.set_text('') + self.filter_locality.set_text('') self.filter_city.set_text('') self.filter_county.set_text('') self.filter_state.set_text('') self.filter_country.set_text('') + self.filter_zip.set_text('') + self.filter_parish.set_text('') self.filter_note.set_text('') self.generic.set_active(0) @@ -110,18 +114,19 @@ class PlaceSidebarFilter(SidebarFilter): gid = unicode(self.filter_id.get_text()).strip() title = unicode(self.filter_title.get_text()).strip() street = unicode(self.filter_street.get_text()).strip() - parish = unicode(self.filter_parish.get_text()).strip() - zipc = unicode(self.filter_zip.get_text()).strip() + locality = unicode(self.filter_locality.get_text()).strip() city = unicode(self.filter_city.get_text()).strip() county = unicode(self.filter_county.get_text()).strip() state = unicode(self.filter_state.get_text()).strip() country = unicode(self.filter_country.get_text()).strip() + zipc = unicode(self.filter_zip.get_text()).strip() + parish = unicode(self.filter_parish.get_text()).strip() note = unicode(self.filter_note.get_text()).strip() regex = self.filter_regex.get_active() gen = self.generic.get_active() > 0 - empty = not (gid or title or street or parish or zipc or city or county - or state or country or note or regex or gen) + empty = not (gid or title or street or locality or city or county or + state or country or zipc or parish or note or regex or gen) if empty: generic_filter = None else: @@ -133,7 +138,8 @@ class PlaceSidebarFilter(SidebarFilter): rule = HasIdOf([gid]) generic_filter.add_rule(rule) - rule = HasPlace([title, street, parish, zipc, city, county, state, country]) + rule = HasPlace([title, street, locality, city, county, state, + country, zipc, parish]) generic_filter.add_rule(rule) if note: diff --git a/src/ToolTips.py b/src/ToolTips.py index 2a0aee54b..34a12e341 100644 --- a/src/ToolTips.py +++ b/src/ToolTips.py @@ -141,6 +141,7 @@ class RepositoryTip(object): % ( _("Location"), escape(address.get_street()), + escape(address.get_locality()), escape(address.get_city()), escape(address.get_county()), escape(address.get_state()), diff --git a/src/gen/db/upgrade.py b/src/gen/db/upgrade.py index 13538c358..96dca3421 100644 --- a/src/gen/db/upgrade.py +++ b/src/gen/db/upgrade.py @@ -82,6 +82,7 @@ def gramps_upgrade_15(self): tags = [tag_handle] else: tags = [] + address_list = [convert_address(addr) for addr in address_list] new_primary_name = convert_name_15(primary_name) new_alternate_names = [convert_name_15(altname) for altname in alternate_names] @@ -186,6 +187,8 @@ def gramps_upgrade_15(self): for handle in self.place_map.keys(): place = self.place_map[handle] new_place = list(place) + new_place[5] = convert_location(new_place[5]) + new_place[6] = [convert_location(loc) for loc in new_place[6]] new_place = new_place[:11] + new_place[12:] new_place = tuple(new_place) with BSDDBTxn(self.env, self.place_map) as txn: @@ -243,6 +246,18 @@ def convert_marker(self, marker_field): else: return None +def convert_locbase(loc): + """Convert location base to include an empty locality field.""" + return tuple([loc[0], u''] + list(loc[1:])) + +def convert_location(loc): + """Convert a location into the new format.""" + return (convert_locbase(loc[0]), loc[1]) + +def convert_address(addr): + """Convert an address into the new format.""" + return (addr[0], addr[1], addr[2], addr[3], convert_locbase(addr[4])) + def convert_name_15(name): (privacy, source_list, note_list, date, first_name, surname, suffix, title, diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 8168e7b16..f0485d1d1 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -528,6 +528,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): try: owner_data = self.metadata.get('researcher') if owner_data: + if len(owner_data[0]) == 7: # Pre-3.3 format + owner_data = upgrade_researcher(owner_data) self.owner.unserialize(owner_data) except ImportError: #handle problems with pre-alpha 3.0 pass @@ -1837,6 +1839,14 @@ def write_lock_file(name): f.write(text) f.close() +def upgrade_researcher(owner_data): + """ + Upgrade researcher data to include a locality field in the address. + This should be called for databases prior to Gramps 3.3. + """ + addr = tuple([owner_data[0][0], ''] + list(owner_data[0][1:])) + return (addr, owner_data[1], owner_data[2], owner_data[3]) + if __name__ == "__main__": import os, sys, pdb diff --git a/src/gen/lib/locationbase.py b/src/gen/lib/locationbase.py index ac8d05436..b649c2cb6 100644 --- a/src/gen/lib/locationbase.py +++ b/src/gen/lib/locationbase.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,6 +42,7 @@ class LocationBase(object): """ if source: self.street = source.street + self.locality = source.locality self.city = source.city self.county = source.county self.state = source.state @@ -49,6 +51,7 @@ class LocationBase(object): self.phone = source.phone else: self.street = "" + self.locality = "" self.city = "" self.county = "" self.state = "" @@ -60,15 +63,15 @@ class LocationBase(object): """ Convert the object to a serialized tuple of data. """ - return (self.street, self.city, self.county, self.state, + return (self.street, self.locality, self.city, self.county, self.state, self.country, self.postal, self.phone) def unserialize(self, data): """ Convert a serialized tuple of data to an object. """ - (self.street, self.city, self.county, self.state, self.country, - self.postal, self.phone) = data + (self.street, self.locality, self.city, self.county, self.state, + self.country, self.postal, self.phone) = data return self def get_text_data_list(self): @@ -88,6 +91,14 @@ class LocationBase(object): """Return the street portion of the Location.""" return self.street + def set_locality(self, val): + """Set the locality portion of the Location.""" + self.locality = val + + def get_locality(self): + """Return the locality portion of the Location.""" + return self.locality + def set_city(self, data): """Set the city name of the LocationBase object.""" self.city = data diff --git a/src/gen/plug/report/utils.py b/src/gen/plug/report/utils.py index add0eb91e..57967047f 100644 --- a/src/gen/plug/report/utils.py +++ b/src/gen/plug/report/utils.py @@ -218,6 +218,7 @@ def get_address_str(addr): """ str = "" elems = [ addr.get_street(), + addr.get_locality(), addr.get_city(), addr.get_county(), addr.get_state(), diff --git a/src/gen/proxy/private.py b/src/gen/proxy/private.py index 35e06d908..081f57251 100644 --- a/src/gen/proxy/private.py +++ b/src/gen/proxy/private.py @@ -611,12 +611,13 @@ def sanitize_address(db, address): new_address = Address() new_address.set_street(address.get_street()) + new_address.set_locality(address.get_locality()) new_address.set_city(address.get_city()) - new_address.set_postal_code(address.get_postal_code()) - new_address.set_phone(address.get_phone()) + new_address.set_county(address.get_county()) new_address.set_state(address.get_state()) new_address.set_country(address.get_country()) - new_address.set_county(address.get_county()) + new_address.set_postal_code(address.get_postal_code()) + new_address.set_phone(address.get_phone()) new_address.set_date_object(address.get_date_object()) copy_source_ref_list(db, address, new_address) diff --git a/src/glade/editlocation.glade b/src/glade/editlocation.glade index 886840c8e..4f7b9f228 100644 --- a/src/glade/editlocation.glade +++ b/src/glade/editlocation.glade @@ -32,8 +32,8 @@ city - 1 - 2 + 2 + 3 GTK_FILL @@ -42,13 +42,14 @@ True True + The town or city where the place is. 1 2 - 1 - 2 + 2 + 3 @@ -88,6 +89,7 @@ True True + Lowest clergical division of this place. Typically used for church sources that only mention the parish. @@ -108,8 +110,8 @@ county - 2 - 3 + 3 + 4 GTK_FILL @@ -118,13 +120,14 @@ True True + Third level of place division. Eg., in the USA a county. 1 2 - 2 - 3 + 3 + 4 @@ -150,6 +153,7 @@ True True + Second level of place division, eg., in the USA a state, in Germany a Bundesland. @@ -170,8 +174,8 @@ country - 3 - 4 + 4 + 5 GTK_FILL @@ -180,13 +184,14 @@ True True + The country where the place is. 1 2 - 3 - 4 + 4 + 5 @@ -230,6 +235,8 @@ phone + 2 + 3 4 5 GTK_FILL @@ -243,8 +250,8 @@ - 1 - 2 + 3 + 4 4 5 @@ -254,6 +261,7 @@ True True + Lowest level of a place division: eg the street name. @@ -263,10 +271,34 @@ - + + True + 0 + _Locality: + True + locality + + + 1 + 2 + GTK_FILL + + - + + True + True + A district within, or a settlement near to, a town or city. + + + + 1 + 2 + 1 + 2 + + diff --git a/src/glade/editplace.glade b/src/glade/editplace.glade index 431c808af..e1c0480b8 100644 --- a/src/glade/editplace.glade +++ b/src/glade/editplace.glade @@ -198,8 +198,8 @@ You can set these values via the Geography View by searching the place, or via a city - 1 - 2 + 2 + 3 GTK_FILL @@ -228,7 +228,7 @@ Use Alternate Locations tab to store the current name. 1 - 2 + 4 @@ -236,15 +236,15 @@ Use Alternate Locations tab to store the current name. True True - The village or city where the place is. + The town or city where the place is. Use Alternate Locations tab to store the current name. 1 2 - 1 - 2 + 2 + 3 @@ -291,8 +291,8 @@ Use Alternate Locations tab to store the current name. county - 2 - 3 + 3 + 4 GTK_FILL @@ -307,8 +307,8 @@ Use Alternate Locations tab to store the current name. 1 2 - 2 - 3 + 3 + 4 @@ -355,8 +355,8 @@ Use Alternate Locations tab to store the current name. country - 3 - 4 + 4 + 5 GTK_FILL @@ -372,8 +372,8 @@ Use Alternate Locations tab to store the current name. 1 2 - 3 - 4 + 4 + 5 @@ -418,6 +418,8 @@ Use Alternate Locations tab to store the current name. phone + 2 + 3 4 5 GTK_FILL @@ -431,24 +433,43 @@ Use Alternate Locations tab to store the current name. - 1 - 2 + 3 + 4 4 5 - + + True + 0 + _Locality: + True + locality + + + 1 + 2 + GTK_FILL + + - - - - - - - + + True + True + A district within, or a settlement near to, a town or city. +Use Alternate Locations tab to store the current name. + + + + 1 + 2 + 1 + 2 + + diff --git a/src/gui/editors/displaytabs/locationembedlist.py b/src/gui/editors/displaytabs/locationembedlist.py index 44d5af797..8ca311ca9 100644 --- a/src/gui/editors/displaytabs/locationembedlist.py +++ b/src/gui/editors/displaytabs/locationembedlist.py @@ -45,17 +45,18 @@ from embeddedlist import EmbeddedList #------------------------------------------------------------------------- class LocationEmbedList(EmbeddedList): - _HANDLE_COL = 5 + _HANDLE_COL = 6 _DND_TYPE = DdTargets.LOCATION #index = column in model. Value = # (name, sortcol in model, width, markup/text, weigth_col _column_names = [ (_('Street'), 0, 150, 0, -1), - (_('City'), 1, 100, 0, -1), - (_('County'), 2, 100, 0, -1), - (_('State/Province'), 3, 100, 0, -1), - (_('Country'), 4, 75, 0, -1), + (_('Locality'), 1, 100, 0, -1), + (_('City'), 2, 100, 0, -1), + (_('County'), 3, 100, 0, -1), + (_('State'), 4, 100, 0, -1), + (_('Country'), 5, 75, 0, -1), ] def __init__(self, dbstate, uistate, track, data): @@ -68,7 +69,7 @@ class LocationEmbedList(EmbeddedList): return self.data def column_order(self): - return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4)) + return ((1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)) def add_button_clicked(self, obj): loc = gen.lib.Location() diff --git a/src/gui/editors/displaytabs/locationmodel.py b/src/gui/editors/displaytabs/locationmodel.py index bbbe32ecd..f64e447bd 100644 --- a/src/gui/editors/displaytabs/locationmodel.py +++ b/src/gui/editors/displaytabs/locationmodel.py @@ -42,8 +42,8 @@ import gtk class LocationModel(gtk.ListStore): def __init__(self, obj_list, db): - gtk.ListStore.__init__(self, str, str, str, str, str, object) + gtk.ListStore.__init__(self, str, str, str, str, str, str, object) self.db = db for obj in obj_list: - self.append(row=[obj.street, obj.city, obj.county, + self.append(row=[obj.street, obj.locality, obj.city, obj.county, obj.state, obj.country, obj, ]) diff --git a/src/gui/editors/editlocation.py b/src/gui/editors/editlocation.py index 4ef5c5c14..b49c5a889 100644 --- a/src/gui/editors/editlocation.py +++ b/src/gui/editors/editlocation.py @@ -2,7 +2,8 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# 2009 Gary Burton +# Copyright (C) 2009 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,6 +57,12 @@ class EditLocation(EditSecondary): self.obj.get_street, self.db.readonly) + self.locality = MonitoredEntry( + self.top.get_object("locality"), + self.obj.set_locality, + self.obj.get_locality, + self.db.readonly) + self.city = MonitoredEntry( self.top.get_object("city"), self.obj.set_city, diff --git a/src/gui/editors/editplace.py b/src/gui/editors/editplace.py index ad89ac798..bbb9a1f49 100644 --- a/src/gui/editors/editplace.py +++ b/src/gui/editors/editplace.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2009 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -159,6 +160,10 @@ class EditPlace(EditPrimary): mloc.set_street, mloc.get_street, self.db.readonly) + self.locality = MonitoredEntry(self.top.get_object("locality"), + mloc.set_locality, mloc.get_locality, + self.db.readonly) + self.city = MonitoredEntry(self.top.get_object("city"), mloc.set_city, mloc.get_city, self.db.readonly) diff --git a/src/gui/selectors/selectplace.py b/src/gui/selectors/selectplace.py index 434e2dfca..1be1b8096 100644 --- a/src/gui/selectors/selectplace.py +++ b/src/gui/selectors/selectplace.py @@ -2,7 +2,8 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham -# 2009-2010 Gary Burton +# Copyright (C) 2009-2010 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,14 +59,15 @@ class SelectPlace(BaseSelector): def get_column_titles(self): return [ - (_('Title'), 350, BaseSelector.TEXT, 0), - (_('ID'), 75, BaseSelector.TEXT, 1), - (_('Street'), 75, BaseSelector.TEXT, 11), - (_('Parish'), 75, BaseSelector.TEXT, 2), - (_('City'), 75, BaseSelector.TEXT, 4), - (_('County'), 75, BaseSelector.TEXT, 5), - (_('State'), 75, BaseSelector.TEXT, 6), - (_('Country'), 75, BaseSelector.TEXT, 7), + (_('Title'), 350, BaseSelector.TEXT, 0), + (_('ID'), 75, BaseSelector.TEXT, 1), + (_('Street'), 75, BaseSelector.TEXT, 2), + (_('Locality'), 75, BaseSelector.TEXT, 3), + (_('City'), 75, BaseSelector.TEXT, 4), + (_('County'), 75, BaseSelector.TEXT, 5), + (_('State'), 75, BaseSelector.TEXT, 6), + (_('Country'), 75, BaseSelector.TEXT, 7), + (_('Parish'), 75, BaseSelector.TEXT, 9), ] def get_from_handle_func(self): diff --git a/src/gui/views/treemodels/placemodel.py b/src/gui/views/treemodels/placemodel.py index b43bc2485..815478534 100644 --- a/src/gui/views/treemodels/placemodel.py +++ b/src/gui/views/treemodels/placemodel.py @@ -77,7 +77,7 @@ COUNTRYLEVELS = { #------------------------------------------------------------------------- class PlaceBaseModel(object): - HANDLE_COL = 13 + HANDLE_COL = 14 def __init__(self, db): self.gen_cursor = db.get_place_cursor @@ -85,16 +85,17 @@ class PlaceBaseModel(object): self.fmap = [ self.column_name, self.column_id, - self.column_parish, - self.column_postal_code, + self.column_street, + self.column_locality, self.column_city, self.column_county, self.column_state, self.column_country, + self.column_postal_code, + self.column_parish, self.column_latitude, self.column_longitude, self.column_change, - self.column_street, self.column_place_name, self.column_handle, self.column_tooltip @@ -102,16 +103,17 @@ class PlaceBaseModel(object): self.smap = [ self.column_name, self.column_id, - self.column_parish, - self.column_postal_code, + self.column_street, + self.column_locality, self.column_city, self.column_county, self.column_state, self.column_country, + self.column_postal_code, + self.column_parish, self.sort_latitude, self.sort_longitude, self.sort_change, - self.column_street, self.column_place_name, self.column_handle, ] @@ -152,33 +154,39 @@ class PlaceBaseModel(object): except: return u'' - def column_city(self, data): + def column_locality(self, data): try: return data[5][0][1] except: return u'' + + def column_city(self, data): + try: + return data[5][0][2] + except: + return u'' def column_county(self, data): try: - return data[5][0][2] + return data[5][0][3] except: return u'' def column_state(self, data): try: - return data[5][0][3] + return data[5][0][4] except: return u'' def column_country(self, data): try: - return data[5][0][4] + return data[5][0][5] except: return u'' def column_postal_code(self, data): try: - return data[5][0][5] + return data[5][0][6] except: return u'' @@ -213,7 +221,7 @@ class PlaceListModel(PlaceBaseModel, FlatBaseModel): skip=set(), sort_map=None): PlaceBaseModel.__init__(self, db) - FlatBaseModel.__init__(self, db, scol, order, tooltip_column=14, + FlatBaseModel.__init__(self, db, scol, order, tooltip_column=15, search=search, skip=skip, sort_map=sort_map) def column_name(self, data): @@ -233,7 +241,7 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): PlaceBaseModel.__init__(self, db) TreeBaseModel.__init__(self, db, scol=scol, order=order, - tooltip_column=14, + tooltip_column=15, search=search, skip=skip, sort_map=sort_map, nrgroups = 3, group_can_have_handle = True) @@ -243,7 +251,7 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): PlaceBaseModel """ self.number_items = self.db.get_number_of_places - self.hmap = [self.column_header] + [None]*13 + self.hmap = [self.column_header] + [None]*14 def get_tree_levels(self): """ @@ -260,17 +268,17 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): """ if data[5] is None: # No primary location - level = [''] * 5 + level = [''] * 6 else: - #country, state, county, city, street - level = [data[5][0][i] for i in range(4,-1,-1)] + #country, state, county, city, locality, street + level = [data[5][0][i] for i in range(5,-1,-1)] node1 = (level[0], ) node2 = (level[1], level[0]) node3 = (level[2], level[1], level[0]) sort_key = self.sort_func(data) - if not (level[3] or level[4]): + if not (level[3] or level[4] or level[5]): if level[2]: self.add_node(None, node1, level[0], None, add_parent=False) self.add_node(node1, node2, level[1], None, add_parent=False) @@ -298,13 +306,11 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): def column_name(self, data): name = '' if data[5] is not None: - level = [data[5][0][i] for i in range(4,-1,-1)] - if not (level[3] or level[4]): + level = [data[5][0][i] for i in range(5,-1,-1)] + if not (level[3] or level[4] or level[5]): name = unicode(level[2] or level[1] or level[0]) - elif level[3] and level[4]: - name = unicode(level[3] + ', ' + level[4]) - elif level[3] or level[4]: - name = unicode(level[3] or level[4]) + else: + name = ', '.join([item for item in level[3:] if item]) if not name: name = unicode(data[2]) diff --git a/src/plugins/export/ExportXml.py b/src/plugins/export/ExportXml.py index 4e0914670..6d6f53a8f 100644 --- a/src/plugins/export/ExportXml.py +++ b/src/plugins/export/ExportXml.py @@ -585,6 +585,7 @@ class GrampsXmlWriter(UpdateCallback): self.g.write('%s\n' % (sp,conf_priv(address))) self.write_date(address.get_date_object(),index+1) self.write_line("street",address.get_street(),index+1) + self.write_line("locality",address.get_locality(),index+1) self.write_line("city",address.get_city(),index+1) self.write_line("county",address.get_county(),index+1) self.write_line("state",address.get_state(),index+1) @@ -950,45 +951,51 @@ class GrampsXmlWriter(UpdateCallback): def build_place_title(self,loc): "Builds a title from a location" - city = self.fix(loc.get_city()) street = self.fix(loc.get_street()) + locality = self.fix(loc.get_locality()) + city = self.fix(loc.get_city()) parish = self.fix(loc.get_parish()) + county = self.fix(loc.get_county()) state = self.fix(loc.get_state()) country = self.fix(loc.get_country()) - county = self.fix(loc.get_county()) value = "" if street: value = street + if locality: + value = self.append_value(value, locality) if city: - value = self.append_value(value,city) + value = self.append_value(value, city) if parish: - value = self.append_value(value,parish) + value = self.append_value(value, parish) if county: - value = self.append_value(value,county) + value = self.append_value(value, county) if state: - value = self.append_value(value,state) + value = self.append_value(value, state) if country: - value = self.append_value(value,country) + value = self.append_value(value, country) return value def dump_location(self,loc): "Writes the location information to the output file" if loc.is_empty(): return + street = self.fix(loc.get_street()) + locality = self.fix(loc.get_locality()) city = self.fix(loc.get_city()) parish = self.fix(loc.get_parish()) + county = self.fix(loc.get_county()) state = self.fix(loc.get_state()) country = self.fix(loc.get_country()) - county = self.fix(loc.get_county()) zip_code = self.fix(loc.get_postal_code()) phone = self.fix(loc.get_phone()) - street = self.fix(loc.get_street()) self.g.write(' 0: self.placeobj.add_alternate_locations(loc) else: @@ -2269,6 +2270,9 @@ class GrampsParser(UpdateCallback): def stop_street(self, tag): self.address.street = tag + def stop_locality(self, tag): + self.address.locality = tag + def stop_city(self, tag): self.address.city = tag diff --git a/src/plugins/lib/libplaceview.py b/src/plugins/lib/libplaceview.py index f2e2e8b37..b205f812f 100644 --- a/src/plugins/lib/libplaceview.py +++ b/src/plugins/lib/libplaceview.py @@ -2,6 +2,7 @@ # # Copyright (C) 2001-2006 Donald N. Allingham # Copyright (C) 2008 Gary Burton +# Copyright (C) 2010 Nick Hall # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,42 +75,44 @@ class PlaceBaseView(ListView): """ COL_NAME = 0 COL_ID = 1 - COL_PARISH = 2 - COL_ZIP = 3 + COL_STREET = 2 + COL_LOCALITY = 3 COL_CITY = 4 COL_COUNTY = 5 COL_STATE = 6 COL_COUNTRY = 7 - COL_LAT = 8 - COL_LON = 9 - COL_CHAN = 10 - COL_STREET = 11 + COL_ZIP = 8 + COL_PARISH = 9 + COL_LAT = 10 + COL_LON = 11 + COL_CHAN = 12 # name of the columns COLUMN_NAMES = [ _('Place Name'), _('ID'), - _('Church Parish'), - _('ZIP/Postal Code'), + _('Street'), + _('Locality'), _('City'), _('County'), _('State'), _('Country'), + _('ZIP/Postal Code'), + _('Church Parish'), _('Latitude'), _('Longitude'), _('Last Changed'), - _('Street'), ] # columns that contain markup MARKUP_COLS = [COL_NAME] # default setting with visible columns, order of the col, and their size CONFIGSETTINGS = ( - ('columns.visible', [COL_NAME, COL_ID, COL_STREET, COL_CITY, COL_STATE - ]), - ('columns.rank', [COL_NAME, COL_ID, COL_STREET, COL_ZIP, COL_CITY, - COL_COUNTY, COL_STATE, COL_COUNTRY, COL_LAT, - COL_LON, COL_PARISH, COL_CHAN]), - ('columns.size', [250, 75, 100, 100, 100, 100, 150, 150, 150, - 150, 150, 100]) + ('columns.visible', [COL_NAME, COL_ID, COL_STREET, COL_LOCALITY, + COL_CITY, COL_COUNTY, COL_STATE]), + ('columns.rank', [COL_NAME, COL_ID, COL_STREET, COL_LOCALITY, COL_CITY, + COL_COUNTY, COL_STATE, COL_COUNTRY, COL_ZIP, + COL_PARISH, COL_LAT, COL_LON, COL_CHAN]), + ('columns.size', [250, 75, 150, 150, 150, 150, 100, 100, 100, + 100, 150, 150, 100]) ) ADD_MSG = _("Add a new place") EDIT_MSG = _("Edit the selected place") @@ -132,7 +135,7 @@ class PlaceBaseView(ListView): ListView.__init__( self, title, dbstate, uistate, - self.COLUMN_NAMES, 13, + self.COLUMN_NAMES, 14, model, signal_map, dbstate.db.get_place_bookmarks(), Bookmarks.PlaceBookmarks, nav_group, diff --git a/src/plugins/textreport/PlaceReport.py b/src/plugins/textreport/PlaceReport.py index 65134c59a..a330dcb21 100644 --- a/src/plugins/textreport/PlaceReport.py +++ b/src/plugins/textreport/PlaceReport.py @@ -121,6 +121,7 @@ class PlaceReport(Report): place_details = [_("Gramps ID: %s ") % place.get_gramps_id(), _("Street: %s ") % location.get_street(), _("Parish: %s ") % location.get_parish(), + _("Locality: %s ") % location.get_locality(), _("City: %s ") % location.get_city(), _("County: %s ") % location.get_county(), _("State: %s") % location.get_state(), diff --git a/src/plugins/view/placetreeview.py b/src/plugins/view/placetreeview.py index 02307e567..add640de9 100644 --- a/src/plugins/view/placetreeview.py +++ b/src/plugins/view/placetreeview.py @@ -53,43 +53,45 @@ class PlaceTreeView(PlaceBaseView): """ COL_PLACE = 0 COL_ID = 1 - COL_PARISH = 2 - COL_ZIP = 3 + COL_STREET = 2 + COL_LOCALITY = 3 COL_CITY = 4 COL_COUNTY = 5 COL_STATE = 6 COL_COUNTRY = 7 - COL_LAT = 8 - COL_LON = 9 - COL_CHAN = 10 - COL_STREET = 11 - COL_NAME = 12 + COL_ZIP = 8 + COL_PARISH = 9 + COL_LAT = 10 + COL_LON = 11 + COL_CHAN = 12 + COL_NAME = 13 # name of the columns COLUMN_NAMES = [ _('Place'), _('ID'), - _('Church Parish'), - _('ZIP/Postal Code'), + _('Street'), + _('Locality'), _('City'), _('County'), _('State'), _('Country'), + _('ZIP/Postal Code'), + _('Church Parish'), _('Latitude'), _('Longitude'), _('Last Changed'), - _('Street'), _('Place Name'), ] # default setting with visible columns, order of the col, and their size CONFIGSETTINGS = ( - ('columns.visible', [COL_PLACE, COL_ID, COL_STREET, COL_CITY, COL_STATE - ]), - ('columns.rank', [COL_PLACE, COL_ID, COL_STREET, COL_ZIP, COL_CITY, - COL_COUNTY, COL_STATE, COL_COUNTRY, COL_LAT, - COL_LON, COL_PARISH, COL_CHAN, COL_NAME]), - ('columns.size', [250, 75, 100, 100, 100, 100, 150, 150, 150, - 150, 150, 100, 150]) - ) + ('columns.visible', [COL_PLACE, COL_ID, COL_STREET, COL_LOCALITY, + COL_CITY, COL_COUNTY, COL_STATE]), + ('columns.rank', [COL_PLACE, COL_ID, COL_STREET, COL_LOCALITY, COL_CITY, + COL_COUNTY, COL_STATE, COL_COUNTRY, COL_ZIP, + COL_PARISH, COL_LAT, COL_LON, COL_CHAN, COL_NAME]), + ('columns.size', [250, 75, 150, 150, 150, 150, 100, 100, 100, + 100, 150, 150, 100, 150]) + ) def __init__(self, dbstate, uistate): PlaceBaseView.__init__(self, dbstate, uistate,