add in the file priorities to the file tree on the details tab

add some icons for the priorities
This commit is contained in:
Damien Churchill 2009-04-01 18:42:04 +00:00
parent baf3d283e0
commit 0d5c30b5f9
8 changed files with 55 additions and 5 deletions

View file

@ -194,4 +194,27 @@ input {
.x-deluge-add-file-checkbox {
margin-top: 2px;
}
/* Filepriority styles */
.x-no-download, .x-normal-download, .x-high-download, .x-highest-download {
padding-left: 20px;
background-repeat: no-repeat;
line-height: 16px;
}
.x-no-download {
background-image: url(/icons/no_download.png);
}
.x-normal-download {
background-image: url(/icons/normal.png);
}
.x-high-download {
background-image: url(/icons/high.png);
}
.x-highest-download {
background-image: url(/icons/highest.png);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

View file

@ -232,6 +232,7 @@ Deluge.Details.Files = {
text: file, // this needs to be here for sorting
size: fsize(item[0]),
progress: item[1],
priority: item[2],
leaf: true,
iconCls: 'x-deluge-file',
uiProvider: Ext.tree.ColumnNodeUI
@ -298,11 +299,22 @@ function peer_address(value, p, record) {
return String.format('<div class="{0}">{1}</div>', seed, value);
}
function peer_progress(value) {
function progress_renderer(value) {
var progress = (value * 100).toInt();
return String.format(tpl, progress, '', progress);
}
FILE_PRIORITY_CSS = {
0: 'x-no-download',
1: 'x-normal-download',
2: 'x-high-download',
5: 'x-highest-download'
}
function priority_renderer(value) {
return String.format('<div class="{0}">{1}</div>', FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
}
function sort_address(value) {
var m = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);
var address = 0;
@ -363,11 +375,12 @@ Deluge.Details.Panel = new Ext.TabPanel({
header: _('Progress'),
width: 150,
dataIndex: 'progress',
renderer: peer_progress
renderer: progress_renderer
},{
header: _('Priority'),
width: 150,
dataIndex: 'priority'
dataIndex: 'priority',
renderer: priority_renderer
}],
root: new Ext.tree.TreeNode({
@ -383,7 +396,7 @@ Deluge.Details.Panel = new Ext.TabPanel({
{header: '&nbsp;', width: 30, sortable: true, renderer: flag, dataIndex: 'country'},
{header: 'Address', width: 125, sortable: true, renderer: peer_address, dataIndex: 'address'},
{header: 'Client', width: 125, sortable: true, renderer: Deluge.Formatters.plain, dataIndex: 'client'},
{header: 'Progress', width: 150, sortable: true, renderer: peer_progress, dataIndex: 'progress'},
{header: 'Progress', width: 150, sortable: true, renderer: progress_renderer, dataIndex: 'progress'},
{header: 'Down Speed', width: 100, sortable: true, renderer: fspeed, dataIndex: 'downspeed'},
{header: 'Up Speed', width: 100, sortable: true, renderer: fspeed, dataIndex: 'upspeed'}
],

View file

@ -120,6 +120,17 @@ Deluge.Formatters = {
}
}
FILE_PRIORITY = {
0: 'Do Not Download',
1: 'Normal Priority',
2: 'High Priority',
5: 'Highest Priority',
'Do Not Download': 0,
'Normal Priority': 1,
'High Priority': 2,
'Highest Priority': 5
}
var fsize = Deluge.Formatters.size;
var fspeed = Deluge.Formatters.speed;
var ftime = Deluge.Formatters.timeRemaining;

View file

@ -332,6 +332,7 @@ class WebApi(JSONComponent):
def _on_got_files(self, torrent, d):
files = torrent.get("files")
file_progress = torrent.get("file_progress")
file_priorities = torrent.get("file_priorities")
paths = []
info = {}
@ -339,12 +340,14 @@ class WebApi(JSONComponent):
path = torrent_file["path"]
paths.append(path)
torrent_file["progress"] = file_progress[index]
torrent_file["priority"] = file_priorities[index]
info[path] = torrent_file
def walk(path, item):
if type(item) is dict:
return item
return [info[path]["size"], info[path]["progress"]]
return [info[path]["size"], info[path]["progress"],
info[path]["priority"]]
file_tree = uicommon.FileTree(paths)
file_tree.walk(walk)