partially working files tab added back in

This commit is contained in:
Damien Churchill 2010-01-24 04:06:06 +00:00
parent c7635b0ff0
commit d74050e7a6
5 changed files with 26 additions and 7 deletions

View File

@ -40,7 +40,7 @@ Copyright:
return String.format('<div class="{0}">{1}</div>', FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
}
Ext.deluge.details.FilesTab = Ext.extend(Ext.tree.ColumnTree, {
Ext.deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
constructor: function(config) {
config = Ext.apply({
@ -54,16 +54,19 @@ Copyright:
width: 330,
dataIndex: 'filename'
}, {
xtype: 'tgcustomcolumn',
header: _('Size'),
width: 150,
dataIndex: 'size',
renderer: fsize
}, {
xtype: 'tgcustomcolumn',
header: _('Progress'),
width: 150,
dataIndex: 'progress',
renderer: fileProgressRenderer
}, {
xtype: 'tgcustomcolumn',
header: _('Priority'),
width: 150,
dataIndex: 'priority',
@ -74,8 +77,14 @@ Copyright:
text: 'Files'
})
}, config);
Ext.deluge.details.FilesTab.superclass.constructor.call(this, config);
},
initComponent: function() {
Ext.deluge.details.FilesTab.superclass.initComponent.call(this);
},
onRender: function(ct, position) {
Ext.deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
@ -173,14 +182,15 @@ Copyright:
if (!child) {
child = new Ext.tree.TreeNode({
id: file,
text: file
text: file,
filename: file
});
parent.appendChild(child);
}
walk(item, child);
} else {
if (!child) {
child = new Ext.tree.ColumnTreeNode({
child = new Ext.tree.TreeNode({
id: file,
filename: file,
text: file, // this needs to be here for sorting
@ -190,13 +200,10 @@ Copyright:
priority: item[3],
leaf: true,
iconCls: 'x-deluge-file',
uiProvider: Ext.tree.ColumnNodeUI
uiProvider: Ext.ux.tree.TreeGridNodeUI
});
parent.appendChild(child);
}
child.setColumnValue(1, item[1]);
child.setColumnValue(2, item[2]);
child.setColumnValue(3, item[3]);
}
}
}

View File

@ -64,6 +64,7 @@ Deluge.Formatters = {
* @returns {string} formatted string with KiB, MiB or GiB units.
*/
size: function(bytes) {
if (!bytes) return '';
bytes = bytes / 1024.0;
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }

View File

@ -12,4 +12,5 @@ add_file "TreeGridColumnResizer.js"
add_file "TreeGridNodeUI.js"
add_file "TreeGridLoader.js"
add_file "TreeGridColumns.js"
add_file "TreeGridCustomColumn.js"
add_file "TreeGrid.js"

View File

@ -0,0 +1,9 @@
Ext.tree.CustomColumn = Ext.extend(Ext.tree.Column, {
constructor: function(c) {
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
c.tpl.format = c.renderer;
Ext.tree.CustomColumn.superclass.constructor.call(this, c);
}
});
Ext.reg('tgcustomcolumn', Ext.tree.CustomColumn);

View File

@ -331,6 +331,7 @@ class TopLevel(resource.Resource):
"/js/ext-extensions/TreeGridNodeUI.js",
"/js/ext-extensions/TreeGridLoader.js",
"/js/ext-extensions/TreeGridColumns.js",
"/js/ext-extensions/TreeGridCustomColumn.js",
"/js/ext-extensions/TreeGrid.js",
"/config.js",
"/gettext.js",