This commit is contained in:
alta88 2009-04-05 17:38:55 -06:00
Родитель 59d9e05cd4
Коммит 3b1bf808c8
7 изменённых файлов: 92 добавлений и 49 удалений

Просмотреть файл

@ -82,6 +82,16 @@ let CollectionsView = {
return this._collectionsViewMenuPopup = document.getElementById("collectionsViewMenuPopup");
},
get _listToolbar() {
delete this._listToolbar;
return this._listToolbar = document.getElementById("snowlListToolbar");
},
get _toggleListToolbarButton() {
delete this._toggleListToolbarButton;
return this._toggleListToolbarButton = document.getElementById("listToolbarButton");
},
get itemIds() {
let intArray = [];
let strArray = this._tree.getAttribute("itemids").split(",");
@ -99,6 +109,11 @@ let CollectionsView = {
gListOrRiver: null,
Filters: {
unread: false,
searchterms: null
},
//**************************************************************************//
// Initialization & Destruction
@ -109,6 +124,12 @@ let CollectionsView = {
this._log = Log4Moz.repository.getLogger("Snowl.Sidebar");
this.gListOrRiver = "list";
if (!this._listToolbar.hasAttribute("hidden"))
this._toggleListToolbarButton.setAttribute("checked", true);
this.Filters["unread"] = document.getElementById("snowlUnreadButton").
checked ? true : false;
// Restore persisted view selection (need to build the menulist) or init.
let selIndex = parseInt(this._collectionsViewMenu.getAttribute("selectedindex"));
if (selIndex >= 0) {
@ -145,9 +166,7 @@ let CollectionsView = {
let titleMsg = strings.get("rebuildPlacesTitleMsg");
let dialogMsg = strings.get("rebuildPlacesDialogMsg");
let promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
promptService.alert(window, titleMsg, dialogMsg);
SnowlService._promptSvc.alert(window, titleMsg, dialogMsg);
this.itemIds = -1;
this._collectionsViewMenu.setAttribute("selectedindex", 0); // "default"
@ -345,7 +364,7 @@ this._log.info("onClick: twisty CLEARED"); // clearSelection()
null,
constraints,
null);
gMessageViewWindow.SnowlMessageView.setCollection(collection);
gMessageViewWindow.SnowlMessageView.setCollection(collection, this.Filters);
},
onCollectionsTreeMouseDown: function(aEvent) {
@ -364,11 +383,24 @@ this._log.info("onClick: twisty CLEARED"); // clearSelection()
SnowlService.refreshAllSources();
},
onCommandUnreadButton: function(aEvent) {
onToggleListToolbar: function() {
if (this._listToolbar.hasAttribute("hidden"))
this._listToolbar.removeAttribute("hidden");
else
this._listToolbar.setAttribute("hidden", true);
},
onSearch: function(aValue) {
this.Filters["searchterms"] = aValue ? aValue : null;
gMessageViewWindow.SnowlMessageView._applyFilters(this.Filters);
},
onCommandUnreadButton: function(aChecked) {
// XXX Instead of rebuilding from scratch each time, when going from
// all to unread, simply hide the ones that are read (f.e. by setting a CSS
// class on read items and then using a CSS rule to hide them)?
gMessageViewWindow.SnowlMessageView._applyFilters();
this.Filters["unread"] = aChecked ? true : false;
gMessageViewWindow.SnowlMessageView._applyFilters(this.Filters);
},
_resetCollectionsView: true,

Просмотреть файл

@ -71,8 +71,21 @@
<commandset id="placesCommands"/>
<commandset id="editMenuCommands"/>
<popup id="placesContext"/>
<toolbar id="snowlToolbar" persist="hidden">
<toolbar id="snowlListToolbar" persist="hidden">
<toolbaritem id="searchBox"
flex="1"
align="center">
<label value="&search.label;"
accesskey="&search.accesskey;"
control="snowlFilter"/>
<!-- type="timed" timeout="200" -->
<textbox id="snowlFilter"
flex="1"
type="search"
emptytext="&listSearch.emptytext;"
oncommand="CollectionsView.onSearch(this.value)"/>
</toolbaritem>
<toolbarspring/>
<toolbaritem id="viewBox"
align="center">
<label value="&view.label;"
@ -95,7 +108,14 @@
</menupopup>
</menulist>
</toolbaritem>
<toolbarspring/>
</toolbar>
<!-- This is the overlay point for the collections view overlay. -->
<vbox id="collectionsViewBox"/>
<vbox id="writeForm" hidden="true"/>
<toolbar id="snowlToolbar" persist="hidden">
<toolbarbutton id="snowlSubscribeButton"
class="tabbable"
oncommand="CollectionsView.onSubscribe()"
@ -104,21 +124,24 @@
class="tabbable"
oncommand="CollectionsView.onRefresh()"
tooltiptext="&refreshButton.tooltip;"/>
<toolbarbutton id="listToolbarButton"
class="tabbable"
type="checkbox"
persist="checked"
oncommand="CollectionsView.onToggleListToolbar()"
tooltiptext="&listToolbarButton.tooltip;"/>
<toolbarspring/>
<toolbarbutton id="snowlUnreadButton"
class="tabbable"
type="checkbox"
persist="checked"
oncommand="CollectionsView.onCommandUnreadButton(event)"
oncommand="CollectionsView.onCommandUnreadButton(this.checked)"
tooltiptext="&unreadButton.tooltip;"/>
<toolbarbutton id="writeButton" type="checkbox"
<toolbarbutton id="writeButton"
class="tabbable"
type="checkbox"
oncommand="ListSidebar.onToggleWrite(event)"
tooltiptext="&writeButton.tooltip;"/>
</toolbar>
<!-- This is the overlay point for the collections view overlay. -->
<vbox id="collectionsViewBox"/>
<vbox id="writeForm" hidden="true"/>
</page>

Просмотреть файл

@ -66,11 +66,6 @@ let SnowlMessageView = {
getService(Ci.nsIAtomService);
},
get _filter() {
delete this._filter;
return this._filter = document.getElementById("searchbar");
},
get _tree() {
delete this._tree;
return this._tree = document.getElementById("snowlView");
@ -91,16 +86,6 @@ let SnowlMessageView = {
return this._snowlSidebar = document.getElementById("snowlSidebar");
},
// The get method doesn't return all attrs/properties on sidebar reloads..
_unreadButton: function() {
return document.getElementById("sidebar").contentDocument.
getElementById("snowlUnreadButton");
},
_sidebarWin: function() {
return document.getElementById("sidebar").contentWindow;
},
// Maps XUL tree column IDs to collection properties.
_columnProperties: {
"snowlSourceCol": "source",
@ -224,39 +209,31 @@ let SnowlMessageView = {
this._rebuildView();
},
onFilter: function() {
this._applyFilters();
onFilter: function(aFilters) {
this._applyFilters(aFilters);
},
_applyFilters: function() {
_applyFilters: function(aFilters) {
let filters = [];
//this._log.info("_applyFilters: START");
//this._log.info("_applyFilters: aFilters - "+[aFilters].toSource());
if (this._unreadButton().checked)
if (aFilters["unread"])
filters.push({ expression: "read = 0", parameters: {} });
// FIXME: use a left join here once the SQLite bug breaking left joins to
// virtual tables has been fixed (i.e. after we upgrade to SQLite 3.5.7+).
if (this._filter.value &&
this._filter.currentEngine.name == this._filter.SNOWL_ENGINE_NAME &&
this._filter.searchView == "list")
if (aFilters["searchterms"])
filters.push({ expression: "messages.id IN (SELECT messageID FROM parts JOIN partsText ON parts.id = partsText.docid WHERE partsText.content MATCH :filter)",
parameters: { filter: SnowlUtils.appendAsterisks(this._filter.value) } });
parameters: { filter: SnowlUtils.appendAsterisks(aFilters["searchterms"]) } });
this._collection.filters = filters;
if (this._sidebarWin().CollectionsView.itemIds == -1)
// No selection, don't show anything
this._collection.clear();
else
this._collection.invalidate();
this._collection.invalidate();
this._rebuildView();
},
setCollection: function(collection) {
setCollection: function(collection, aFilters) {
this._collection = collection;
this._applyFilters();
this._applyFilters(aFilters);
},
_rebuildView: function() {

Просмотреть файл

@ -52,6 +52,12 @@
#snowlRefreshButton {
list-style-image: url("chrome://snowl/content/icons/arrow_refresh_small.png");
}
#listToolbarButton {
list-style-image: url("chrome://global/skin/icons/Search-glass.png");
-moz-image-region: rect(0pt, 16px, 16px, 0pt);
}
#snowlUnreadButton {
list-style-image: url("chrome://snowl/content/icons/new.png");
}

Просмотреть файл

@ -19,3 +19,5 @@
<!ENTITY viewDefault.label "Default">
<!ENTITY viewSources.label "Sources">
<!ENTITY viewAuthors.label "Authors">
<!ENTITY search.label "Search:">
<!ENTITY search.accesskey "S">

Просмотреть файл

@ -7,3 +7,5 @@
<!ENTITY openListMessage.label "Open Message">
<!ENTITY openListMessage.accesskey "O">
<!ENTITY listSearch.emptytext "Search Messages">

Просмотреть файл

@ -3,4 +3,5 @@
<!ENTITY refreshButton.tooltip "Refresh all message sources.">
<!ENTITY exportButton.tooltip "Export message sources as OPML.">
<!ENTITY unreadButton.tooltip "Only show unread messages.">
<!ENTITY listToolbarButton.tooltip "Toggle View toolbar.">
<!ENTITY writeButton.tooltip "Write a message.">