7842: Fix custom place types in the place editor

Allow place type combobox to receive focus.
Store custom place types in the metadata table.
This commit is contained in:
Nick Hall 2014-06-21 16:07:40 +01:00
parent 604e9ac9aa
commit 2706bfb552
5 changed files with 26 additions and 3 deletions

View File

@ -864,6 +864,13 @@ class DbReadBase(object):
""" """
raise NotImplementedError raise NotImplementedError
def get_place_types(self):
"""
Return a list of all custom place types assocated with Place instances
in the database.
"""
raise NotImplementedError
def gramps_upgrade(self): def gramps_upgrade(self):
""" """
Return True if database is upgraded Return True if database is upgraded

View File

@ -420,6 +420,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.source_media_types = set() self.source_media_types = set()
self.url_types = set() self.url_types = set()
self.media_attributes = set() self.media_attributes = set()
self.place_types = set()
self.open = 0 self.open = 0
self.genderStats = GenderStats() self.genderStats = GenderStats()
@ -1633,6 +1634,13 @@ class DbBsddbRead(DbReadBase, Callback):
""" """
return list(self.url_types) return list(self.url_types)
def get_place_types(self):
"""
Return a list of all custom place types assocated with Place instances
in the database.
"""
return list(self.place_types)
def __log_error(self): def __log_error(self):
pass pass

View File

@ -970,6 +970,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.url_types = set(meta(b'url_types')) self.url_types = set(meta(b'url_types'))
self.media_attributes = set(meta(b'mattr_names')) self.media_attributes = set(meta(b'mattr_names'))
self.event_attributes = set(meta(b'eattr_names')) self.event_attributes = set(meta(b'eattr_names'))
self.place_types = set(meta(b'place_types'))
# surname list # surname list
self.surname_list = meta(b'surname_list') self.surname_list = meta(b'surname_list')
@ -1442,6 +1443,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
txn.put(b'url_types', list(self.url_types)) txn.put(b'url_types', list(self.url_types))
txn.put(b'mattr_names', list(self.media_attributes)) txn.put(b'mattr_names', list(self.media_attributes))
txn.put(b'eattr_names', list(self.event_attributes)) txn.put(b'eattr_names', list(self.event_attributes))
txn.put(b'place_types', list(self.place_types))
# name display formats # name display formats
txn.put(b'surname_list', self.surname_list) txn.put(b'surname_list', self.surname_list)
@ -2017,6 +2019,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.commit_base(place, self.place_map, PLACE_KEY, self.commit_base(place, self.place_map, PLACE_KEY,
transaction, change_time) transaction, change_time)
if place.get_type().is_custom():
self.place_types.add(str(place.get_type()))
self.url_types.update([str(url.type) for url in place.urls self.url_types.update([str(url.type) for url in place.urls
if url.type.is_custom()]) if url.type.is_custom()])

View File

@ -132,7 +132,9 @@ class EditPlace(EditPrimary):
self.place_type = MonitoredDataType(self.top.get_object("place_type"), self.place_type = MonitoredDataType(self.top.get_object("place_type"),
self.obj.set_type, self.obj.set_type,
self.obj.get_type) self.obj.get_type,
self.db.readonly,
self.db.get_place_types())
self.code = MonitoredEntry( self.code = MonitoredEntry(
self.top.get_object("code_entry"), self.top.get_object("code_entry"),

View File

@ -354,12 +354,13 @@ You can set these values via the Geography View by searching the place, or via a
<child> <child>
<object class="GtkComboBox" id="place_type"> <object class="GtkComboBox" id="place_type">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">What type of place this is. Eg 'Country', 'City', ... .</property> <property name="tooltip_text" translatable="yes">What type of place this is. Eg 'Country', 'City', ... .</property>
<property name="has_entry">True</property> <property name="has_entry">True</property>
<child internal-child="entry"> <child internal-child="entry">
<object class="GtkEntry" id="combobox-entry2"> <object class="GtkEntry" id="combobox-entry2">
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="overwrite_mode">True</property>
</object> </object>
</child> </child>
</object> </object>