Fixed one issue with multi-select and drop on self; one issue remains: copies data on a self multi drop

svn: r15773
This commit is contained in:
Doug Blank 2010-08-19 04:08:07 +00:00
parent 88a4bbb926
commit 7758caa4e3

View File

@ -1014,10 +1014,14 @@ class ScratchDropRawList(ScratchDropList):
def get_objects(self): def get_objects(self):
retval = [] retval = []
for item in self._obj_list: for item in self._obj_list:
if item is None:
continue
target = pickle.loads(item)[0] target = pickle.loads(item)[0]
_class = map2class(target) _class = map2class(target)
obj = _class(self._dbstate, item) if _class:
retval.append(obj) obj = _class(self._dbstate, item)
if obj:
retval.append(obj)
return retval return retval
class ScratchDropHandleList(ScratchDropList): class ScratchDropHandleList(ScratchDropList):
@ -1366,26 +1370,30 @@ class ScratchPadListView(object):
o_list = o.get_objects() o_list = o.get_objects()
else: else:
o_list = [o] o_list = [o]
data = [o.__class__.DRAG_TARGET.drag_type, o, o.tooltip, for o in o_list:
o._type, o._value] if o.__class__.DRAG_TARGET is None:
contains = model_contains(model, data) continue
if not contains: data = [o.__class__.DRAG_TARGET.drag_type, o, o.tooltip,
for o in o_list: o._type, o._value]
drop_info = widget.get_dest_row_at_pos(x, y) contains = model_contains(model, data)
if drop_info: if context.action != ACTION_MOVE and contains:
path, position = drop_info continue
node = model.get_iter(path) drop_info = widget.get_dest_row_at_pos(x, y)
if (position == gtk.TREE_VIEW_DROP_BEFORE if drop_info:
or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE): path, position = drop_info
model.insert_before(node, data) node = model.get_iter(path)
else: if (position == gtk.TREE_VIEW_DROP_BEFORE
model.insert_after(node, data) or position == gtk.TREE_VIEW_DROP_INTO_OR_BEFORE):
model.insert_before(node, data)
else: else:
model.append(data) model.insert_after(node, data)
else:
model.append(data)
if context.action == ACTION_MOVE: # FIXME: there is one bug here: if you multi-select and drop
context.finish(True, True, time) # on self, then it moves the first, and copies the rest.
elif context.action == ACTION_MOVE:
if context.action == ACTION_MOVE:
context.finish(True, True, time) context.finish(True, True, time)
# remember time for double drop workaround. # remember time for double drop workaround.