diff --git a/deluge/ui/console/modes/alltorrents.py b/deluge/ui/console/modes/alltorrents.py index 5ccde995f..d1f54917d 100644 --- a/deluge/ui/console/modes/alltorrents.py +++ b/deluge/ui/console/modes/alltorrents.py @@ -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", diff --git a/deluge/ui/console/modes/preference_panes.py b/deluge/ui/console/modes/preference_panes.py index f015ebe94..0dfea2340 100644 --- a/deluge/ui/console/modes/preference_panes.py +++ b/deluge/ui/console/modes/preference_panes.py @@ -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 diff --git a/deluge/ui/console/modes/torrent_actions.py b/deluge/ui/console/modes/torrent_actions.py index a15de5246..15704352a 100644 --- a/deluge/ui/console/modes/torrent_actions.py +++ b/deluge/ui/console/modes/torrent_actions.py @@ -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) @@ -157,5 +183,5 @@ def torrent_actions_popup(mode,tids,details=False): popup.add_line("_Move Storage",data=ACTION.MOVE_STORAGE) if details: popup.add_divider() - popup.add_line("Torrent _Details",data=ACTION.DETAILS) + popup.add_line("Torrent _Details",data=ACTION.DETAILS) mode.set_popup(popup)