From 4ad5681ee353d243790adca38f20bdfd3bed7c6d Mon Sep 17 00:00:00 2001 From: Tim G L Lyons Date: Mon, 14 Nov 2011 23:57:08 +0000 Subject: [PATCH] Fix drag_info in citationtreeview, so that it doesn't break merge citation. Also add some comments about drag and drop. svn: r18443 --- src/ScratchPad.py | 9 +++++++++ src/plugins/view/citationtreeview.py | 23 +++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ScratchPad.py b/src/ScratchPad.py index fb4827318..7d51536b2 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -142,6 +142,15 @@ def obj2target(target): } 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): """ Returns True if data is a row in model. diff --git a/src/plugins/view/citationtreeview.py b/src/plugins/view/citationtreeview.py index ee4fc637d..3160a002d 100644 --- a/src/plugins/view/citationtreeview.py +++ b/src/plugins/view/citationtreeview.py @@ -196,18 +196,21 @@ class CitationTreeView(ListView): return self.dbstate.db.get_citation_bookmarks() 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() - if len(selection) == 1: - 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: + if len(selection) == 1 and \ + self.dbstate.db.get_source_from_handle(selection[0]): return DdTargets.SOURCE_LINK - else: - return DdTargets.CITATION_LINK else: return DdTargets.CITATION_LINK