Author: damoxc
Revision: 4970
Log:
implement setting the file priority via the context menu
Diff:
Modified: trunk/deluge/ui/web/js/deluge-details.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-details.js 2009-04-01 20:03:21 UTC (rev
4969)
+++ trunk/deluge/ui/web/js/deluge-details.js 2009-04-01 21:31:36 UTC (rev
4970)
@@ -205,6 +205,7 @@
new Ext.tree.TreeSorter(this.panel, {
folderSort: true
});
+ Deluge.Menus.FilePriorities.on('itemclick',
this.onItemClick.bindWithEvent(this));
},
onContextMenu: function(node, e) {
@@ -213,8 +214,38 @@
Deluge.Menus.FilePriorities.showAt(e.getPoint());
},
+ onItemClick: function(baseItem, e) {
+ switch (baseItem.id) {
+ case 'expandAll':
+ this.panel.expandAll();
+ break;
+ default:
+ var indexes = new Hash();
+ function walk(node) {
+ if (!node.attributes.fileIndex) return;
+ indexes[node.attributes.fileIndex] =
node.attributes.priority;
+ }
+ this.panel.getRootNode().cascade(walk);
+
+ var node =
this.panel.getSelectionModel().getSelectedNode();
+ indexes[node.attributes.fileIndex] =
baseItem.filePriority;
+
+ priorities = new Array(indexes.getLength());
+ indexes.each(function(priority, index) {
+ priorities[index] = priority;
+ });
+
+
Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
+ onSuccess: function() {
+ this.update(this.torrentId);
+ }
+ });
+ break;
+ }
+ },
+
onRequestComplete: function(files, torrentId) {
- if (this.torrentId != torrentId) {
+ if (this.torrentId != torrentId) {
this.clear();
this.torrentId = torrentId;
}
@@ -236,18 +267,19 @@
id: file,
filename: file,
text: file, // this
needs to be here for sorting
- size: item[0],
- progress: item[1],
- priority: item[2],
+ fileIndex: item[0],
+ size: item[1],
+ progress: item[2],
+ priority: item[3],
leaf: true,
iconCls:
'x-deluge-file',
uiProvider:
Ext.tree.ColumnNodeUI
});
parent.appendChild(child);
}
- child.setColumnValue(1, item[0]);
- child.setColumnValue(2, item[1]);
- child.setColumnValue(3, item[2]);
+ child.setColumnValue(1, item[1]);
+ child.setColumnValue(2, item[2]);
+ child.setColumnValue(3, item[3]);
}
});
}
Modified: trunk/deluge/ui/web/js/deluge-menus.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-menus.js 2009-04-01 20:03:21 UTC (rev
4969)
+++ trunk/deluge/ui/web/js/deluge-menus.js 2009-04-01 21:31:36 UTC (rev
4970)
@@ -383,19 +383,23 @@
}, '-', {
id: 'no_download',
text: _('Do Not Download'),
- icon: '/icons/no_download.png'
+ icon: '/icons/no_download.png',
+ filePriority: 0
}, {
id: 'normal',
text: _('Normal Priority'),
- icon: '/icons/normal.png'
+ icon: '/icons/normal.png',
+ filePriority: 1
}, {
id: 'high',
text: _('High Priority'),
- icon: '/icons/high.png'
+ icon: '/icons/high.png',
+ filePriority: 2
}, {
id: 'highest',
text: _('Highest Priority'),
- icon: '/icons/highest.png'
+ icon: '/icons/highest.png',
+ filePriority: 5
}]
});
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-04-01 20:03:21 UTC (rev 4969)
+++ trunk/deluge/ui/web/json_api.py 2009-04-01 21:31:36 UTC (rev 4970)
@@ -341,13 +341,14 @@
paths.append(path)
torrent_file["progress"] = file_progress[index]
torrent_file["priority"] = file_priorities[index]
+ torrent_file["index"] = index
info[path] = torrent_file
def walk(path, item):
if type(item) is dict:
return item
- return [info[path]["size"], info[path]["progress"],
- info[path]["priority"]]
+ return [info[path]["index"], info[path]["size"],
+ info[path]["progress"], info[path]["priority"]]
file_tree = uicommon.FileTree(paths)
file_tree.walk(walk)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---