repository drag-n-drop

svn: r6196
This commit is contained in:
Don Allingham 2006-03-23 05:19:38 +00:00
parent ff679efba3
commit 9f60846eef
6 changed files with 60 additions and 5 deletions

View File

@ -1,4 +1,6 @@
2006-03-22 Don Allingham <don@gramps-project.org> 2006-03-22 Don Allingham <don@gramps-project.org>
* src/ScratchPad.py: handle repositories
*
* src/DataViews/_SourceView.py: handle drag and drop * src/DataViews/_SourceView.py: handle drag and drop
* src/DataViews/_PersonView.py: handle drag and drop * src/DataViews/_PersonView.py: handle drag and drop
* src/ViewManager.py: pychecker fixes * src/ViewManager.py: pychecker fixes

View File

@ -38,6 +38,7 @@ import DisplayModels
import const import const
import Utils import Utils
from Editors import EditRepository, DelRepositoryQuery from Editors import EditRepository, DelRepositoryQuery
from DdTargets import DdTargets
from QuestionDialog import QuestionDialog, ErrorDialog from QuestionDialog import QuestionDialog, ErrorDialog
@ -83,6 +84,8 @@ class RepositoryView(PageView.ListView):
DisplayModels.RepositoryModel, DisplayModels.RepositoryModel,
signal_map) signal_map)
def drag_info(self):
return DdTargets.REPO_LINK
def define_actions(self): def define_actions(self):
PageView.ListView.define_actions(self) PageView.ListView.define_actions(self)

View File

@ -113,6 +113,7 @@ class _DdTargets(object):
self.ADDRESS = _DdType(self,'paddr') self.ADDRESS = _DdType(self,'paddr')
self.SOURCEREF = _DdType(self,'srcref') self.SOURCEREF = _DdType(self,'srcref')
self.REPOREF = _DdType(self,'reporef') self.REPOREF = _DdType(self,'reporef')
self.REPO_LINK = _DdType(self,'repo-link')
self.NAME = _DdType(self,'name') self.NAME = _DdType(self,'name')
self.MEDIAOBJ = _DdType(self,'mediaobj') self.MEDIAOBJ = _DdType(self,'mediaobj')
self.DATA = _DdType(self,'data_tuple') self.DATA = _DdType(self,'data_tuple')
@ -136,6 +137,8 @@ class _DdTargets(object):
self.SOURCEREF, self.SOURCEREF,
self.EVENTREF, self.EVENTREF,
self.NAME, self.NAME,
self.REPO_LINK,
self.REPOREF,
self.MEDIAOBJ, self.MEDIAOBJ,
self.PERSON_LINK, self.PERSON_LINK,
self.PERSON_LINK_LIST] self.PERSON_LINK_LIST]

View File

