Mercurial > snowl
annotate content/collections.js @ 358:c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Tue, 04 Nov 2008 12:11:07 -0800 |
parents | e9d7087abad1 |
children |
rev | line source |
---|---|
229
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
1 /* ***** BEGIN LICENSE BLOCK ***** |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
3 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
4 * The contents of this file are subject to the Mozilla Public License Version |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
5 * 1.1 (the "License"); you may not use this file except in compliance with |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
6 * the License. You may obtain a copy of the License at |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
7 * http://www.mozilla.org/MPL/ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
8 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
9 * Software distributed under the License is distributed on an "AS IS" basis, |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
11 * for the specific language governing rights and limitations under the |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
12 * License. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
13 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
14 * The Original Code is Snowl. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
15 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
16 * The Initial Developer of the Original Code is Mozilla. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
17 * Portions created by the Initial Developer are Copyright (C) 2008 |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
18 * the Initial Developer. All Rights Reserved. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
19 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
20 * Contributor(s): |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
21 * Myk Melez <myk@mozilla.org> |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
22 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
23 * Alternatively, the contents of this file may be used under the terms of |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
24 * either the GNU General Public License Version 2 or later (the "GPL"), or |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
26 * in which case the provisions of the GPL or the LGPL are applicable instead |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
27 * of those above. If you wish to allow use of your version of this file only |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
28 * under the terms of either the GPL or the LGPL, and not to allow others to |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
29 * use your version of this file under the terms of the MPL, indicate your |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
30 * decision by deleting the provisions above and replace them with the notice |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
31 * and other provisions required by the GPL or the LGPL. If you do not delete |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
32 * the provisions above, a recipient may use your version of this file under |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
33 * the terms of any one of the MPL, the GPL or the LGPL. |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
34 * |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
35 * ***** END LICENSE BLOCK ***** */ |
b324ba5e93f0
add license header blocks to all CSS & JS files
Myk Melez <myk@mozilla.org>
parents:
225
diff
changeset
|
36 |
358
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
37 // modules that come with Firefox |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
38 |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
39 // modules that are generic |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
40 Cu.import("resource://snowl/modules/log4moz.js"); |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
41 Cu.import("resource://snowl/modules/Observers.js"); |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
42 Cu.import("resource://snowl/modules/URI.js"); |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
43 |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
44 // modules that are Snowl-specific |
45
a3811857c5dc
register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents:
39
diff
changeset
|
45 Cu.import("resource://snowl/modules/service.js"); |
a3811857c5dc
register the resource alias to the top-level directory rather than the modules directory for consistency with resource://gre/modules/ URLs and so we can use it to load resources from elsewhere in the extension later; this means converting chrome://snowl/module.js URLs into chrome://snowl/modules/module.js URLs
Myk Melez <myk@mozilla.org>
parents:
39
diff
changeset
|
46 Cu.import("resource://snowl/modules/datastore.js"); |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
47 Cu.import("resource://snowl/modules/source.js"); |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
48 Cu.import("resource://snowl/modules/feed.js"); |
165 | 49 Cu.import("resource://snowl/modules/identity.js"); |
169
d5cc6dfafc40
basic support for grouping in the collection object
Myk Melez <myk@mozilla.org>
parents:
167
diff
changeset
|
50 Cu.import("resource://snowl/modules/collection.js"); |
275
5982695f4890
factor out OPML export code from the collections view
Myk Melez <myk@mozilla.org>
parents:
238
diff
changeset
|
51 Cu.import("resource://snowl/modules/opml.js"); |
16
8efec269810d
get rid of init.js and a bunch of unused code in snowl.js
Myk Melez <myk@mozilla.org>
parents:
12
diff
changeset
|
52 |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
53 let gBrowserWindow = window.QueryInterface(Ci.nsIInterfaceRequestor). |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
54 getInterface(Ci.nsIWebNavigation). |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
55 QueryInterface(Ci.nsIDocShellTreeItem). |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
56 rootTreeItem. |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
57 QueryInterface(Ci.nsIInterfaceRequestor). |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
58 getInterface(Ci.nsIDOMWindow); |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
59 |
317
27a89f014e81
rename SourcesView to CollectionsView
Myk Melez <myk@mozilla.org>
parents:
316
diff
changeset
|
60 let CollectionsView = { |
21 | 61 _log: null, |
62 | |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
63 get _tree() { |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
64 delete this._tree; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
65 return this._tree = document.getElementById("sourcesView"); |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
66 }, |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
67 |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
68 get _children() { |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
69 delete this._children; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
70 return this._children = this._tree.getElementsByTagName("treechildren")[0]; |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
71 }, |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
72 |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
73 isHierarchical: gBrowserWindow.Snowl._prefs.get("collection.hierarchicalView"), |
106
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
74 |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
75 //**************************************************************************// |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
76 // Initialization & Destruction |
2a08b4a82802
integrate OPML import into the sidebar
Myk Melez <myk@mozilla.org>
parents:
105
diff
changeset
|
77 |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
78 init: function() { |
21 | 79 this._log = Log4Moz.Service.getLogger("Snowl.Sidebar"); |
358
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
80 Observers.add(this, "snowl:sources:changed"); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
81 this._getCollections(); |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
82 this._buildCollectionTree(); |
21 | 83 |
344
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
84 // Ensure collection selection maintained, if in List sidebar |
62557df25569
make the River menuitem toggle the river view open and closed; fix the Wide Message layout problem (chrome gets messed up in Wide Message mode, particularly when using extensions like Sidebar Tabs)
alta88 <alta88@gmail.com>
parents:
317
diff
changeset
|
85 if (document.getElementById("snowlSidebar")) |
355
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
86 this._tree.view.selection.select(SnowlUtils.gListViewCollectionIndex); |
21 | 87 }, |
88 | |
89 | |
90 //**************************************************************************// | |
91 // nsITreeView | |
92 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
93 selection: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
94 |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
95 get rowCount() { |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
96 return this._rows.length; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
97 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
98 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
99 // FIXME: consolidate these two references. |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
100 _treebox: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
101 setTree: function(treeBox) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
102 this._treeBox = treeBox; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
103 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
104 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
105 getCellText : function(row, column) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
106 return this._rows[row].name; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
107 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
108 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
109 isContainer: function(row) { |
177 | 110 //this._log.info("isContainer: " + (this._rows[row].groups ? true : false)); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
111 return (this._rows[row].groups ? true : false); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
112 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
113 isContainerOpen: function(row) { |
177 | 114 //this._log.info("isContainerOpen: " + this._rows[row].isOpen); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
115 return this._rows[row].isOpen; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
116 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
117 isContainerEmpty: function(row) { |
177 | 118 //this._log.info("isContainerEmpty: " + row + " " + this._rows[row].groups.length + " " + (this._rows[row].groups.length == 0)); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
119 return (this._rows[row].groups.length == 0); |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
120 }, |
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
121 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
122 isSeparator: function(row) { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
123 isSorted: function() { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
124 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
125 // FIXME: make this return true for collection names that are editable, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
126 // and then implement name editing on the new architecture. |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
127 isEditable: function(row, column) { return false }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
128 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
129 getParentIndex: function(row) { |
177 | 130 //this._log.info("getParentIndex: " + row); |
131 | |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
132 let thisLevel = this.getLevel(row); |
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
133 |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
134 if (thisLevel == 0) |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
135 return -1; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
136 for (let t = row - 1; t >= 0; t--) |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
137 if (this.getLevel(t) < thisLevel) |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
138 return t; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
139 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
140 throw "getParentIndex: couldn't figure out parent index for row " + row; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
141 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
142 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
143 getLevel: function(row) { |
177 | 144 //this._log.info("getLevel: " + row); |
145 | |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
146 if (!this.isHierarchical) |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
147 return 0; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
148 |
179
ab9b528514e6
don't indent the All collection, and support more flexible hierarchy
Myk Melez <myk@mozilla.org>
parents:
178
diff
changeset
|
149 return this._rows[row].level; |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
150 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
151 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
152 hasNextSibling: function(idx, after) { |
177 | 153 //this._log.info("hasNextSibling: " + idx + " " + after); |
154 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
155 let thisLevel = this.getLevel(idx); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
156 for (let t = idx + 1; t < this._rows.length; t++) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
157 let nextLevel = this.getLevel(t); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
158 if (nextLevel == thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
159 return true; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
160 if (nextLevel < thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
161 return false; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
162 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
163 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
164 return false; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
165 }, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
166 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
167 getImageSrc: function(row, column) { |
177 | 168 if (column.id == "nameCol") { |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
169 let iconURL = this._rows[row].iconURL; |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
170 if (iconURL) |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
171 return iconURL.spec; |
177 | 172 } |
173 | |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
174 return null; |
21 | 175 }, |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
176 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
177 toggleOpenState: function(idx) { |
177 | 178 //this._log.info("toggleOpenState: " + idx); |
179 | |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
180 let item = this._rows[idx]; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
181 if (!item.groups) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
182 return; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
183 |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
184 if (item.isOpen) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
185 item.isOpen = false; |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
186 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
187 let thisLevel = this.getLevel(idx); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
188 let numToDelete = 0; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
189 for (let t = idx + 1; t < this._rows.length; t++) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
190 if (this.getLevel(t) > thisLevel) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
191 numToDelete++; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
192 else |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
193 break; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
194 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
195 if (numToDelete) { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
196 this._rows.splice(idx + 1, numToDelete); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
197 this._treeBox.rowCountChanged(idx + 1, -numToDelete); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
198 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
199 } |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
200 else { |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
201 item.isOpen = true; |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
202 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
203 let groups = this._rows[idx].groups; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
204 for (let i = 0; i < groups.length; i++) |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
205 this._rows.splice(idx + 1 + i, 0, groups[i]); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
206 this._treeBox.rowCountChanged(idx + 1, groups.length); |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
207 } |
108
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
208 }, |
ec5e374be495
show favicons in the subscriptions sidebar
Myk Melez <myk@mozilla.org>
parents:
106
diff
changeset
|
209 |
195 | 210 getRowProperties: function (row, properties) {}, |
211 getCellProperties: function (row, column, properties) {}, | |
212 getColumnProperties: function(columnID, column, properties) {}, | |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
213 |
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
214 setCellText: function(aRow, aCol, aValue) { |
75
877a7694445f
update the sources table schema, changing the title column to name and differentiating between machine-processable and human-readable URIs
Myk Melez <myk@mozilla.org>
parents:
45
diff
changeset
|
215 let statement = SnowlDatastore.createStatement("UPDATE sources SET name = :name WHERE id = :id"); |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
216 statement.params.name = this._rows[aRow].name = aValue; |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
217 statement.params.id = this._rows[aRow].id; |
21 | 218 |
219 try { | |
220 statement.execute(); | |
221 } | |
222 finally { | |
223 statement.reset(); | |
224 } | |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
225 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
226 |
28
0d34d2108b49
use a custom view for the message pane
Myk Melez <myk@mozilla.org>
parents:
21
diff
changeset
|
227 |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
228 //**************************************************************************// |
358
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
229 // Misc XPCOM Interfaces |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
230 |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
231 // nsIObserver |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
232 observe: function(subject, topic, data) { |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
233 switch (topic) { |
358
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
234 case "snowl:sources:changed": |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
235 this._getCollections(); |
105
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
236 // Rebuild the view to reflect the new collection of messages. |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
237 // Since the number of rows might have changed, we do this by reinitializing |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
238 // the view instead of merely invalidating the box object (which doesn't |
cd3267665afd
reinit the sidebar view when the number of rows changes
Myk Melez <myk@mozilla.org>
parents:
75
diff
changeset
|
239 // expect changes to the number of rows). |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
240 this._buildCollectionTree(); |
10
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
241 break; |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
242 } |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
243 }, |
64defcf896f1
update the list of sources when the user subscribes to one
Myk Melez <myk@mozilla.org>
parents:
9
diff
changeset
|
244 |
172
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
245 _collections: null, |
3ec4ba145105
support for a hierarchical tree view
Myk Melez <myk@mozilla.org>
parents:
171
diff
changeset
|
246 _getCollections: function() { |
178
1a27019af73e
reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents:
177
diff
changeset
|
247 this._collections = []; |
1a27019af73e
reimplement the 'All' collection on the new architecture
Myk Melez <myk@mozilla.org>
parents:
177
diff
changeset
|
248 |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
249 let statement = SnowlDatastore.createStatement( |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
250 "SELECT id, name, iconURL, grouped, groupIDColumn, groupNameColumn, " + |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
251 "groupHomeURLColumn, groupIconURLColumn FROM collections ORDER BY orderKey" |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
252 ); |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
253 |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
254 statement.QueryInterface(Ci.mozIStorageStatementWrapper); |
165 | 255 |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
256 try { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
257 while (statement.step()) { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
258 this._collections.push(new SnowlCollection(statement.row.id, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
259 statement.row.name, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
260 URI.get(statement.row.iconURL), |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
261 null, |
212
cf89d5c676c0
persist collection and group in the URL, and delay loading content until the collections sidebar has loaded
Myk Melez <myk@mozilla.org>
parents:
211
diff
changeset
|
262 null, |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
263 statement.row.grouped ? true : false, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
264 statement.row.groupIDColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
265 statement.row.groupNameColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
266 statement.row.groupHomeURLColumn, |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
267 statement.row.groupIconURLColumn)); |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
268 } |
175
5409a8759186
collection object rearch: encapsulate grouping info into grouping object
Myk Melez <myk@mozilla.org>
parents:
174
diff
changeset
|
269 } |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
270 finally { |
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
271 statement.reset(); |
180 | 272 } |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
273 }, |
180 | 274 |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
275 // Build the list of rows in the tree. By default, all containers |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
276 // are closed, so this is the same as the list of collections, although |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
277 // in the future we might persist and restore the open state. |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
278 _buildCollectionTree: function() { |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
279 if (this.isHierarchical) { |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
280 this._rows = [collection for each (collection in this._collections)]; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
281 } |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
282 else { |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
283 this._rows = []; |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
284 for each (let collection in this._collections) { |
211
9c5fdc76cb35
store the list of collections in the database
Myk Melez <myk@mozilla.org>
parents:
202
diff
changeset
|
285 if (collection.grouped) |
194
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
286 for each (let group in collection.groups) |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
287 this._rows.push(group); |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
288 else |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
289 this._rows.push(collection); |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
290 } |
bdb8643cbeab
flatten the list of collections
Myk Melez <myk@mozilla.org>
parents:
187
diff
changeset
|
291 } |
349
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
292 |
f95f6f24516f
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
alta88
parents:
344
diff
changeset
|
293 this._tree.view = this; |
21 | 294 }, |
295 | |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
296 onSelect: function(aEvent) { |
355
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
297 if (this._tree.currentIndex == -1 || SnowlUtils.gRightMouseButtonDown) |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
298 return; |
173
4d59aa183d57
get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents:
172
diff
changeset
|
299 |
4d59aa183d57
get loading of a group into the list view working
Myk Melez <myk@mozilla.org>
parents:
172
diff
changeset
|
300 let collection = this._rows[this._tree.currentIndex]; |
355
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
301 SnowlUtils.gListViewCollectionIndex = this._tree.currentIndex; |
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
302 gMessageViewWindow.SnowlMessageView.setCollection(collection); |
9
d8abd85fc94d
implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents:
8
diff
changeset
|
303 }, |
d8abd85fc94d
implement basic subscribe and unsubscribe
Myk Melez <myk@mozilla.org>
parents:
8
diff
changeset
|
304 |
355
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
305 onCollectionsTreeMouseDown: function(aEvent) { |
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
306 SnowlUtils.onTreeMouseDown(aEvent, this._tree); |
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
307 }, |
21 | 308 |
355
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
309 onTreeContextPopupHidden: function() { |
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
310 if (!SnowlUtils.gSelectOnRtClick) |
e9d7087abad1
implement tree (list and collection) contextmenu foundation, change XXX Utils to DateUtils, some click handling fixes.
alta88
parents:
349
diff
changeset
|
311 SnowlUtils.RestoreSelectionWithoutContentLoad(this._tree); |
297 | 312 }, |
313 | |
314 unsubscribe: function() { | |
315 let collection = this._rows[this._tree.currentIndex]; | |
316 | |
317 if (!collection.parent || collection.parent.groupIDColumn != "sources.id") | |
318 return; | |
319 | |
320 let sourceID = this._rows[this._tree.currentIndex].groupID; | |
321 | |
322 SnowlDatastore.dbConnection.beginTransaction(); | |
323 try { | |
324 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM metadata WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")"); | |
325 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM parts WHERE messageID IN (SELECT id FROM messages WHERE sourceID = " + sourceID + ")"); | |
326 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM messages WHERE sourceID = " + sourceID); | |
327 SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM sources WHERE id = " + sourceID); | |
328 SnowlDatastore.dbConnection.commitTransaction(); | |
329 } | |
330 catch(ex) { | |
331 SnowlDatastore.dbConnection.rollbackTransaction(); | |
332 throw ex; | |
333 } | |
334 | |
358
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
335 Observers.notify(null, "snowl:sources:changed", null); |
c00b3db58dcf
add 'snowl' to all observer topics to avoid conflicts with other extensions/core code; use the Observers component everywhere
Myk Melez <myk@mozilla.org>
parents:
355
diff
changeset
|
336 Observers.notify(null, "snowl:messages:changed", null); |
8
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
337 } |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
338 |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
339 }; |
87c6af76db52
add a sidebar listing subscriptions with basic support for selecting a subscription and seeing just its messages
Myk Melez <myk@mozilla.org>
parents:
diff
changeset
|
340 |
317
27a89f014e81
rename SourcesView to CollectionsView
Myk Melez <myk@mozilla.org>
parents:
316
diff
changeset
|
341 window.addEventListener("load", function() { CollectionsView.init() }, true); |