Author: damoxc

Revision: 4968

Log:
        extend the treenode to provide a method to allow for updating colum 
values

Diff:
Modified: trunk/deluge/ui/web/js/deluge-details.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-details.js    2009-04-01 18:46:48 UTC (rev 
4967)
+++ trunk/deluge/ui/web/js/deluge-details.js    2009-04-01 19:36:27 UTC (rev 
4968)
@@ -226,11 +226,11 @@
                                        walk(item, child);
                                } else {
                                        if (!child) {
-                                               child = new Ext.tree.TreeNode({
+                                               child = new 
Ext.tree.ColumnTreeNode({
                                                        id: file,
                                                        filename: file,
                                                        text: file, // this 
needs to be here for sorting
-                                                       size: fsize(item[0]),
+                                                       size: item[0],
                                                        progress: item[1],
                                                        priority: item[2],
                                                        leaf: true,
@@ -239,6 +239,9 @@
                                                });
                                                parent.appendChild(child);
                                        }
+                                       child.setColumnValue(1, item[0]);
+                                       child.setColumnValue(2, item[1]);
+                                       child.setColumnValue(3, item[2]);
                                }
                        });
                }
@@ -370,7 +373,8 @@
                },{
                        header: _('Size'),
                        width: 150,
-                       dataIndex: 'size'
+                       dataIndex: 'size',
+                       renderer: fsize
                },{
                        header: _('Progress'),
                        width: 150,

Modified: trunk/deluge/ui/web/js/deluge-ext.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-ext.js        2009-04-01 18:46:48 UTC (rev 
4967)
+++ trunk/deluge/ui/web/js/deluge-ext.js        2009-04-01 19:36:27 UTC (rev 
4968)
@@ -84,8 +84,27 @@
     }
 });
 
+Ext.tree.ColumnTreeNode = Ext.extend(Ext.tree.TreeNode, {
+       
+       setColumnValue: function(index, value) {
+               var t = this.getOwnerTree();
+               var oldValue = this[t.columns[index].dataIndex];
+               if (this.rendered) {
+                       this.ui.onColumnValueChange(this, index, value, 
oldValue);
+               }
+               this.fireEvent('columnvaluechange', this, index, value, 
oldValue);
+       }
+});
+
 Ext.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
     focus: Ext.emptyFn, // prevent odd scrolling behavior
+       
+       onColumnValueChange: function(n, colIndex, value, oldValue) {
+               if (this.rendered) {
+                       var c = n.getOwnerTree().columns[colIndex];
+                       this.columnNodes[colIndex].innerHTML = (c.renderer ? 
c.renderer(value, n, null) : value);
+               }
+       },
 
     renderElements : function(n, a, targetNode, bulkRender){
         this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : 
'';
@@ -134,8 +153,18 @@
         this.indentNode = cs[0];
         this.ecNode = cs[1];
         this.iconNode = cs[2];
-        this.anchor = cs[3];
-        this.textNode = cs[3].firstChild;
+               var index = 3;
+        if(cb){
+            this.checkbox = cs[3];
+                       // fix for IE6
+                       this.checkbox.defaultChecked = this.checkbox.checked;   
                
+            index++;
+        }
+        this.anchor = cs[index];
+               this.columnNodes = [cs[index].firstChild];
+               for(var i = 1, len = cols.length; i < len; i++){
+                       this.columnNodes[i] = 
this.elNode.childNodes[i].firstChild;
+               }
     }
 });
 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to