add sorting of the files by filenames, and folders display at the top

This commit is contained in:
Damien Churchill 2009-04-01 16:33:31 +00:00
parent de733b0fae
commit baf3d283e0
2 changed files with 14 additions and 2 deletions

View File

@ -51,7 +51,9 @@ Deluge.Add = {
}, },
onRender: function(window) { onRender: function(window) {
new Ext.tree.TreeSorter(this.Files, {
folderSort: true
});
}, },
onSelect: function(selModel, rowIndex, record) { onSelect: function(selModel, rowIndex, record) {
@ -68,6 +70,7 @@ Deluge.Add = {
} else { } else {
parent.appendChild(new Ext.tree.TreeNode({ parent.appendChild(new Ext.tree.TreeNode({
filename: file, filename: file,
text: file, // this needs to be here for sorting reasons
size: fsize(item[0]), size: fsize(item[0]),
leaf: true, leaf: true,
checked: item[1], checked: item[1],
@ -79,7 +82,10 @@ Deluge.Add = {
} }
this.clearFiles(); this.clearFiles();
walk(torrentInfo['files'], this.Files.getRootNode());
var root = this.Files.getRootNode();
walk(torrentInfo['files'], root);
root.firstChild.expand();
}, },
onTorrentAdded: function(info) { onTorrentAdded: function(info) {

View File

@ -201,6 +201,10 @@ Deluge.Details.Files = {
this.panel = panel; this.panel = panel;
this.panel.clear = this.clear.bind(this); this.panel.clear = this.clear.bind(this);
this.panel.update = this.update.bind(this); this.panel.update = this.update.bind(this);
new Ext.tree.TreeSorter(this.panel, {
folderSort: true
});
}, },
onRequestComplete: function(files, torrentId) { onRequestComplete: function(files, torrentId) {
@ -225,6 +229,7 @@ Deluge.Details.Files = {
child = new Ext.tree.TreeNode({ child = new Ext.tree.TreeNode({
id: file, id: file,
filename: file, filename: file,
text: file, // this needs to be here for sorting
size: fsize(item[0]), size: fsize(item[0]),
progress: item[1], progress: item[1],
leaf: true, leaf: true,
@ -238,6 +243,7 @@ Deluge.Details.Files = {
} }
var root = this.panel.getRootNode(); var root = this.panel.getRootNode();
walk(files, root); walk(files, root);
root.firstChild.expand();
}, },
clear: function() { clear: function() {