Added family type drag objects
svn: r15669
This commit is contained in:
@@ -125,6 +125,7 @@ class _DdTargets(object):
|
|||||||
self.REPO_LINK = _DdType(self, 'repo-link')
|
self.REPO_LINK = _DdType(self, 'repo-link')
|
||||||
self.REPOREF = _DdType(self, 'reporef')
|
self.REPOREF = _DdType(self, 'reporef')
|
||||||
self.PERSON_LINK = _DdType(self, 'person-link')
|
self.PERSON_LINK = _DdType(self, 'person-link')
|
||||||
|
self.FAMILY_LINK = _DdType(self, 'family-link')
|
||||||
self.LINK_LIST = _DdType(self, 'link-list')
|
self.LINK_LIST = _DdType(self, 'link-list')
|
||||||
self.RAW_LIST = _DdType(self, 'raw-list')
|
self.RAW_LIST = _DdType(self, 'raw-list')
|
||||||
self.HANDLE_LIST = _DdType(self, 'handle-list')
|
self.HANDLE_LIST = _DdType(self, 'handle-list')
|
||||||
@@ -148,6 +149,7 @@ class _DdTargets(object):
|
|||||||
self.NOTE_LINK,
|
self.NOTE_LINK,
|
||||||
self.PLACE_LINK,
|
self.PLACE_LINK,
|
||||||
self.PERSON_LINK,
|
self.PERSON_LINK,
|
||||||
|
self.FAMILY_LINK,
|
||||||
self.LINK_LIST,
|
self.LINK_LIST,
|
||||||
self.RAW_LIST,
|
self.RAW_LIST,
|
||||||
self.HANDLE_LIST,
|
self.HANDLE_LIST,
|
||||||
|
@@ -303,8 +303,8 @@ class ScratchPadPlace(ScratchPadWrapper):
|
|||||||
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
||||||
value = self._db.get_place_from_handle(self._handle)
|
value = self._db.get_place_from_handle(self._handle)
|
||||||
if value:
|
if value:
|
||||||
self._title = value.get_title()
|
self._title = value.gramps_id
|
||||||
self._value = "" #value.get_description()
|
self._value = value.get_title()
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
return ""
|
return ""
|
||||||
@@ -552,8 +552,8 @@ class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
base = self._db.get_repository_from_handle(self._obj.ref)
|
base = self._db.get_repository_from_handle(self._obj.ref)
|
||||||
if base:
|
if base:
|
||||||
self._title = base.get_name()
|
self._title = str(base.get_type())
|
||||||
self._value = str(base.get_type())
|
self._value = base.get_name()
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
if not self.is_valid(): return _("Unavailable")
|
if not self.is_valid(): return _("Unavailable")
|
||||||
@@ -583,7 +583,7 @@ class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
base = self._db.get_event_from_handle(self._obj.ref)
|
base = self._db.get_event_from_handle(self._obj.ref)
|
||||||
if base:
|
if base:
|
||||||
self._title = base.get_description()
|
self._title = base.gramps_id
|
||||||
self._value = str(base.get_type())
|
self._value = str(base.get_type())
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
@@ -601,8 +601,8 @@ class ScratchPadName(ScratchPadGrampsTypeWrapper):
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self._title = self._obj.get_name()
|
self._title = str(self._obj.get_type())
|
||||||
self._value = str(self._obj.get_type())
|
self._value = self._obj.get_name()
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
if not self.is_valid(): return _("Unavailable")
|
if not self.is_valid(): return _("Unavailable")
|
||||||
@@ -650,7 +650,7 @@ class ScratchPadText(ScratchPadWrapper):
|
|||||||
def __init__(self, dbstate, obj):
|
def __init__(self, dbstate, obj):
|
||||||
ScratchPadWrapper.__init__(self, dbstate, obj)
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
||||||
self._type = _("Text")
|
self._type = _("Text")
|
||||||
self._title = ""
|
self._title = _("Text")
|
||||||
self._value = self._obj
|
self._value = self._obj
|
||||||
self._pickle = self._obj
|
self._pickle = self._obj
|
||||||
|
|
||||||
@@ -764,14 +764,8 @@ class ScratchPersonLink(ScratchPadWrapper):
|
|||||||
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
||||||
person = self._db.get_person_from_handle(self._handle)
|
person = self._db.get_person_from_handle(self._handle)
|
||||||
if person:
|
if person:
|
||||||
self._title = person.get_primary_name().get_name()
|
self._title = person.gramps_id
|
||||||
birth_ref = person.get_birth_ref()
|
self._value = person.get_primary_name().get_name()
|
||||||
if birth_ref:
|
|
||||||
birth_handle = birth_ref.ref
|
|
||||||
birth = self._db.get_event_from_handle(birth_handle)
|
|
||||||
date_str = DateHandler.get_date(birth)
|
|
||||||
if date_str != "":
|
|
||||||
self._value = escape(date_str)
|
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
if not self.is_valid(): return _("Unavailable")
|
if not self.is_valid(): return _("Unavailable")
|
||||||
@@ -808,6 +802,38 @@ class ScratchPersonLink(ScratchPadWrapper):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class ScratchFamilyLink(ScratchPadWrapper):
|
||||||
|
|
||||||
|
DROP_TARGETS = [DdTargets.FAMILY_LINK]
|
||||||
|
DRAG_TARGET = DdTargets.FAMILY_LINK
|
||||||
|
ICON = ICONS["family"]
|
||||||
|
|
||||||
|
def __init__(self, dbstate, obj):
|
||||||
|
ScratchPadWrapper.__init__(self, dbstate, obj)
|
||||||
|
self._type = _("Family")
|
||||||
|
self._objclass = 'Family'
|
||||||
|
self.reset()
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
from Simple import SimpleAccess
|
||||||
|
sa = SimpleAccess(self._db)
|
||||||
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
||||||
|
family = self._db.get_family_from_handle(self._handle)
|
||||||
|
self._title = family.gramps_id if family else _("Unavailable")
|
||||||
|
self._value = sa.describe(family)
|
||||||
|
|
||||||
|
def tooltip(self):
|
||||||
|
if not self.is_valid(): return _("Unavailable")
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def is_valid(self):
|
||||||
|
data = pickle.loads(self._obj)
|
||||||
|
handle = data[2]
|
||||||
|
obj = self._db.get_family_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class ScratchSourceLink(ScratchPadWrapper):
|
class ScratchSourceLink(ScratchPadWrapper):
|
||||||
|
|
||||||
DROP_TARGETS = [DdTargets.SOURCE_LINK]
|
DROP_TARGETS = [DdTargets.SOURCE_LINK]
|
||||||
@@ -824,8 +850,8 @@ class ScratchSourceLink(ScratchPadWrapper):
|
|||||||
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
||||||
source = self._db.get_source_from_handle(self._handle)
|
source = self._db.get_source_from_handle(self._handle)
|
||||||
if source:
|
if source:
|
||||||
self._title = source.get_title()
|
self._title = source.get_gramps_id()
|
||||||
self._value = source.get_gramps_id()
|
self._value = source.get_title()
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
if not self.is_valid(): return _("Unavailable")
|
if not self.is_valid(): return _("Unavailable")
|
||||||
@@ -867,8 +893,8 @@ class ScratchRepositoryLink(ScratchPadWrapper):
|
|||||||
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
(drag_type, idval, self._handle, val) = pickle.loads(self._obj)
|
||||||
source = self._db.get_repository_from_handle(self._handle)
|
source = self._db.get_repository_from_handle(self._handle)
|
||||||
if source:
|
if source:
|
||||||
self._title = source.get_name()
|
self._title = str(source.get_type())
|
||||||
self._value = str(source.get_type())
|
self._value = source.get_name()
|
||||||
|
|
||||||
def tooltip(self):
|
def tooltip(self):
|
||||||
if not self.is_valid(): return _("Unavailable")
|
if not self.is_valid(): return _("Unavailable")
|
||||||
@@ -908,6 +934,7 @@ class ScratchDropList(object):
|
|||||||
|
|
||||||
def map2class(self, target):
|
def map2class(self, target):
|
||||||
return {"person-link": ScratchPersonLink,
|
return {"person-link": ScratchPersonLink,
|
||||||
|
"family-link": ScratchFamilyLink,
|
||||||
'personref': ScratchPadPersonRef,
|
'personref': ScratchPadPersonRef,
|
||||||
'source-link': ScratchSourceLink,
|
'source-link': ScratchSourceLink,
|
||||||
'srcref': ScratchPadSourceRef,
|
'srcref': ScratchPadSourceRef,
|
||||||
@@ -922,6 +949,7 @@ class ScratchDropList(object):
|
|||||||
|
|
||||||
def obj2class(self, target):
|
def obj2class(self, target):
|
||||||
return {"Person": ScratchPersonLink,
|
return {"Person": ScratchPersonLink,
|
||||||
|
"Family": ScratchFamilyLink,
|
||||||
'Source': ScratchSourceLink,
|
'Source': ScratchSourceLink,
|
||||||
'Repository': ScratchRepositoryLink,
|
'Repository': ScratchRepositoryLink,
|
||||||
'Event': ScratchPadEvent,
|
'Event': ScratchPadEvent,
|
||||||
@@ -932,6 +960,7 @@ class ScratchDropList(object):
|
|||||||
|
|
||||||
def obj2target(self, target):
|
def obj2target(self, target):
|
||||||
return {"Person": 'person-link',
|
return {"Person": 'person-link',
|
||||||
|
"Family": 'family-link',
|
||||||
'Source': 'source-link',
|
'Source': 'source-link',
|
||||||
'Repository': 'repo-link',
|
'Repository': 'repo-link',
|
||||||
'Event': 'pevent',
|
'Event': 'pevent',
|
||||||
@@ -1181,6 +1210,7 @@ class ScratchPadListView(object):
|
|||||||
self.register_wrapper_class(ScratchPadMediaRef)
|
self.register_wrapper_class(ScratchPadMediaRef)
|
||||||
self.register_wrapper_class(ScratchSourceLink)
|
self.register_wrapper_class(ScratchSourceLink)
|
||||||
self.register_wrapper_class(ScratchPersonLink)
|
self.register_wrapper_class(ScratchPersonLink)
|
||||||
|
self.register_wrapper_class(ScratchFamilyLink)
|
||||||
self.register_wrapper_class(ScratchDropList)
|
self.register_wrapper_class(ScratchDropList)
|
||||||
self.register_wrapper_class(ScratchDropRawList)
|
self.register_wrapper_class(ScratchDropRawList)
|
||||||
self.register_wrapper_class(ScratchDropHandleList)
|
self.register_wrapper_class(ScratchDropHandleList)
|
||||||
|
@@ -53,6 +53,7 @@ import config
|
|||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
from Filters.SideBar import FamilySidebarFilter
|
from Filters.SideBar import FamilySidebarFilter
|
||||||
from gen.plug import CATEGORY_QR_FAMILY
|
from gen.plug import CATEGORY_QR_FAMILY
|
||||||
|
from DdTargets import DdTargets
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -263,3 +264,9 @@ class FamilyView(ListView):
|
|||||||
As this submenu will be dynamically built, we offer a dummy action
|
As this submenu will be dynamically built, we offer a dummy action
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def drag_info(self):
|
||||||
|
"""
|
||||||
|
Indicate that the drag type is a FAMILY_LINK
|
||||||
|
"""
|
||||||
|
return DdTargets.FAMILY_LINK
|
||||||
|
Reference in New Issue
Block a user