mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 06:58:42 +00:00
improve the selective downloading adding support for directories and don't recreate treenodes
This commit is contained in:
parent
c176ff900f
commit
dd1716c240
2 changed files with 53 additions and 38 deletions
|
@ -65,7 +65,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
dataIndex: 'download',
|
dataIndex: 'download',
|
||||||
tpl: new Ext.XTemplate('{download:this.format}', {
|
tpl: new Ext.XTemplate('{download:this.format}', {
|
||||||
format: function(v) {
|
format: function(v) {
|
||||||
return '<div class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
return '<div rel="chkbox" class="x-grid3-check-col'+(v?'-on':'')+'"> </div>';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}],
|
}],
|
||||||
|
@ -84,23 +84,25 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onNodeClick: function(node, e) {
|
setDownload: function(node, value) {
|
||||||
node.attributes.download = !node.attributes.download;
|
node.attributes.download = value;
|
||||||
var newNode = new Ext.tree.TreeNode(node.attributes);
|
node.ui.updateColumns();
|
||||||
node.parentNode.replaceChild(newNode, node);
|
|
||||||
this.fireEvent('filechecked', newNode, node.attributes.download, !node.attributes.download);
|
if (node.isLeaf()) {
|
||||||
|
return this.fireEvent('filechecked', node, value, !value);
|
||||||
|
} else {
|
||||||
|
node.cascade(function(n) {
|
||||||
|
n.attributes.download = value;
|
||||||
|
n.ui.updateColumns();
|
||||||
|
return this.fireEvent('filechecked', n, value, !value);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFolderCheck: function(node, checked) {
|
onNodeClick: function(node, e) {
|
||||||
var priorities = this.optionsManager.get('file_priorities');
|
var el = new Ext.Element(e.target);
|
||||||
node.cascade(function(child) {
|
if (el.getAttribute('rel') == 'chkbox') {
|
||||||
if (!child.ui.checkbox) {
|
this.setDownload(node, !node.attributes.download);
|
||||||
child.attributes.checked = checked;
|
}
|
||||||
} else {
|
|
||||||
child.ui.checkbox.checked = checked;
|
|
||||||
}
|
|
||||||
priorities[child.attributes.fileindex] = checked;
|
|
||||||
}, this);
|
|
||||||
this.optionsManager.setDefault('file_priorities', priorities);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,27 +97,15 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
var priorities = this.form.optionsManager.get('file_priorities');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
|
|
||||||
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) {
|
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) {
|
||||||
if (type == 'dir') {
|
var node = new Ext.tree.TreeNode({
|
||||||
var folder = new Ext.tree.TreeNode({
|
download: (entry.index) ? priorities[entry.index] : true,
|
||||||
filename: filename,
|
filename: filename,
|
||||||
size: entry.length,
|
fileindex: entry.index,
|
||||||
download: true
|
leaf: type != 'dir',
|
||||||
});
|
size: entry.length
|
||||||
folder.on('checkchange', this.onFolderCheck, this);
|
});
|
||||||
parentNode.appendChild(folder);
|
parentNode.appendChild(node);
|
||||||
return folder;
|
if (type == 'dir') return node;
|
||||||
} else {
|
|
||||||
var node = new Ext.tree.TreeNode({
|
|
||||||
filename: filename,
|
|
||||||
fileindex: entry.index,
|
|
||||||
size: entry.length,
|
|
||||||
leaf: true,
|
|
||||||
download: priorities[entry.index],
|
|
||||||
uiProvider: Ext.tree.ColumnNodeUI
|
|
||||||
});
|
|
||||||
node.on('checkchange', this.onNodeCheck, this);
|
|
||||||
parentNode.appendChild(node);
|
|
||||||
}
|
|
||||||
}, this, root);
|
}, this, root);
|
||||||
root.firstChild.expand();
|
root.firstChild.expand();
|
||||||
},
|
},
|
||||||
|
@ -138,6 +126,31 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onFileChecked: function(node, newValue, oldValue) {
|
onFileChecked: function(node, newValue, oldValue) {
|
||||||
|
if (!Ext.isNumber(node.attributes.fileindex)) return;
|
||||||
|
|
||||||
|
// if (this.form.optionsManager.get('compact_allocation')) {
|
||||||
|
// Ext.Msg.show({
|
||||||
|
// title: _('Unable to set file priority!'),
|
||||||
|
// msg: _('File prioritization is unavailable when using Compact allocation. Would you like to switch to Full allocation?'),
|
||||||
|
// buttons: Ext.Msg.YESNO,
|
||||||
|
// fn: function(result) {
|
||||||
|
// if (result == 'yes') {
|
||||||
|
// var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
|
// priorities[node.attributes.fileindex] = (result) ? newValue : oldValue;
|
||||||
|
// this.form.optionsManager.update('file_priorities', priorities);
|
||||||
|
// } else {
|
||||||
|
// node.attributes.download = oldValue;
|
||||||
|
// node.ui.updateColumns();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// scope: this,
|
||||||
|
// icon: Ext.MessageBox.QUESTION
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
|
// priorities[node.attributes.fileindex] = newValue;
|
||||||
|
// this.form.optionsManager.update('file_priorities', priorities);
|
||||||
|
// }
|
||||||
var priorities = this.form.optionsManager.get('file_priorities');
|
var priorities = this.form.optionsManager.get('file_priorities');
|
||||||
priorities[node.attributes.fileindex] = newValue;
|
priorities[node.attributes.fileindex] = newValue;
|
||||||
this.form.optionsManager.update('file_priorities', priorities);
|
this.form.optionsManager.update('file_priorities', priorities);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue