implement 'new' handling and visuals in list view.

This commit is contained in:
alta88 2009-07-02 14:58:59 -06:00
Родитель 70d7247c92
Коммит 90323ec456
5 изменённых файлов: 84 добавлений и 15 удалений

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

@ -340,6 +340,10 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
}
}
if (!modKey && this.itemIds != -1)
// Unset new status for (about to be) formerly selected collection(s).
this.markCollectionNewState();
// Get constraints based on selected rows
let constraints = this.getSelectionConstraints();
@ -416,11 +420,11 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
aEvent.target.checked = !aEvent.target.checked;
this.Filters["unread"] = aEvent.target.checked ? true : false;
if (this.itemIds == -1)
// If no selection.
return;
gMessageViewWindow.SnowlMessageView.onFilter(this.Filters);
if (this.itemIds == -1 && !this.Filters["unread"] && !this.Filters["deleted"])
// If no selection and unchecking, clear list (don't select 'All').
gMessageViewWindow.SnowlMessageView.onCollectionsDeselect();
else
gMessageViewWindow.SnowlMessageView.onFilter(this.Filters);
},
onCommandShowDeletedButton: function(aEvent) {
@ -432,11 +436,11 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
else
document.getElementById("snowlPurgeDeletedButton").setAttribute("disabled", true);
if (this.itemIds == -1)
// If no selection.
return;
gMessageViewWindow.SnowlMessageView.onFilter(this.Filters);
if (this.itemIds == -1 && !this.Filters["deleted"] && !this.Filters["unread"])
// If no selection and unchecking, clear list (don't select 'All').
gMessageViewWindow.SnowlMessageView.onCollectionsDeselect();
else
gMessageViewWindow.SnowlMessageView.onFilter(this.Filters);
},
onCommandPurgeDeletedButton: function(aEvent) {
@ -589,6 +593,60 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
}
},
markCollectionNewState: function() {
// Mark all selected source/author collection messages as not new (unread)
// upon the collection being no longer selected. Note: shift-click on a
// collection will leave new state when unselected.
let itemId, uri, sources = [], authors = [], query, all = false;
let itemIds = this.itemIds;
let currentIndexItemId =
this._tree.view.nodeForTreeIndex(this._tree.currentIndex).itemId
for each (itemId in itemIds) {
// If selecting item currently in selection, leave as new.
if (itemId == currentIndexItemId)
continue;
// Create places query object from places item uri.
uri = PlacesUtils.bookmarks.getBookmarkURI(itemId).spec;
query = new SnowlQuery(uri);
if (query.queryFolder == SnowlPlaces.collectionsSystemID ||
query.queryFolder == SnowlPlaces.collectionsSourcesID ||
query.queryFolder == SnowlPlaces.collectionsAuthorsID) {
all = true;
break;
}
if (query.queryTypeSource && sources.indexOf(query.queryID, 0) < 0)
sources.push(query.queryID);
if (query.queryTypeAuthor && authors.indexOf(query.queryID, 0) < 0)
authors.push(query.queryID);
}
query = "";
if (!all) {
if (sources.length > 0)
query += "sourceID = " + sources.join(" OR sourceID = ");
if (authors.length > 0) {
if (sources.length > 0)
query += " OR ";
query += "authorID = " + authors.join(" OR authorID = ");
}
query = query ? "( " + query + " ) AND " : null;
}
if (query != null) {
SnowlDatastore.dbConnection.executeSimpleSQL(
"UPDATE messages SET read = " + MESSAGE_UNREAD +
" WHERE " + query + "read = " + MESSAGE_NEW);
// Clear the collections stats cache and invalidate tree to rebuild.
SnowlService._collectionStatsByCollectionID = null;
this._tree.treeBoxObject.invalidate();
}
},
removeSource: function() {
//this._log.info("removeSource: START curIndex:curSelectedIndex = "+
// this._tree.currentIndex+" : "+this._tree.currentSelectedIndex);

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

@ -38,6 +38,10 @@
font-weight: bold !important
}
#snowlView > treechildren::-moz-tree-image(new) {
list-style-image: url("chrome://snowl/content/icons/asterisk_orange.png");
}
#snowlView > treechildren::-moz-tree-cell-text(deleted) {
text-decoration: line-through;
}

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

@ -154,9 +154,14 @@ let SnowlMessageView = {
// because the text styling we apply to unread/deleted messages has to be
// specified by the ::-moz-tree-cell-text pseudo-element, which inherits
// only the cell's properties.
if (!this._collection.messages[aRow].read)
if (this._collection.messages[aRow].read == MESSAGE_UNREAD ||
this._collection.messages[aRow].read == MESSAGE_NEW)
aProperties.AppendElement(this._atomSvc.getAtom("unread"));
if (aColumn.id == "snowlSubjectCol" &&
this._collection.messages[aRow].read == MESSAGE_NEW)
aProperties.AppendElement(this._atomSvc.getAtom("new"));
if (this._collection.messages[aRow].current == MESSAGE_NON_CURRENT_DELETED ||
this._collection.messages[aRow].current == MESSAGE_CURRENT_DELETED)
aProperties.AppendElement(this._atomSvc.getAtom("deleted"));
@ -245,7 +250,9 @@ let SnowlMessageView = {
//this._log.info("_applyFilters: Filters - "+this.Filters.toSource());
if (this.Filters["unread"])
filters.push({ expression: "read = 0", parameters: {} });
filters.push({ expression: "(read = " + MESSAGE_UNREAD + " OR" +
" read = " + MESSAGE_NEW + ")",
parameters: {} });
if (this.Filters["deleted"])
filters.push({ expression: "(current = " + MESSAGE_NON_CURRENT_DELETED + " OR" +

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

@ -286,7 +286,7 @@ this._log.info("got " + groups.length + " groups");
received: SnowlDateUtils.julianToJSDate(statement.row.received),
link: statement.row.link ? URI.get(statement.row.link) : null,
current: statement.row.current,
read: statement.row.read ? true : false,
read: statement.row.read, // ? true : false,
content: content
});

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

@ -84,7 +84,7 @@ SnowlMessage.retrieve = function(id) {
received: SnowlDateUtils.julianToJSDate(statement.row.received),
link: statement.row.link ? URI.get(statement.row.link) : null,
current: statement.row.current,
read: statement.row.read ? true : false
read: statement.row.read // ? true : false
});
if (statement.row.authorID) {
@ -192,7 +192,7 @@ SnowlMessage.prototype = {
link: null,
timestamp: null,
received: null,
read: false,
read: MESSAGE_NEW,
current: null,
summary: null,
content: null,