Module: deluge
Branch: master
Commit: c970a80030e31cf456e027e48a6b7a86363cee81

Author: Damien Churchill <[email protected]>
Date:   Fri Apr  2 15:44:26 2010 +0100

finish converting the AddWindow over to a ListView

---

 deluge/ui/web/js/deluge-all/add/AddWindow.js |   34 +++++++++++++++----------
 deluge/ui/web/js/deluge-all/add/UrlWindow.js |    2 +-
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/deluge/ui/web/js/deluge-all/add/AddWindow.js 
b/deluge/ui/web/js/deluge-all/add/AddWindow.js
index 36940d8..07443e1 100644
--- a/deluge/ui/web/js/deluge-all/add/AddWindow.js
+++ b/deluge/ui/web/js/deluge-all/add/AddWindow.js
@@ -59,9 +59,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
                        }
                }
 
-               this.list = this.add({
-                       xtype: 'listview',
-                       region: 'center',
+               this.list = new Ext.list.ListView({
                        store: new Ext.data.SimpleStore({
                                fields: [
                                        {name: 'info_hash', mapping: 1},
@@ -79,15 +77,19 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
                        stripeRows: true,
                        singleSelect: true,
                        listeners: {
-                               'selectionchanged': {
+                               'selectionchange': {
                                        fn: this.onSelect,
                                        scope: this
                                }
                        },
                        hideHeaders: true,
                        autoExpandColumn: 'torrent',
-                       deferredRender: false,
-                       autoScroll: true,
+                       autoScroll: true
+               });
+
+               this.add({
+                       region: 'center',
+                       items: [this.list],
                        margins: '5 5 5 5',
                        bbar: new Ext.Toolbar({
                                items: [{
@@ -125,7 +127,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
 
        onAddClick: function() {
                var torrents = [];
-               if (!this.grid) return;
+               if (!this.list) return;
                this.list.getStore().each(function(r) {
                        var id = r.get('info_hash');
                        torrents.push({
@@ -159,9 +161,8 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
        },
 
        onRemove: function() {
-               var selection = this.grid.getSelectionModel();
-               if (!selection.hasSelection()) return;
-               var torrent = selection.getSelected();
+               if (!this.list.getSelectionCount()) return;
+               var torrent = this.list.getSelectedRecords()[0];
                this.list.getStore().remove(torrent);
                this.optionsPanel.clear();
                
@@ -169,10 +170,15 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
        },
 
        onSelect: function(list, selections) {
-               
-               this.optionsPanel.setTorrent(record.get('info_hash'));
-               this.optionsPanel.files.setDisabled(false);
-               this.optionsPanel.form.setDisabled(false);
+               if (selections.length) {        
+                       var record = this.list.getRecord(selections[0]);
+                       this.optionsPanel.setTorrent(record.get('info_hash'));
+                       this.optionsPanel.files.setDisabled(false);
+                       this.optionsPanel.form.setDisabled(false);
+               } else {
+                       this.optionsPanel.files.setDisabled(true);
+                       this.optionsPanel.form.setDisabled(true);
+               }
        },
 
        onShow: function() {
diff --git a/deluge/ui/web/js/deluge-all/add/UrlWindow.js 
b/deluge/ui/web/js/deluge-all/add/UrlWindow.js
index 717cac9..963be02 100644
--- a/deluge/ui/web/js/deluge-all/add/UrlWindow.js
+++ b/deluge/ui/web/js/deluge-all/add/UrlWindow.js
@@ -1,5 +1,5 @@
 /*!
- * Deluge.add.Url.js
+ * Deluge.add.UrlWindow.js
  * 
  * Copyright (c) Damien Churchill 2009-2010 <[email protected]>
  *

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