Fix drag_info in citationtreeview, so that it doesn't break merge citation. Also add some comments about drag and drop.
svn: r18443
This commit is contained in:
parent
7ebf8de20a
commit
4ad5681ee3
@ -142,6 +142,15 @@ def obj2target(target):
|
|||||||
}
|
}
|
||||||
return d[target] if target in d else None
|
return d[target] if target in d else None
|
||||||
|
|
||||||
|
# FIXME: CITATION: Dropping a citation onto an embedded tab should open
|
||||||
|
# CitationEdit. However, note should behave similarly, and although there is
|
||||||
|
# code to call EditNote, EditNote does not appear to be called. I don't
|
||||||
|
# understand how to get the editor called.
|
||||||
|
|
||||||
|
# FIXME: CITATION: It should be possible to drop a source onto an embedded tab,
|
||||||
|
# with CitationEdit being opened, However, It is not possible to do the drop,
|
||||||
|
# and as described above I do not understand how to get the editor called.
|
||||||
|
|
||||||
def model_contains(model, data):
|
def model_contains(model, data):
|
||||||
"""
|
"""
|
||||||
Returns True if data is a row in model.
|
Returns True if data is a row in model.
|
||||||
|
@ -196,18 +196,21 @@ class CitationTreeView(ListView):
|
|||||||
return self.dbstate.db.get_citation_bookmarks()
|
return self.dbstate.db.get_citation_bookmarks()
|
||||||
|
|
||||||
def drag_info(self):
|
def drag_info(self):
|
||||||
|
# Since drag only needs to work when just one row is selected, ideally,
|
||||||
|
# this should just return SOURCE_LINK if one source is selected and
|
||||||
|
# CITATION_LINK if one citation is selected, and probably None
|
||||||
|
# otherwise. However, this doesn't work. Drag and drop failed to work at
|
||||||
|
# all for citationtree view, and I think this was because None is
|
||||||
|
# returned during initialisation. There is also a problem where it seems
|
||||||
|
# at some point during a citation merge, neither a Source nor a Citation
|
||||||
|
# is selected. Hence the simplistic solution implemented below, where
|
||||||
|
# CITATION_LINK is always returned except when it is obviously correct
|
||||||
|
# to return SOURCE_LINK.
|
||||||
|
|
||||||
selection = self.selected_handles()
|
selection = self.selected_handles()
|
||||||
if len(selection) == 1:
|
if len(selection) == 1 and \
|
||||||
handle = selection[0]
|
self.dbstate.db.get_source_from_handle(selection[0]):
|
||||||
# The handle will either be a Source handle or a Citation handle
|
|
||||||
source = self.dbstate.db.get_source_from_handle(handle)
|
|
||||||
citation = self.dbstate.db.get_citation_from_handle(handle)
|
|
||||||
if (not source and not citation) or (source and citation):
|
|
||||||
raise ValueError("selection must be either source or citation")
|
|
||||||
if source:
|
|
||||||
return DdTargets.SOURCE_LINK
|
return DdTargets.SOURCE_LINK
|
||||||
else:
|
|
||||||
return DdTargets.CITATION_LINK
|
|
||||||
else:
|
else:
|
||||||
return DdTargets.CITATION_LINK
|
return DdTargets.CITATION_LINK
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user