From 9c14d3b487448bb62e61246c877f3e9059a91427 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 29 Oct 2010 23:11:08 +0000 Subject: [PATCH] GEPS 006: Add Locality to researcher svn: r16082 --- src/Utils.py | 40 ++++++----- src/config.py | 1 + src/gen/lib/researcher.py | 3 +- src/gui/configure.py | 13 ++-- src/gui/views/treemodels/repomodel.py | 12 ++-- src/plugins/export/ExportGedcom.py | 8 +++ src/plugins/export/ExportXml.py | 1 + src/plugins/import/ImportXml.py | 13 ++-- src/plugins/lib/libgedcom.py | 25 ++++++- src/plugins/tool/OwnerEditor.py | 19 ++--- src/plugins/tool/ownereditor.glade | 99 +++++++++++++++++---------- src/plugins/view/repoview.py | 23 +++---- 12 files changed, 164 insertions(+), 93 deletions(-) diff --git a/src/Utils.py b/src/Utils.py index 37d4ee4da..71f5dd6bb 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1219,27 +1219,29 @@ def get_translations(): # #------------------------------------------------------------------------- def get_researcher(): - import gen.lib - import config - - n = config.get('researcher.researcher-name') - a = config.get('researcher.researcher-addr') - c = config.get('researcher.researcher-city') - s = config.get('researcher.researcher-state') - ct = config.get('researcher.researcher-country') - p = config.get('researcher.researcher-postal') - ph = config.get('researcher.researcher-phone') - e = config.get('researcher.researcher-email') + """ + Return a new database owner with the default values from the config file. + """ + name = config.get('researcher.researcher-name') + address = config.get('researcher.researcher-addr') + locality = config.get('researcher.researcher-locality') + city = config.get('researcher.researcher-city') + state = config.get('researcher.researcher-state') + country = config.get('researcher.researcher-country') + post_code = config.get('researcher.researcher-postal') + phone = config.get('researcher.researcher-phone') + email = config.get('researcher.researcher-email') owner = gen.lib.Researcher() - owner.set_name(n) - owner.set_address(a) - owner.set_city(c) - owner.set_state(s) - owner.set_country(ct) - owner.set_postal_code(p) - owner.set_phone(ph) - owner.set_email(e) + owner.set_name(name) + owner.set_address(address) + owner.set_locality(locality) + owner.set_city(city) + owner.set_state(state) + owner.set_country(country) + owner.set_postal_code(post_code) + owner.set_phone(phone) + owner.set_email(email) return owner diff --git a/src/config.py b/src/config.py index 6d6002def..b46504ab0 100644 --- a/src/config.py +++ b/src/config.py @@ -286,6 +286,7 @@ register('preferences.last-view', '') register('preferences.last-views', []) register('researcher.researcher-addr', '') +register('researcher.researcher-locality', '') register('researcher.researcher-city', '') register('researcher.researcher-country', '') register('researcher.researcher-email', '') diff --git a/src/gen/lib/researcher.py b/src/gen/lib/researcher.py index 78b5afe39..243ce99c2 100644 --- a/src/gen/lib/researcher.py +++ b/src/gen/lib/researcher.py @@ -97,6 +97,7 @@ class Researcher(LocationBase): def set_from(self, other_researcher): """Set all attributes from another instance.""" self.street = other_researcher.street + self.locality = other_researcher.locality self.city = other_researcher.city self.county = other_researcher.county self.state = other_researcher.state @@ -110,6 +111,6 @@ class Researcher(LocationBase): def get(self): return [getattr(self, value) for value in - ['name', 'addr', 'city', 'state', + ['name', 'addr', 'locality', 'city', 'state', 'country', 'postal', 'phone', 'email'] ] diff --git a/src/gui/configure.py b/src/gui/configure.py index eafd483ba..dc96a1341 100644 --- a/src/gui/configure.py +++ b/src/gui/configure.py @@ -426,12 +426,13 @@ class GrampsPreferences(ConfigureDialog): table.set_row_spacings(6) self.add_entry(table, _('Name'), 0, 'researcher.researcher-name') self.add_entry(table, _('Address'), 1, 'researcher.researcher-addr') - self.add_entry(table, _('City'), 2, 'researcher.researcher-city') - self.add_entry(table, _('State/Province'), 3, 'researcher.researcher-state') - self.add_entry(table, _('Country'), 4, 'researcher.researcher-country') - self.add_entry(table, _('ZIP/Postal Code'), 5, 'researcher.researcher-postal') - self.add_entry(table, _('Phone'), 6, 'researcher.researcher-phone') - self.add_entry(table, _('Email'), 7, 'researcher.researcher-email') + self.add_entry(table, _('Locality'), 2, 'researcher.researcher-locality') + self.add_entry(table, _('City'), 3, 'researcher.researcher-city') + self.add_entry(table, _('State/County'), 4, 'researcher.researcher-state') + self.add_entry(table, _('Country'), 5, 'researcher.researcher-country') + self.add_entry(table, _('ZIP/Postal Code'), 6, 'researcher.researcher-postal') + self.add_entry(table, _('Phone'), 7, 'researcher.researcher-phone') + self.add_entry(table, _('Email'), 8, 'researcher.researcher-email') return _('Researcher'), table def add_prefix_panel(self, configdialog): diff --git a/src/gui/views/treemodels/repomodel.py b/src/gui/views/treemodels/repomodel.py index 803b93c7f..5dfda3e32 100644 --- a/src/gui/views/treemodels/repomodel.py +++ b/src/gui/views/treemodels/repomodel.py @@ -63,11 +63,11 @@ class RepositoryModel(FlatBaseModel): self.column_type, self.column_home_url, self.column_street, - self.column_postal_code, + self.column_locality, self.column_city, - self.column_county, self.column_state, self.column_country, + self.column_postal_code, self.column_email, self.column_search_url, self.column_change, @@ -81,11 +81,11 @@ class RepositoryModel(FlatBaseModel): self.column_type, self.column_home_url, self.column_street, - self.column_postal_code, + self.column_locality, self.column_city, - self.column_county, self.column_state, self.column_country, + self.column_postal_code, self.column_email, self.column_search_url, self.sort_change, @@ -132,12 +132,12 @@ class RepositoryModel(FlatBaseModel): except: return u'' - def column_county(self,data): + def column_locality(self,data): try: if data[5]: addr = gen.lib.Address() addr.unserialize(data[5][0]) - return addr.get_county() + return addr.get_locality() else: return u'' except: diff --git a/src/plugins/export/ExportGedcom.py b/src/plugins/export/ExportGedcom.py index 95bce2b77..eb7cd01b2 100644 --- a/src/plugins/export/ExportGedcom.py +++ b/src/plugins/export/ExportGedcom.py @@ -382,6 +382,8 @@ class GedcomWriter(UpdateCallback): self.__writeln(2, "CONT", "%s, %s %s" % (city, state, post)) else: self.__writeln(2, "CONT", u"Not Provided") + if addr: + self.__writeln(2, "ADR1", addr) if adr2: self.__writeln(2, "ADR2", adr2) if city: @@ -683,6 +685,8 @@ class GedcomWriter(UpdateCallback): self.__writeln(1, 'RESI') self.__date(2, addr.get_date_object()) self.__writeln(2, "ADDR", addr.get_street()) + if addr.get_street(): + self.__writeln(3, 'ADR1', addr.get_street()) if addr.get_locality(): self.__writeln(3, 'ADR2', addr.get_locality()) if addr.get_city(): @@ -1011,6 +1015,8 @@ class GedcomWriter(UpdateCallback): self.__writeln(1, 'NAME', repo.get_name()) for addr in repo.get_address_list(): self.__writeln(1, "ADDR", addr.get_street()) + if addr.get_street(): + self.__writeln(2, 'ADR1', addr.get_street()) if addr.get_locality(): self.__writeln(2, 'ADR2', addr.get_locality()) if addr.get_city(): @@ -1367,6 +1373,8 @@ class GedcomWriter(UpdateCallback): location = place.get_main_location() if location and not location.is_empty(): self.__writeln(level, "ADDR", location.get_street()) + if location.get_street(): + self.__writeln(level + 1, 'ADR1', location.get_street()) if location.get_locality(): self.__writeln(level + 1, 'ADR2', location.get_locality()) if location.get_city(): diff --git a/src/plugins/export/ExportXml.py b/src/plugins/export/ExportXml.py index 6d6f53a8f..e7775845b 100644 --- a/src/plugins/export/ExportXml.py +++ b/src/plugins/export/ExportXml.py @@ -221,6 +221,7 @@ class GrampsXmlWriter(UpdateCallback): self.g.write(" \n") self.write_line("resname", owner.get_name(),3) self.write_line("resaddr", owner.get_address(),3) + self.write_line("reslocality", owner.get_locality(),3) self.write_line("rescity", owner.get_city(),3) self.write_line("resstate", owner.get_state(),3) self.write_line("rescountry", owner.get_country(),3) diff --git a/src/plugins/import/ImportXml.py b/src/plugins/import/ImportXml.py index 9dbffdfdb..09d81643e 100644 --- a/src/plugins/import/ImportXml.py +++ b/src/plugins/import/ImportXml.py @@ -533,10 +533,11 @@ class GrampsParser(UpdateCallback): "postal": (None, self.stop_postal), "range": (self.start_range, None), "researcher": (None, self.stop_research), - "resname": (None, self.stop_resname ), - "resaddr": (None, self.stop_resaddr ), - "rescity": (None, self.stop_rescity ), - "resstate": (None, self.stop_resstate ), + "resname": (None, self.stop_resname), + "resaddr": (None, self.stop_resaddr), + "reslocality": (None, self.stop_reslocality), + "rescity": (None, self.stop_rescity), + "resstate": (None, self.stop_resstate), "rescountry": (None, self.stop_rescountry), "respostal": (None, self.stop_respostal), "resphone": (None, self.stop_resphone), @@ -2442,6 +2443,7 @@ class GrampsParser(UpdateCallback): def stop_research(self, tag): self.owner.set_name(self.resname) self.owner.set_address(self.resaddr) + self.owner.set_locality(self.reslocality) self.owner.set_city(self.rescity) self.owner.set_state(self.resstate) self.owner.set_country(self.rescon) @@ -2455,6 +2457,9 @@ class GrampsParser(UpdateCallback): def stop_resaddr(self, tag): self.resaddr = tag + def stop_reslocality(self, tag): + self.reslocality = tag + def stop_rescity(self, tag): self.rescity = tag diff --git a/src/plugins/lib/libgedcom.py b/src/plugins/lib/libgedcom.py index a646df69d..a72040bee 100644 --- a/src/plugins/lib/libgedcom.py +++ b/src/plugins/lib/libgedcom.py @@ -2036,7 +2036,7 @@ class GedcomParser(UpdateCallback): self.parse_loc_tbl = { TOKEN_ADDR : self.__location_addr, - TOKEN_ADR1 : self.__location_addr, + TOKEN_ADR1 : self.__location_adr1, TOKEN_ADR2 : self.__location_adr2, TOKEN_DATE : self.__location_date, TOKEN_CITY : self.__location_city, @@ -2136,6 +2136,7 @@ class GedcomParser(UpdateCallback): self.parse_addr_tbl = { TOKEN_DATE : self.__address_date, + TOKEN_ADR1 : self.__address_adr1, TOKEN_ADR2 : self.__address_adr2, TOKEN_CITY : self.__address_city, TOKEN_STAE : self.__address_state, @@ -4644,6 +4645,17 @@ class GedcomParser(UpdateCallback): """ state.addr.set_date_object(line.data) + def __address_adr1(self, line, state): + """ + Parses the ADR1 line of an ADDR tag + + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + state.addr.set_street(line.data) + def __address_adr2(self, line, state): """ Parses the ADR2 line of an ADDR tag @@ -5348,6 +5360,17 @@ class GedcomParser(UpdateCallback): state.location = gen.lib.Location() state.location.set_date_object(line.data) + def __location_adr1(self, line, state): + """ + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + if not state.location: + state.location = gen.lib.Location() + state.location.set_street(line.data) + def __location_adr2(self, line, state): """ @param line: The current line in GedLine format diff --git a/src/plugins/tool/OwnerEditor.py b/src/plugins/tool/OwnerEditor.py index abff6ab58..5d46fa586 100644 --- a/src/plugins/tool/OwnerEditor.py +++ b/src/plugins/tool/OwnerEditor.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2008 Brian G. Matherly # Copyright (C) 2010 Jakim Friant +# 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 @@ -62,6 +63,7 @@ WIKI_HELP_SEC = _('manual|Edit_Database_Owner_Information...') config_keys = ( 'researcher.researcher-name', 'researcher.researcher-addr', + 'researcher.researcher-locality', 'researcher.researcher-city', 'researcher.researcher-state', 'researcher.researcher-country', @@ -122,14 +124,15 @@ class OwnerEditor(tool.Tool, ManagedWindow.ManagedWindow): self.entries = [] entry = [ - ("entry1", self.owner.set_name, self.owner.get_name), - ("entry2", self.owner.set_address, self.owner.get_address), - ("entry3", self.owner.set_city, self.owner.get_city), - ("entry4", self.owner.set_state, self.owner.get_state), - ("entry5", self.owner.set_country, self.owner.get_country), - ("entry6", self.owner.set_postal_code, self.owner.get_postal_code), - ("entry7", self.owner.set_phone, self.owner.get_phone), - ("entry8", self.owner.set_email, self.owner.get_email), + ("name", self.owner.set_name, self.owner.get_name), + ("address", self.owner.set_address, self.owner.get_address), + ("locality", self.owner.set_locality, self.owner.get_locality), + ("city", self.owner.set_city, self.owner.get_city), + ("state", self.owner.set_state, self.owner.get_state), + ("country", self.owner.set_country, self.owner.get_country), + ("zip", self.owner.set_postal_code, self.owner.get_postal_code), + ("phone", self.owner.set_phone, self.owner.get_phone), + ("email", self.owner.set_email, self.owner.get_email), ] for (name,set_fn,get_fn) in entry: diff --git a/src/plugins/tool/ownereditor.glade b/src/plugins/tool/ownereditor.glade index 3664522dd..c9d10303c 100644 --- a/src/plugins/tool/ownereditor.glade +++ b/src/plugins/tool/ownereditor.glade @@ -29,7 +29,7 @@ True 6 - 8 + 9 2 6 6 @@ -48,7 +48,7 @@ True 0 - Address: + Street: 1 @@ -64,8 +64,8 @@ City: - 2 - 3 + 3 + 4 GTK_FILL @@ -74,11 +74,11 @@ True 0 - State/Province: + State/County: - 3 - 4 + 4 + 5 GTK_FILL @@ -90,8 +90,8 @@ Country: - 4 - 5 + 5 + 6 GTK_FILL @@ -103,8 +103,8 @@ ZIP/Postal Code: - 5 - 6 + 6 + 7 GTK_FILL @@ -116,8 +116,8 @@ Phone: - 6 - 7 + 7 + 8 GTK_FILL @@ -129,14 +129,14 @@ Email: - 7 - 8 + 8 + 9 GTK_FILL - + True True @@ -148,7 +148,7 @@ - + True True @@ -162,21 +162,7 @@ - - True - True - - - - 1 - 2 - 2 - 3 - - - - - + True True @@ -190,7 +176,7 @@ - + True True @@ -204,7 +190,7 @@ - + True True @@ -218,7 +204,7 @@ - + True True @@ -232,7 +218,7 @@ - + True True @@ -245,6 +231,47 @@ + + + True + True + + + + 1 + 2 + 8 + 9 + + + + + + True + 0 + Locality: + + + 2 + 3 + GTK_FILL + + + + + + True + True + + + + 1 + 2 + 2 + 3 + + + False diff --git a/src/plugins/view/repoview.py b/src/plugins/view/repoview.py index b03c957bc..3b545e4a8 100644 --- a/src/plugins/view/repoview.py +++ b/src/plugins/view/repoview.py @@ -69,11 +69,11 @@ class RepositoryView(ListView): COL_TYPE = 2 COL_URL = 3 COL_STREET = 4 - COL_ZIP = 5 + COL_LOCALITY = 5 COL_CITY = 6 - COL_COUNTY = 7 - COL_STATE = 8 - COL_COUNTRY = 9 + COL_STATE = 7 + COL_COUNTRY = 8 + COL_ZIP = 9 COL_EMAIL = 10 COL_SURL = 11 COL_CHAN = 12 @@ -84,11 +84,11 @@ class RepositoryView(ListView): _('Type'), _('Home URL'), _('Street'), - _('ZIP/Postal Code'), + _('Locality'), _('City'), - _('County'), - _('State'), + _('State/County'), _('Country'), + _('ZIP/Postal Code'), _('Email'), _('Search URL'), _('Last Changed'), @@ -97,11 +97,10 @@ class RepositoryView(ListView): CONFIGSETTINGS = ( ('columns.visible', [COL_NAME, COL_ID, COL_TYPE, COL_URL, COL_STREET, ]), - ('columns.rank', [COL_NAME, COL_ID, COL_ZIP, COL_CITY, COL_TYPE, - COL_URL, COL_STREET, COL_COUNTY, COL_STATE, - COL_COUNTRY, COL_EMAIL, COL_SURL, - COL_CHAN]), - ('columns.size', [200, 75, 100, 100, 100, 250, 100, 100, 100, + ('columns.rank', [COL_NAME, COL_ID, COL_TYPE, COL_URL, COL_STREET, + COL_LOCALITY, COL_CITY, COL_STATE, COL_COUNTRY, + COL_ZIP, COL_EMAIL, COL_SURL, COL_CHAN]), + ('columns.size', [200, 75, 100, 250, 100, 100, 100, 100, 100, 100, 100, 100, 100]) ) ADD_MSG = _("Add a new repository")