fix setting file download priority in the add window
This commit is contained in:
parent
61dd9a5589
commit
0fbbf4ac6c
|
@ -48,19 +48,33 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
|||
|
||||
columns: [{
|
||||
header: _('Filename'),
|
||||
width: 275,
|
||||
width: 295,
|
||||
dataIndex: 'filename'
|
||||
},{
|
||||
header: _('Size'),
|
||||
width: 80,
|
||||
width: 60,
|
||||
dataIndex: 'size',
|
||||
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
||||
fsize: function(v) {
|
||||
return fsize(v);
|
||||
}
|
||||
})
|
||||
},{
|
||||
header: _('Download'),
|
||||
width: 65,
|
||||
dataIndex: 'download',
|
||||
tpl: new Ext.XTemplate('{download:this.format}', {
|
||||
format: function(v) {
|
||||
return '<div class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
||||
}
|
||||
})
|
||||
}],
|
||||
|
||||
initComponent: function() {
|
||||
Deluge.add.FilesTab.superclass.initComponent.call(this);
|
||||
this.on('click', this.onNodeClick, this);
|
||||
},
|
||||
|
||||
clearFiles: function() {
|
||||
var root = this.getRootNode();
|
||||
if (!root.hasChildNodes()) return;
|
||||
|
@ -70,6 +84,13 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
|||
});
|
||||
},
|
||||
|
||||
onNodeClick: function(node, e) {
|
||||
node.attributes.download = !node.attributes.download;
|
||||
var newNode = new Ext.tree.TreeNode(node.attributes);
|
||||
node.parentNode.replaceChild(newNode, node);
|
||||
this.fireEvent('filechecked', newNode, node.attributes.download, !node.attributes.download);
|
||||
},
|
||||
|
||||
onFolderCheck: function(node, checked) {
|
||||
var priorities = this.optionsManager.get('file_priorities');
|
||||
node.cascade(function(child) {
|
||||
|
@ -81,11 +102,5 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
|||
priorities[child.attributes.fileindex] = checked;
|
||||
}, this);
|
||||
this.optionsManager.setDefault('file_priorities', priorities);
|
||||
},
|
||||
|
||||
onNodeCheck: function(node, checked) {
|
||||
var priorities = this.optionsManager.get('file_priorities');
|
||||
priorities[node.attributes.fileindex] = checked;
|
||||
this.optionsManager.update('file_priorities', priorities);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -45,13 +45,8 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
Deluge.add.OptionsPanel.superclass.initComponent.call(this);
|
||||
this.files = this.add(new Deluge.add.FilesTab());
|
||||
this.form = this.add(new Deluge.add.OptionsTab());
|
||||
//this.form.on('render', this.onFormRender, this);
|
||||
},
|
||||
|
||||
onFormRender: function(form) {
|
||||
form.layout = new Ext.layout.FormLayout();
|
||||
form.layout.setContainer(form);
|
||||
form.doLayout();
|
||||
this.files.on('filechecked', this.onFileChecked, this);
|
||||
},
|
||||
|
||||
addTorrent: function(torrent) {
|
||||
|
@ -106,7 +101,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
var folder = new Ext.tree.TreeNode({
|
||||
filename: filename,
|
||||
size: entry.length,
|
||||
checked: true
|
||||
download: true
|
||||
});
|
||||
folder.on('checkchange', this.onFolderCheck, this);
|
||||
parentNode.appendChild(folder);
|
||||
|
@ -117,7 +112,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
fileindex: entry.index,
|
||||
size: entry.length,
|
||||
leaf: true,
|
||||
checked: priorities[entry.index],
|
||||
download: priorities[entry.index],
|
||||
uiProvider: Ext.tree.ColumnNodeUI
|
||||
});
|
||||
node.on('checkchange', this.onNodeCheck, this);
|
||||
|
@ -140,5 +135,11 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
|||
|
||||
if (type == 'dir') this.walkFileTree(entry, callback, scope, ret);
|
||||
}
|
||||
},
|
||||
|
||||
onFileChecked: function(node, newValue, oldValue) {
|
||||
var priorities = this.form.optionsManager.get('file_priorities');
|
||||
priorities[node.attributes.fileindex] = newValue;
|
||||
this.form.optionsManager.update('file_priorities', priorities);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue