mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
fix setting file download priority in the add window
This commit is contained in:
parent
61dd9a5589
commit
0fbbf4ac6c
2 changed files with 32 additions and 16 deletions
|
@ -48,19 +48,33 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
|
|
||||||
columns: [{
|
columns: [{
|
||||||
header: _('Filename'),
|
header: _('Filename'),
|
||||||
width: 275,
|
width: 295,
|
||||||
dataIndex: 'filename'
|
dataIndex: 'filename'
|
||||||
},{
|
},{
|
||||||
header: _('Size'),
|
header: _('Size'),
|
||||||
width: 80,
|
width: 60,
|
||||||
dataIndex: 'size',
|
dataIndex: 'size',
|
||||||
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
tpl: new Ext.XTemplate('{size:this.fsize}', {
|
||||||
fsize: function(v) {
|
fsize: function(v) {
|
||||||
return fsize(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() {
|
clearFiles: function() {
|
||||||
var root = this.getRootNode();
|
var root = this.getRootNode();
|
||||||
if (!root.hasChildNodes()) return;
|
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) {
|
onFolderCheck: function(node, checked) {
|
||||||
var priorities = this.optionsManager.get('file_priorities');
|
var priorities = this.optionsManager.get('file_priorities');
|
||||||
node.cascade(function(child) {
|
node.cascade(function(child) {
|
||||||
|
@ -81,11 +102,5 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
priorities[child.attributes.fileindex] = checked;
|
priorities[child.attributes.fileindex] = checked;
|
||||||
}, this);
|
}, this);
|
||||||
this.optionsManager.setDefault('file_priorities', priorities);
|
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);
|
Deluge.add.OptionsPanel.superclass.initComponent.call(this);
|
||||||
this.files = this.add(new Deluge.add.FilesTab());
|
this.files = this.add(new Deluge.add.FilesTab());
|
||||||
this.form = this.add(new Deluge.add.OptionsTab());
|
this.form = this.add(new Deluge.add.OptionsTab());
|
||||||
//this.form.on('render', this.onFormRender, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
onFormRender: function(form) {
|
this.files.on('filechecked', this.onFileChecked, this);
|
||||||
form.layout = new Ext.layout.FormLayout();
|
|
||||||
form.layout.setContainer(form);
|
|
||||||
form.doLayout();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addTorrent: function(torrent) {
|
addTorrent: function(torrent) {
|
||||||
|
@ -106,7 +101,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
var folder = new Ext.tree.TreeNode({
|
var folder = new Ext.tree.TreeNode({
|
||||||
filename: filename,
|
filename: filename,
|
||||||
size: entry.length,
|
size: entry.length,
|
||||||
checked: true
|
download: true
|
||||||
});
|
});
|
||||||
folder.on('checkchange', this.onFolderCheck, this);
|
folder.on('checkchange', this.onFolderCheck, this);
|
||||||
parentNode.appendChild(folder);
|
parentNode.appendChild(folder);
|
||||||
|
@ -117,7 +112,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
fileindex: entry.index,
|
fileindex: entry.index,
|
||||||
size: entry.length,
|
size: entry.length,
|
||||||
leaf: true,
|
leaf: true,
|
||||||
checked: priorities[entry.index],
|
download: priorities[entry.index],
|
||||||
uiProvider: Ext.tree.ColumnNodeUI
|
uiProvider: Ext.tree.ColumnNodeUI
|
||||||
});
|
});
|
||||||
node.on('checkchange', this.onNodeCheck, this);
|
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);
|
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…
Add table
Add a link
Reference in a new issue