Support Note LINKS as backlinks

This commit is contained in:
prculley 2020-08-10 11:27:46 -05:00 committed by Nick Hall
parent 11d5a64643
commit f57c38e220
3 changed files with 27 additions and 2 deletions

View File

@ -161,7 +161,14 @@ class Note(BasicPrimaryObject):
:returns: List of (classname, handle) tuples for referenced objects. :returns: List of (classname, handle) tuples for referenced objects.
:rtype: list :rtype: list
""" """
return self.get_referenced_tag_handles() reflist = []
for dom, obj, prop, hndl in self.get_links():
if dom != "gramps" or prop != "handle":
continue
else:
reflist.append((obj, hndl))
reflist.extend(self.get_referenced_tag_handles())
return reflist
def merge(self, acquisition): def merge(self, acquisition):
""" """

View File

@ -134,6 +134,15 @@ class BackRefModel(Gtk.ListStore):
name = p.get_name() name = p.get_name()
gid = p.gramps_id gid = p.gramps_id
handle = p.handle handle = p.handle
elif dtype == 'Note':
p = self.db.get_note_from_handle(ref[1])
if not p:
continue
name = " ".join(p.get().split())
if len(name) > 80:
name = name[:80] + "..."
gid = p.gramps_id
handle = p.handle
else: else:
p = self.db.get_media_from_handle(ref[1]) p = self.db.get_media_from_handle(ref[1])
if not p: if not p:

View File

@ -569,12 +569,14 @@ def get_link_color(context):
return rgb_to_hex((col.red, col.green, col.blue)) return rgb_to_hex((col.red, col.green, col.blue))
def edit_object(dbstate, uistate, reftype, ref): def edit_object(dbstate, uistate, reftype, ref):
""" """
Invokes the appropriate editor for an object type and given handle. Invokes the appropriate editor for an object type and given handle.
""" """
from .editors import (EditEvent, EditPerson, EditFamily, EditSource, from .editors import (EditEvent, EditPerson, EditFamily, EditSource,
EditPlace, EditMedia, EditRepository, EditCitation) EditPlace, EditMedia, EditRepository, EditCitation,
EditNote)
if reftype == 'Person': if reftype == 'Person':
try: try:
@ -642,6 +644,13 @@ def edit_object(dbstate, uistate, reftype, ref):
EditRepository(dbstate, uistate, [], repo) EditRepository(dbstate, uistate, [], repo)
except WindowActiveError: except WindowActiveError:
pass pass
elif reftype == 'Note':
try:
note = dbstate.db.get_note_from_handle(ref)
EditNote(dbstate, uistate, [], note)
except WindowActiveError:
pass
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #