add...
Content-type: text/plain

Author: damoxc

Revision: 6143

Log:
        fix the progressbar renderer for the file tree
add a new file priority "Mixed"
add progress bars and priorities for directories using the new tree format

Diff:
Modified: trunk/deluge/ui/web/css/deluge.css
===================================================================
--- trunk/deluge/ui/web/css/deluge.css  2010-01-26 13:12:32 UTC (rev 6142)
+++ trunk/deluge/ui/web/css/deluge.css  2010-01-26 13:18:16 UTC (rev 6143)
@@ -207,6 +207,12 @@
        margin-top: 0px;
 }
 
+/* Files TreeGrid */
+.x-treegrid-col {
+       overflow: hidden;
+}
+
+
 /* Options Tab Styles */
 .x-deluge-options-label {
        margin-right: 10px;

Modified: trunk/deluge/ui/web/js/deluge-all/Deluge.Details.Files.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-all/Deluge.Details.Files.js   2010-01-26 
13:12:32 UTC (rev 6142)
+++ trunk/deluge/ui/web/js/deluge-all/Deluge.Details.Files.js   2010-01-26 
13:18:16 UTC (rev 6143)
@@ -34,10 +34,10 @@
        /* Renderers for the column tree */
        function fileProgressRenderer(value) {
                var progress = value * 100;
-               return Deluge.progressBar(progress, this.width - 50, 
progress.toFixed(2) + '%', 0);
+               return Deluge.progressBar(progress, this.col.width, 
progress.toFixed(2) + '%', 0);
        }
        function priorityRenderer(value) {
-               if (!value) return '';
+               if (isNaN(value)) return '';
                return String.format('<div class="{0}">{1}</div>', 
FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
        }
        
@@ -55,19 +55,19 @@
                                        width: 330,
                                        dataIndex: 'filename'
                                }, {
-                                       xtype: 'tgcustomcolumn',
+                                       xtype: 'tgrendercolumn',
                                        header: _('Size'),
                                        width: 150,
                                        dataIndex: 'size',
                                        renderer: fsize
                                }, {
-                                       xtype: 'tgcustomcolumn',
+                                       xtype: 'tgrendercolumn',
                                        header: _('Progress'),
                                        width: 150,
                                        dataIndex: 'progress',
                                        renderer: fileProgressRenderer
                                }, {
-                                       xtype: 'tgcustomcolumn',
+                                       xtype: 'tgrendercolumn',
                                        header: _('Priority'),
                                        width: 150,
                                        dataIndex: 'priority',
@@ -176,15 +176,18 @@
                
                onRequestComplete: function(files, options) {
                        function walk(files, parent) {
-                               for (var file in files) {
-                                       var item = files[file];
+                               for (var file in files.contents) {
+                                       var item = files.contents[file];
                                        var child = parent.findChild('id', 
file);
-                                       if (Ext.type(item) == 'object') {
+                                       if (item.type == 'dir') {
                                                if (!child) {
                                                        child = new 
Ext.tree.TreeNode({
                                                                id: file,
                                                                text: file,
-                                                               filename: file
+                                                               filename: file,
+                                                               size: 
item['size'],
+                                                               progress: 
item['progress'],
+                                                               priority: 
item['priority']
                                                        });
                                                        
parent.appendChild(child);
                                                }
@@ -195,10 +198,10 @@
                                                                id: file,
                                                                filename: file,
                                                                text: file, // 
this needs to be here for sorting
-                                                               fileIndex: 
item[0],
-                                                               size: item[1],
-                                                               progress: 
item[2],
-                                                               priority: 
item[3],
+                                                               fileIndex: 
item['index'],
+                                                               size: 
item['size'],
+                                                               progress: 
item['progress'],
+                                                               priority: 
item['priority'],
                                                                leaf: true,
                                                                iconCls: 
'x-deluge-file',
                                                                uiProvider: 
Ext.ux.tree.TreeGridNodeUI

Modified: trunk/deluge/ui/web/js/deluge-all/Deluge.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-all/Deluge.js 2010-01-26 13:12:32 UTC (rev 
6142)
+++ trunk/deluge/ui/web/js/deluge-all/Deluge.js 2010-01-26 13:18:16 UTC (rev 
6143)
@@ -119,10 +119,12 @@
 // _('High Priority')
 // _('Highest Priority')
 FILE_PRIORITY = {
+       9: 'Mixed',
     0: 'Do Not Download',
     1: 'Normal Priority',
     2: 'High Priority',
     5: 'Highest Priority',
+       'Mixed': 9,
     'Do Not Download': 0,
     'Normal Priority': 1,
     'High Priority': 2,
@@ -130,6 +132,7 @@
 }
 
 FILE_PRIORITY_CSS = {
+       9: 'x-mixed-download',
        0: 'x-no-download',
        1: 'x-normal-download',
        2: 'x-high-download',

Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py     2010-01-26 13:12:32 UTC (rev 6142)
+++ trunk/deluge/ui/web/json_api.py     2010-01-26 13:18:16 UTC (rev 6143)
@@ -532,6 +532,7 @@
 
         paths = []
         info = {}
+        dir_info = {}
         for index, torrent_file in enumerate(files):
             path = torrent_file["path"]
             paths.append(path)
@@ -540,13 +541,28 @@
             torrent_file["index"] = index
             info[path] = torrent_file
 
+            # update the directory info
+            dirinfo = info.setdefault(os.path.dirname(path), {})
+            dirinfo["size"] = dirinfo.get("size", 0) + torrent_file["size"]
+            if "priority" not in dirinfo:
+                dirinfo["priority"] = torrent_file["priority"]
+            else:
+                if dirinfo["priority"] != torrent_file["priority"]:
+                    dirinfo["priority"] = 9
+
+            progresses = dirinfo.setdefault("progresses", [])
+            progresses.append(torrent_file["progress"])
+            dirinfo["progress"] = float(sum(progresses)) / len(progresses)
+
         def walk(path, item):
-            if type(item) is dict:
+            if item["type"] == "dir":
+                item.update(info[path])
                 return item
-            return [info[path]["index"], info[path]["size"],
-                    info[path]["progress"], info[path]["priority"]]
+            else:
+                item.update(info[path])
+                return item
 
-        file_tree = uicommon.FileTree(paths)
+        file_tree = uicommon.FileTree2(paths)
         file_tree.walk(walk)
         d.callback(file_tree.get_tree())
 


-- 
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