implement setting the file priority via the context menu
This commit is contained in:
parent
8b76cd8a2a
commit
4087dd38cb
|
@ -205,6 +205,7 @@ Deluge.Details.Files = {
|
||||||
new Ext.tree.TreeSorter(this.panel, {
|
new Ext.tree.TreeSorter(this.panel, {
|
||||||
folderSort: true
|
folderSort: true
|
||||||
});
|
});
|
||||||
|
Deluge.Menus.FilePriorities.on('itemclick', this.onItemClick.bindWithEvent(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
onContextMenu: function(node, e) {
|
onContextMenu: function(node, e) {
|
||||||
|
@ -213,6 +214,36 @@ Deluge.Details.Files = {
|
||||||
Deluge.Menus.FilePriorities.showAt(e.getPoint());
|
Deluge.Menus.FilePriorities.showAt(e.getPoint());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onItemClick: function(baseItem, e) {
|
||||||
|
switch (baseItem.id) {
|
||||||
|
case 'expandAll':
|
||||||
|
this.panel.expandAll();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
var indexes = new Hash();
|
||||||
|
function walk(node) {
|
||||||
|
if (!node.attributes.fileIndex) return;
|
||||||
|
indexes[node.attributes.fileIndex] = node.attributes.priority;
|
||||||
|
}
|
||||||
|
this.panel.getRootNode().cascade(walk);
|
||||||
|
|
||||||
|
var node = this.panel.getSelectionModel().getSelectedNode();
|
||||||
|
indexes[node.attributes.fileIndex] = baseItem.filePriority;
|
||||||
|
|
||||||
|
priorities = new Array(indexes.getLength());
|
||||||
|
indexes.each(function(priority, index) {
|
||||||
|
priorities[index] = priority;
|
||||||
|
});
|
||||||
|
|
||||||
|
Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
|
||||||
|
onSuccess: function() {
|
||||||
|
this.update(this.torrentId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onRequestComplete: function(files, torrentId) {
|
onRequestComplete: function(files, torrentId) {
|
||||||
if (this.torrentId != torrentId) {
|
if (this.torrentId != torrentId) {
|
||||||
this.clear();
|
this.clear();
|
||||||
|
@ -236,18 +267,19 @@ Deluge.Details.Files = {
|
||||||
id: file,
|
id: file,
|
||||||
filename: file,
|
filename: file,
|
||||||
text: file, // this needs to be here for sorting
|
text: file, // this needs to be here for sorting
|
||||||
size: item[0],
|
fileIndex: item[0],
|
||||||
progress: item[1],
|
size: item[1],
|
||||||
priority: item[2],
|
progress: item[2],
|
||||||
|
priority: item[3],
|
||||||
leaf: true,
|
leaf: true,
|
||||||
iconCls: 'x-deluge-file',
|
iconCls: 'x-deluge-file',
|
||||||
uiProvider: Ext.tree.ColumnNodeUI
|
uiProvider: Ext.tree.ColumnNodeUI
|
||||||
});
|
});
|
||||||
parent.appendChild(child);
|
parent.appendChild(child);
|
||||||
}
|
}
|
||||||
child.setColumnValue(1, item[0]);
|
child.setColumnValue(1, item[1]);
|
||||||
child.setColumnValue(2, item[1]);
|
child.setColumnValue(2, item[2]);
|
||||||
child.setColumnValue(3, item[2]);
|
child.setColumnValue(3, item[3]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,19 +383,23 @@ Deluge.Menus.FilePriorities = new Ext.menu.Menu({
|
||||||
}, '-', {
|
}, '-', {
|
||||||
id: 'no_download',
|
id: 'no_download',
|
||||||
text: _('Do Not Download'),
|
text: _('Do Not Download'),
|
||||||
icon: '/icons/no_download.png'
|
icon: '/icons/no_download.png',
|
||||||
|
filePriority: 0
|
||||||
}, {
|
}, {
|
||||||
id: 'normal',
|
id: 'normal',
|
||||||
text: _('Normal Priority'),
|
text: _('Normal Priority'),
|
||||||
icon: '/icons/normal.png'
|
icon: '/icons/normal.png',
|
||||||
|
filePriority: 1
|
||||||
}, {
|
}, {
|
||||||
id: 'high',
|
id: 'high',
|
||||||
text: _('High Priority'),
|
text: _('High Priority'),
|
||||||
icon: '/icons/high.png'
|
icon: '/icons/high.png',
|
||||||
|
filePriority: 2
|
||||||
}, {
|
}, {
|
||||||
id: 'highest',
|
id: 'highest',
|
||||||
text: _('Highest Priority'),
|
text: _('Highest Priority'),
|
||||||
icon: '/icons/highest.png'
|
icon: '/icons/highest.png',
|
||||||
|
filePriority: 5
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -341,13 +341,14 @@ class WebApi(JSONComponent):
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
torrent_file["progress"] = file_progress[index]
|
torrent_file["progress"] = file_progress[index]
|
||||||
torrent_file["priority"] = file_priorities[index]
|
torrent_file["priority"] = file_priorities[index]
|
||||||
|
torrent_file["index"] = index
|
||||||
info[path] = torrent_file
|
info[path] = torrent_file
|
||||||
|
|
||||||
def walk(path, item):
|
def walk(path, item):
|
||||||
if type(item) is dict:
|
if type(item) is dict:
|
||||||
return item
|
return item
|
||||||
return [info[path]["size"], info[path]["progress"],
|
return [info[path]["index"], info[path]["size"],
|
||||||
info[path]["priority"]]
|
info[path]["progress"], info[path]["priority"]]
|
||||||
|
|
||||||
file_tree = uicommon.FileTree(paths)
|
file_tree = uicommon.FileTree(paths)
|
||||||
file_tree.walk(walk)
|
file_tree.walk(walk)
|
||||||
|
|
Loading…
Reference in New Issue