Refactored listviews to be able to select multiple items for dnd
svn: r15656
This commit is contained in:
parent
d791f1654b
commit
aa5cefd789
@ -62,6 +62,7 @@ import Utils
|
||||
from QuestionDialog import QuestionDialog, QuestionDialog2
|
||||
from gui.filtereditor import FilterEditor
|
||||
from gen.ggettext import sgettext as _
|
||||
from DdTargets import DdTargets
|
||||
|
||||
#----------------------------------------------------------------
|
||||
#
|
||||
@ -437,7 +438,10 @@ class ListView(NavigationView):
|
||||
return None
|
||||
|
||||
def drag_list_info(self):
|
||||
return None
|
||||
"""
|
||||
Specify the drag type for a multiple selected rows
|
||||
"""
|
||||
return DdTargets.LINK_LIST
|
||||
|
||||
def drag_begin(self, widget, context):
|
||||
widget.drag_source_set_icon_stock(self.get_stock())
|
||||
@ -446,9 +450,14 @@ class ListView(NavigationView):
|
||||
def drag_data_get(self, widget, context, sel_data, info, time):
|
||||
selected_ids = self.selected_handles()
|
||||
|
||||
if selected_ids:
|
||||
if len(selected_ids) == 1:
|
||||
data = (self.drag_info().drag_type, id(self), selected_ids[0], 0)
|
||||
sel_data.set(sel_data.target, 8 , pickle.dumps(data))
|
||||
elif len(selected_ids) > 1:
|
||||
data = (self.drag_list_info().drag_type, id(self),
|
||||
[(self.drag_info().drag_type, handle) for handle in selected_ids],
|
||||
0)
|
||||
sel_data.set(sel_data.target, 8 , pickle.dumps(data))
|
||||
return True
|
||||
|
||||
def set_column_order(self):
|
||||
|
@ -155,12 +155,6 @@ class BasePersonView(ListView):
|
||||
"""
|
||||
return DdTargets.PERSON_LINK
|
||||
|
||||
def drag_list_info(self):
|
||||
"""
|
||||
Specify the drag type for a multiple selected rows
|
||||
"""
|
||||
return DdTargets.PERSON_LINK_LIST
|
||||
|
||||
def exact_search(self):
|
||||
"""
|
||||
Returns a tuple indicating columns requiring an exact search
|
||||
|
@ -158,26 +158,6 @@ class MediaView(ListView):
|
||||
#self.list.connect('drag_data_get', self.drag_data_get)
|
||||
self.list.connect('drag_data_received', self.drag_data_received)
|
||||
|
||||
def drag_data_get(self, widget, context, sel_data, info, time):
|
||||
"""
|
||||
Provide the drag_data_get function, which passes a tuple consisting of:
|
||||
|
||||
1) Drag type defined by the .drag_type field specified by the value
|
||||
assigned to _DND_TYPE
|
||||
2) The id value of this object, used for the purpose of determining
|
||||
the source of the object. If the source of the object is the same
|
||||
as the object, we are doing a reorder instead of a normal drag
|
||||
and drop
|
||||
3) Pickled data. The pickled version of the selected object
|
||||
4) Source row. Used for a reorder to determine the original position
|
||||
of the object
|
||||
"""
|
||||
|
||||
selected_ids = self.selected_handles()
|
||||
if selected_ids:
|
||||
data = (self.drag_info().drag_type, id(self), selected_ids[0], 0)
|
||||
sel_data.set(sel_data.target, 8, pickle.dumps(data))
|
||||
|
||||
def drag_info(self):
|
||||
"""
|
||||
Return the type of DND targets that this view will accept. For Media
|
||||
|
Loading…
Reference in New Issue
Block a user