Fix References Tab to update on Deletes of items when editor is open (#864)
Fixes #11231
This commit is contained in:
parent
44104671b9
commit
c0ff650748
@ -67,6 +67,12 @@ class BackRefList(EmbeddedList):
|
|||||||
_('_References'), refmodel)
|
_('_References'), refmodel)
|
||||||
self._callback = callback
|
self._callback = callback
|
||||||
self.connectid = self.model.connect('row-inserted', self.update_label)
|
self.connectid = self.model.connect('row-inserted', self.update_label)
|
||||||
|
self.db_connect = []
|
||||||
|
for item in ['person', 'family', 'source', 'citation', 'event',
|
||||||
|
'media', 'place', 'repository', 'note']:
|
||||||
|
self.db_connect.append(self.dbstate.db.connect(
|
||||||
|
'%s-delete' % item, self.model.delete_row))
|
||||||
|
self.tree.set_reorderable(False)
|
||||||
self.track_ref_for_deletion("model")
|
self.track_ref_for_deletion("model")
|
||||||
|
|
||||||
def update_label(self, *obj):
|
def update_label(self, *obj):
|
||||||
@ -80,6 +86,8 @@ class BackRefList(EmbeddedList):
|
|||||||
|
|
||||||
def _cleanup_local_connects(self):
|
def _cleanup_local_connects(self):
|
||||||
self.model.disconnect(self.connectid)
|
self.model.disconnect(self.connectid)
|
||||||
|
for item in self.db_connect:
|
||||||
|
self.dbstate.db.disconnect(item)
|
||||||
|
|
||||||
def _cleanup_on_exit(self):
|
def _cleanup_on_exit(self):
|
||||||
# model may be destroyed already in closing managedwindow
|
# model may be destroyed already in closing managedwindow
|
||||||
|
@ -55,6 +55,7 @@ class BackRefModel(Gtk.ListStore):
|
|||||||
self.sref_list = sref_list
|
self.sref_list = sref_list
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self.loading = False
|
self.loading = False
|
||||||
|
self.hndl_iter = {}
|
||||||
self.idle = GLib.idle_add(self.load_model().__next__)
|
self.idle = GLib.idle_add(self.load_model().__next__)
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
@ -145,7 +146,17 @@ class BackRefModel(Gtk.ListStore):
|
|||||||
# We need to use localized string in the model.
|
# We need to use localized string in the model.
|
||||||
# we also need to keep class names to get the object type,
|
# we also need to keep class names to get the object type,
|
||||||
# but we don't need to show that in the view.
|
# but we don't need to show that in the view.
|
||||||
self.append(row=[_(dtype), gid, name, handle, dtype])
|
|
||||||
|
self.hndl_iter[ref[1]] = self.append(
|
||||||
|
row=[_(dtype), gid, name, handle, dtype])
|
||||||
yield True
|
yield True
|
||||||
self.loading = False
|
self.loading = False
|
||||||
yield False
|
yield False
|
||||||
|
|
||||||
|
def delete_row(self, hndl_list):
|
||||||
|
""" Remove rows of the model based on the handles """
|
||||||
|
for hndl in hndl_list:
|
||||||
|
miter = self.hndl_iter.get(hndl, None)
|
||||||
|
if miter is not None:
|
||||||
|
self.remove(miter)
|
||||||
|
del self.hndl_iter[hndl]
|
||||||
|
Loading…
Reference in New Issue
Block a user