add option to action popup for torrent details

This commit is contained in:
Nick 2011-02-02 20:49:27 +01:00
parent b41ebe1b89
commit 0353a388b3
1 changed files with 22 additions and 8 deletions

View File

@ -117,6 +117,8 @@ class ACTION:
REMOVE_DATA=6 REMOVE_DATA=6
REMOVE_NODATA=7 REMOVE_NODATA=7
DETAILS=8
class FILTER: class FILTER:
ALL=0 ALL=0
ACTIVE=1 ACTIVE=1
@ -332,6 +334,13 @@ class AllTorrents(BaseMode):
else: else:
return "" return ""
def show_torrent_details(self,tid):
component.stop(["AllTorrentsStateUpdater"])
self.stdscr.clear()
td = TorrentDetail(self,tid,self.stdscr,self.encoding)
component.get("ConsoleUI").set_mode(td)
def _action_error(self, error): def _action_error(self, error):
rerr = error.value rerr = error.value
self.report_message("An Error Occurred","%s got error %s: %s"%(rerr.method,rerr.exception_type,rerr.exception_msg)) self.report_message("An Error Occurred","%s got error %s: %s"%(rerr.method,rerr.exception_type,rerr.exception_msg))
@ -371,6 +380,13 @@ class AllTorrents(BaseMode):
elif data==ACTION.REANNOUNCE: elif data==ACTION.REANNOUNCE:
log.debug("Reannouncing torrents: %s",ids) log.debug("Reannouncing torrents: %s",ids)
client.core.force_reannounce(ids).addErrback(self._action_error) client.core.force_reannounce(ids).addErrback(self._action_error)
elif data==ACTION.DETAILS:
log.debug("Torrent details")
tid = self._current_torrent_id()
if tid:
self.show_torrent_details(tid)
else:
log.error("No current torrent in _torrent_action, this is a bug")
if len(ids) == 1: if len(ids) == 1:
self.marked = [] self.marked = []
self.last_mark = -1 self.last_mark = -1
@ -387,6 +403,8 @@ class AllTorrents(BaseMode):
self.popup.add_divider() self.popup.add_divider()
self.popup.add_line("Remo_ve Torrent",data=ACTION.REMOVE) self.popup.add_line("Remo_ve Torrent",data=ACTION.REMOVE)
self.popup.add_line("_Force Recheck",data=ACTION.RECHECK) self.popup.add_line("_Force Recheck",data=ACTION.RECHECK)
self.popup.add_divider()
self.popup.add_line("Torrent _Details",data=ACTION.DETAILS)
def _torrent_filter(self, idx, data): def _torrent_filter(self, idx, data):
if data==FILTER.ALL: if data==FILTER.ALL:
@ -609,14 +627,10 @@ class AllTorrents(BaseMode):
elif c == curses.KEY_RIGHT: elif c == curses.KEY_RIGHT:
# We enter a new mode for the selected torrent here # We enter a new mode for the selected torrent here
if not self.marked: tid = self._current_torrent_id()
tid = self._current_torrent_id() if tid:
if tid: self.show_torrent_details(tid)
component.stop(["AllTorrentsStateUpdater"]) return
self.stdscr.clear()
td = TorrentDetail(self,self._current_torrent_id(),self.stdscr,self.encoding)
component.get("ConsoleUI").set_mode(td)
return
# Enter Key # Enter Key
elif (c == curses.KEY_ENTER or c == 10) and self.numtorrents: elif (c == curses.KEY_ENTER or c == 10) and self.numtorrents: