def __refresh_rows(self): self.formatted_rows = [] for row in self.raw_rows: filename = row[0] size = row[1] time = row[2] if row[4]: if size != -1: size_str = "%i items" % size else: size_str = " unknown" try: filename = filename.decode("utf8") except: pass cols = [filename, size_str, common.fdate(time)] widths = [self.cols - 35, 12, 23] self.formatted_rows.append(format_utils.format_row(cols, widths)) else: # Size of .torrent file itself couldn't matter less so we'll leave it out try: filename = filename.decode("utf8") except: pass cols = [filename, common.fdate(time)] widths = [self.cols - 23, 23] self.formatted_rows.append(format_utils.format_row(cols, widths))
def __refresh_rows(self): self.formatted_rows = [] for row in self.raw_rows: filename = row[0] size = row[1] time = row[2] if row[4]: if size != -1: size_str = "%i items" % size else: size_str = " unknown" try: filename = filename.decode("utf8") except: pass cols = [filename, size_str, common.fdate(time)] widths = [self.cols - 35, 12, 23] self.formatted_rows.append( format_utils.format_row(cols, widths)) else: #Size of .torrent file itself couldn't matter less so we'll leave it out try: filename = filename.decode("utf8") except: pass cols = [filename, common.fdate(time)] widths = [self.cols - 23, 23] self.formatted_rows.append( format_utils.format_row(cols, widths))
def draw_files(self, files, depth, off, idx): for fl in files: # kick out if we're going to draw too low on the screen if (off >= self.rows - 1): self.more_to_draw = True return -1, -1 self.file_limit = idx if idx >= self.file_off: # set fg/bg colors based on if we are selected/marked or not # default values fg = "white" bg = "black" if fl[1] in self.marked: bg = "blue" if idx == self.current_file_idx: self.current_file = fl bg = "white" if fl[1] in self.marked: fg = "blue" else: fg = "black" color_string = "{!%s,%s!}" % (fg, bg) #actually draw the dir/file string if fl[3] and fl[4]: # this is an expanded directory xchar = 'v' elif fl[3]: # collapsed directory xchar = '>' else: # file xchar = '-' r = format_utils.format_row([ "%s%s %s" % (" " * depth, xchar, fl[0]), deluge.common.fsize(fl[2]), fl[5], format_utils.format_priority(fl[6]) ], self.column_widths) self.add_string(off, "%s%s" % (color_string, r), trim=False) off += 1 if fl[3] and fl[4]: # recurse if we have children and are expanded off, idx = self.draw_files(fl[3], depth + 1, off, idx + 1) if off < 0: return (off, idx) else: idx += 1 return (off, idx)
def draw_files(self,files,depth,off,idx): for fl in files: # kick out if we're going to draw too low on the screen if (off >= self.rows-1): self.more_to_draw = True return -1,-1 self.file_limit = idx if idx >= self.file_off: # set fg/bg colors based on if we are selected/marked or not # default values fg = "white" bg = "black" if fl[1] in self.marked: bg = "blue" if idx == self.current_file_idx: self.current_file = fl bg = "white" if fl[1] in self.marked: fg = "blue" else: fg = "black" color_string = "{!%s,%s!}"%(fg,bg) #actually draw the dir/file string if fl[3] and fl[4]: # this is an expanded directory xchar = 'v' elif fl[3]: # collapsed directory xchar = '>' else: # file xchar = '-' r = format_utils.format_row(["%s%s %s"%(" "*depth,xchar,fl[0]), deluge.common.fsize(fl[2]),fl[5], format_utils.format_priority(fl[6])], self.column_widths) self.add_string(off,"%s%s"%(color_string,r),trim=False) off += 1 if fl[3] and fl[4]: # recurse if we have children and are expanded off,idx = self.draw_files(fl[3],depth+1,off,idx+1) if off < 0: return (off,idx) else: idx += 1 return (off,idx)
def set_state(self, state, refresh): self.curstate = state # cache in case we change sort order newnames = [] newrows = [] self._sorted_ids = self._sort_torrents(self.curstate) for torrent_id in self._sorted_ids: ts = self.curstate[torrent_id] newnames.append(ts["name"]) newrows.append((format_utils.format_row([column.get_column_value(name,ts) for name in self.__columns],self.column_widths),ts["state"])) self.numtorrents = len(state) self.formatted_rows = newrows self.torrent_names = newnames if refresh: self.refresh()
def draw_files(self,files,depth,off,idx): color_selected = "blue" color_partially_selected = "magenta" color_highlighted = "white" for fl in files: #from sys import stderr #print >> stderr, fl[6] # kick out if we're going to draw too low on the screen if (off >= self.rows-1): self.more_to_draw = True return -1,-1 self.file_limit = idx # default color values fg = "white" bg = "black" attr = "" if fl[6] == -2: priority = -1 #Mixed elif fl[6] == 0: priority = 0 #Do Not Download fg = "red" elif fl[6] == 1: priority = 1 #Normal elif fl[6] <= 6: priority = 2 #High fg = "yellow" elif fl[6] == 7: priority = 3 #Highest fg = "green" if idx >= self.file_off: # set fg/bg colors based on whether the file is selected/marked or not if fl[1] in self.marked: bg = color_selected if fl[3]: if self.marked[fl[1]] < self.__get_contained_files_count(file_list=fl[3]): bg = color_partially_selected attr = "bold" if idx == self.current_file_idx: self.current_file = fl bg = color_highlighted if fl[1] in self.marked: fg = color_selected if fl[3]: if self.marked[fl[1]] < self.__get_contained_files_count(file_list = fl[3]): fg = color_partially_selected else: if fg == "white": fg = "black" attr = "bold" if attr: color_string = "{!%s,%s,%s!}"%(fg, bg, attr) else: color_string = "{!%s,%s!}"%(fg, bg) #actually draw the dir/file string if fl[3] and fl[4]: # this is an expanded directory xchar = 'v' elif fl[3]: # collapsed directory xchar = '>' else: # file xchar = '-' r = format_utils.format_row(["%s%s %s"%(" "*depth,xchar,fl[0]), deluge.common.fsize(fl[2]),fl[5], format_utils.format_priority(fl[6])], self.column_widths) self.add_string(off,"%s%s"%(color_string,r),trim=False) off += 1 if fl[3] and fl[4]: # recurse if we have children and are expanded off,idx = self.draw_files(fl[3],depth+1,off,idx+1) if off < 0: return (off,idx) else: idx += 1 return (off,idx)
def draw_files(self, files, depth, off, idx): color_selected = "blue" color_partially_selected = "magenta" color_highlighted = "white" for fl in files: #from sys import stderr #print >> stderr, fl[6] # kick out if we're going to draw too low on the screen if (off >= self.rows - 1): self.more_to_draw = True return -1, -1 self.file_limit = idx # default color values fg = "white" bg = "black" attr = "" if fl[6] == -2: priority = -1 #Mixed elif fl[6] == 0: priority = 0 #Do Not Download fg = "red" elif fl[6] == 1: priority = 1 #Normal elif fl[6] <= 6: priority = 2 #High fg = "yellow" elif fl[6] == 7: priority = 3 #Highest fg = "green" if idx >= self.file_off: # set fg/bg colors based on whether the file is selected/marked or not if fl[1] in self.marked: bg = color_selected if fl[3]: if self.marked[ fl[1]] < self.__get_contained_files_count( file_list=fl[3]): bg = color_partially_selected attr = "bold" if idx == self.current_file_idx: self.current_file = fl bg = color_highlighted if fl[1] in self.marked: fg = color_selected if fl[3]: if self.marked[ fl[1]] < self.__get_contained_files_count( file_list=fl[3]): fg = color_partially_selected else: if fg == "white": fg = "black" attr = "bold" if attr: color_string = "{!%s,%s,%s!}" % (fg, bg, attr) else: color_string = "{!%s,%s!}" % (fg, bg) #actually draw the dir/file string if fl[3] and fl[4]: # this is an expanded directory xchar = 'v' elif fl[3]: # collapsed directory xchar = '>' else: # file xchar = '-' r = format_utils.format_row([ "%s%s %s" % (" " * depth, xchar, fl[0]), deluge.common.fsize(fl[2]), fl[5], format_utils.format_priority(fl[6]) ], self.column_widths) self.add_string(off, "%s%s" % (color_string, r), trim=False) off += 1 if fl[3] and fl[4]: # recurse if we have children and are expanded off, idx = self.draw_files(fl[3], depth + 1, off, idx + 1) if off < 0: return (off, idx) else: idx += 1 return (off, idx)