change it so multiple files can be changed at a time

This commit is contained in:
Damien Churchill 2009-04-01 21:51:04 +00:00
parent 4087dd38cb
commit 583d76ca18
2 changed files with 23 additions and 5 deletions

View File

@ -210,7 +210,11 @@ Deluge.Details.Files = {
onContextMenu: function(node, e) {
e.stopEvent();
node.select();
var selModel = this.panel.getSelectionModel();
if (selModel.getSelectedNodes().length < 2) {
selModel.clearSelections();
node.select();
}
Deluge.Menus.FilePriorities.showAt(e.getPoint());
},
@ -222,13 +226,24 @@ Deluge.Details.Files = {
default:
var indexes = new Hash();
function walk(node) {
if (!node.attributes.fileIndex) return;
if (!$defined(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;
alert(JSON.encode(indexes));
var nodes = this.panel.getSelectionModel().getSelectedNodes();
$each(nodes, function(node) {
if (!$defined(node.attributes.fileIndex)) return;
indexes[node.attributes.fileIndex] = baseItem.filePriority;
});
alert(JSON.encode(indexes));
/*var keys = indexes.getKeys();
alert(keys);
keys.sort(function(a, b) { return a - b; });
alert(keys);*/
priorities = new Array(indexes.getLength());
indexes.each(function(priority, index) {
@ -238,7 +253,7 @@ Deluge.Details.Files = {
Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
onSuccess: function() {
this.update(this.torrentId);
}
}.bind(this)
});
break;
}
@ -403,6 +418,7 @@ Deluge.Details.Panel = new Ext.TabPanel({
title: _('Files'),
rootVisible: false,
autoScroll: true,
selModel: new Ext.tree.MultiSelectionModel(),
columns: [{
header: _('Filename'),

View File

@ -89,6 +89,8 @@ Ext.tree.ColumnTreeNode = Ext.extend(Ext.tree.TreeNode, {
setColumnValue: function(index, value) {
var t = this.getOwnerTree();
var oldValue = this[t.columns[index].dataIndex];
this[t.columns[index].dataIndex] = value;
this.attributes[[t.columns[index].dataIndex]] = value;
if (this.rendered) {
this.ui.onColumnValueChange(this, index, value, oldValue);
}