Add option(on by default) to move selection when moving torrents up/down the queue. Known bug: Incorrect behavior when trying to move bottommost torrents to the bottom, has no impact besides being unexpected.

This commit is contained in:
Asmageddon 2012-03-09 19:16:14 +01:00
parent 591f9a19e5
commit c30a86e52a
3 changed files with 32 additions and 4 deletions

View File

@ -168,7 +168,8 @@ DEFAULT_PREFS = {
"downloaded_width":13,
"uploaded_width":13,
"owner_width":10,
"ignore_duplicate_lines": False
"ignore_duplicate_lines": False,
"move_selection": True
}
column_pref_names = ["queue","name","size","state",

View File

@ -312,6 +312,7 @@ class InterfacePane(BasePane):
BasePane.__init__(self,offset,parent,width)
self.add_header("General")
self.add_checked_input("ignore_duplicate_lines","Do not store duplicate input in history",parent.console_config["ignore_duplicate_lines"])
self.add_checked_input("move_selection","Move selection when moving torrents in the queue",parent.console_config["move_selection"])
self.add_header("Columns To Display")
for cpn in deluge.ui.console.modes.alltorrents.column_pref_names:
pn = "show_%s"%cpn

View File

@ -83,6 +83,33 @@ def torrent_action(idx, data, mode, ids):
elif qact == ACTION.QUEUE_BOTTOM:
log.debug("Queuing torrents bottom")
client.core.queue_bottom(ids)
if mode.config["move_selection"]:
queue_length = 0
selected_num = 0
for tid in mode.curstate:
tq = mode.curstate.get(tid)["queue"]
if tq != -1:
queue_length += 1
if tq in mode.marked:
selected_num += 1
if qact == ACTION.QUEUE_TOP:
#mode.cursel = 1 + sorted(mode.marked).index(mode.cursel)
mode.cursel = selected_num - sorted(mode.marked).index(mode.cursel)
mode.marked = range(1, selected_num + 1)
elif qact == ACTION.QUEUE_UP:
mode.cursel = max(1, mode.cursel - 1)
mode.marked = map(lambda v: v-1, mode.marked)
mode.marked = filter(lambda v: v>0, mode.marked)
elif qact == ACTION.QUEUE_DOWN:
mode.cursel = min(queue_length, mode.cursel + 1)
mode.marked = map(lambda v: v+1, mode.marked)
mode.marked = filter(lambda v: v<=queue_length, mode.marked)
elif qact == ACTION.QUEUE_BOTTOM:
mode.cursel = queue_length - selected_num + 1 + sorted(mode.marked).index(mode.cursel)
mode.marked = range(queue_length - selected_num + 1, queue_length+1)
if len(ids) == 1:
mode.clear_marks()
return True
@ -100,8 +127,7 @@ def torrent_action(idx, data, mode, ids):
for tid in ids:
log.debug("Removing torrent: %s,%d",tid,wd)
client.core.remove_torrent(tid,wd).addErrback(action_error,mode)
if len(ids) == 1:
mode.clear_marks()
mode.clear_marks()
return True
popup = SelectablePopup(mode,"Confirm Remove",do_remove,mode,ids)
popup.add_line("Are you sure you want to remove the marked torrents?",selectable=False)