@ -1482,6 +1482,7 @@ class RepoEmbedList(EmbeddedList):
_HANDLE_COL = 4 _HANDLE_COL = 4
_DND_TYPE = DdTargets.REPOREF _DND_TYPE = DdTargets.REPOREF
_DND_EXTRA = DdTargets.REPO_LINK
_column_names = [ _column_names = [
(_('ID'), 0, 75), (_('ID'), 0, 75),
@ -1505,12 +1506,12 @@ class RepoEmbedList(EmbeddedList):
return ((1,0),(1,1),(1,2),(1,3)) return ((1,0),(1,1),(1,2),(1,3))
def add_button_clicked(self,obj): def add_button_clicked(self,obj):
from Editors import EditRepositoryRef from Editors import EditRepoRef
ref = RelLib.RepoRef() ref = RelLib.RepoRef()
repo = RelLib.Repository() repo = RelLib.Repository()
try: try:
EditRepositoryRef( EditRepoRef.EditRepoRef(
self.dbstate, self.uistate, self.track, self.dbstate, self.uistate, self.track,
repo, ref, self.add_callback) repo, ref, self.add_callback)
except Errors.WindowActiveError: except Errors.WindowActiveError:

View File

@ -198,7 +198,7 @@ class GrampsBSDDB(GrampsDbBase):
return GrampsBSDDBCursor(self.media_map,self.txn) return GrampsBSDDBCursor(self.media_map,self.txn)
def get_repository_cursor(self): def get_repository_cursor(self):
return GrampsBSDDBAssocCursor(self.repository_map,self.txn) return GrampsBSDDBCursor(self.repository_map,self.txn)
def has_person_handle(self,handle): def has_person_handle(self,handle):
""" """

View File

@ -183,7 +183,7 @@ class ScratchPadEvent(ScratchPadWrapper):
def __init__(self,dbstate,obj): def __init__(self,dbstate,obj):
ScratchPadWrapper.__init__(self,dbstate,obj) ScratchPadWrapper.__init__(self,dbstate,obj)
self._type = _("Event") self._type = _("Event Link")
(drag_type, idval, handle, val) = pickle.loads(obj) (drag_type, idval, handle, val) = pickle.loads(obj)
@ -383,6 +383,28 @@ class ScratchPadSourceRef(ScratchPadGrampsTypeWrapper):
return s return s
class ScratchPadRepoRef(ScratchPadGrampsTypeWrapper):
DROP_TARGETS = [DdTargets.REPOREF]
DRAG_TARGET = DdTargets.REPOREF
ICON = BLANK_PIC
def __init__(self,dbstate,obj):
ScratchPadGrampsTypeWrapper.__init__(self,dbstate,obj)
self._type = _("Repository Reference")
base = self._db.get_repository_from_handle(self._obj.ref)
self._title = base.get_name()
value = base.get_type()
if value == RelLib.Repository.CUSTOM:
self._value = value[1]
else:
self._value = Utils.repository_types[value[0]]
def tooltip(self):
return ""
class ScratchPadEventRef(ScratchPadGrampsTypeWrapper): class ScratchPadEventRef(ScratchPadGrampsTypeWrapper):
DROP_TARGETS = [DdTargets.EVENTREF] DROP_TARGETS = [DdTargets.EVENTREF]
@ -551,6 +573,29 @@ class ScratchSourceLink(ScratchPadWrapper):
def tooltip(self): def tooltip(self):
return "" return ""
class ScratchRepositoryLink(ScratchPadWrapper):
DROP_TARGETS = [DdTargets.REPO_LINK]
DRAG_TARGET = DdTargets.REPO_LINK
ICON = LINK_PIC
def __init__(self,dbstate,obj):
ScratchPadWrapper.__init__(self,dbstate,obj)
self._type = _("Repository Link")
(drag_type, idval, handle, val) = pickle.loads(obj)
source = self._db.get_repository_from_handle(handle)
self._title = source.get_name()
value = source.get_type()
if value == RelLib.Repository.CUSTOM:
self._value = value[1]
else:
self._value = Utils.repository_types[value[0]]
def tooltip(self):
return ""
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Wrapper classes to deal with lists of objects # Wrapper classes to deal with lists of objects
@ -707,7 +752,8 @@ class ScratchPadListView:
self.register_wrapper_class(ScratchPadAttribute) self.register_wrapper_class(ScratchPadAttribute)
self.register_wrapper_class(ScratchPadFamilyAttribute) self.register_wrapper_class(ScratchPadFamilyAttribute)
self.register_wrapper_class(ScratchPadName) self.register_wrapper_class(ScratchPadName)
self.register_wrapper_class(ScratchPadText) self.register_wrapper_class(ScratchPadRepoRef)
self.register_wrapper_class(ScratchRepositoryLink)
self.register_wrapper_class(ScratchMediaObj) self.register_wrapper_class(ScratchMediaObj)
self.register_wrapper_class(ScratchSourceLink) self.register_wrapper_class(ScratchSourceLink)
self.register_wrapper_class(ScratchPersonLink) self.register_wrapper_class(ScratchPersonLink)