From 0fbbf4ac6c4156b3eaf24199dd0caf39734ad0d8 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Mon, 12 Apr 2010 00:11:10 +0100 Subject: [PATCH] fix setting file download priority in the add window --- deluge/ui/web/js/deluge-all/add/FilesTab.js | 31 ++++++++++++++----- .../ui/web/js/deluge-all/add/OptionsPanel.js | 17 +++++----- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/add/FilesTab.js b/deluge/ui/web/js/deluge-all/add/FilesTab.js index 86ef7d03c..7d7db7112 100644 --- a/deluge/ui/web/js/deluge-all/add/FilesTab.js +++ b/deluge/ui/web/js/deluge-all/add/FilesTab.js @@ -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 '
'; + } + }) }], + 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); } }); diff --git a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js index 59708cb08..b925d26a1 100644 --- a/deluge/ui/web/js/deluge-all/add/OptionsPanel.js +++ b/deluge/ui/web/js/deluge-all/add/OptionsPanel.js @@ -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); } });