mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Fix for 19618. Add icons to thread column. r=bienvenu.
This commit is contained in:
parent
8426abc173
commit
aa26ea7210
@ -64,7 +64,7 @@ var folderListener = {
|
||||
{
|
||||
if(property.GetUnicode() == "TotalMessages" || property.GetUnicode() == "TotalUnreadMessages")
|
||||
{
|
||||
folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
var folder = item.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(folder)
|
||||
{
|
||||
var folderResource = folder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
@ -176,7 +176,7 @@ function HandleDeleteOrMoveMsgCompleted(folder)
|
||||
|
||||
function IsCurrentLoadedFolder(folder)
|
||||
{
|
||||
msgfolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
var msgfolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if(msgfolder)
|
||||
{
|
||||
var folderResource = msgfolder.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
@ -50,7 +50,7 @@ Rights Reserved.
|
||||
<treeitem uri="..." id="threadTreeTemplateTreeItem">
|
||||
|
||||
<treerow class="tree-thread-row" IsUnread="rdf:http://home.netscape.com/NC-rdf#IsUnread" >
|
||||
<treecell class="treecell-text" value="rdf:http://home.netscape.com/NC-rdf#Thread"/>
|
||||
<treecell class="treecell-image threadcol" value="rdf:http://home.netscape.com/NC-rdf#ThreadState"/>
|
||||
<treecell class="treecell-indent tree-cell-threadpane-icon"
|
||||
indent="true"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#Subject"
|
||||
|
@ -75,6 +75,7 @@ nsIRDFResource* nsMsgMessageDataSource::kNC_IsImapDeleted = nsnull;
|
||||
nsIRDFResource* nsMsgMessageDataSource::kNC_MessageType = nsnull;
|
||||
nsIRDFResource* nsMsgMessageDataSource::kNC_OrderReceived = nsnull;
|
||||
nsIRDFResource* nsMsgMessageDataSource::kNC_OrderReceivedSort = nsnull;
|
||||
nsIRDFResource* nsMsgMessageDataSource::kNC_ThreadState = nsnull;
|
||||
|
||||
|
||||
//commands
|
||||
@ -127,6 +128,7 @@ nsMsgMessageDataSource::nsMsgMessageDataSource()
|
||||
rdf->GetResource(NC_RDF_MESSAGETYPE, &kNC_MessageType);
|
||||
rdf->GetResource(NC_RDF_ORDERRECEIVED, &kNC_OrderReceived);
|
||||
rdf->GetResource(NC_RDF_ORDERRECEIVED_SORT, &kNC_OrderReceivedSort);
|
||||
rdf->GetResource(NC_RDF_THREADSTATE, &kNC_ThreadState);
|
||||
|
||||
rdf->GetResource(NC_RDF_MARKREAD, &kNC_MarkRead);
|
||||
rdf->GetResource(NC_RDF_MARKUNREAD, &kNC_MarkUnread);
|
||||
@ -176,6 +178,7 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
|
||||
NS_RELEASE2(kNC_MessageType, refcnt);
|
||||
NS_RELEASE2(kNC_OrderReceived, refcnt);
|
||||
NS_RELEASE2(kNC_OrderReceivedSort, refcnt);
|
||||
NS_RELEASE2(kNC_ThreadState, refcnt);
|
||||
|
||||
NS_RELEASE2(kNC_MarkRead, refcnt);
|
||||
NS_RELEASE2(kNC_MarkUnread, refcnt);
|
||||
@ -254,6 +257,10 @@ nsresult nsMsgMessageDataSource::CreateLiterals(nsIRDFService *rdf)
|
||||
createNode((const PRUnichar*)NS_LITERAL_STRING("news"), getter_AddRefs(kNewsLiteral), rdf);
|
||||
createNode((const PRUnichar*)NS_LITERAL_STRING("mail"), getter_AddRefs(kMailLiteral), rdf);
|
||||
|
||||
//strings for the thread column.
|
||||
createNode((const PRUnichar*)NS_LITERAL_STRING("noThread"), getter_AddRefs(kNoThreadLiteral), rdf);
|
||||
createNode((const PRUnichar*)NS_LITERAL_STRING("thread"), getter_AddRefs(kThreadLiteral), rdf);
|
||||
createNode((const PRUnichar*)NS_LITERAL_STRING("threadWithUnread"), getter_AddRefs(kThreadWithUnreadLiteral), rdf);
|
||||
//
|
||||
// localized strings - some of the above strings need to be displayed
|
||||
// to the user
|
||||
@ -451,7 +458,7 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetTargets(nsIRDFResource* source,
|
||||
(kNC_Priority == property) || (kNC_Size == property) ||
|
||||
(kNC_IsUnread == property) || (kNC_IsImapDeleted == property) ||
|
||||
(kNC_OrderReceived == property) || (kNC_HasAttachment == property) ||
|
||||
(kNC_MessageType == property))
|
||||
(kNC_MessageType == property) || (kNC_ThreadState == property))
|
||||
{
|
||||
rv = NS_NewSingletonEnumerator(targets, source);
|
||||
}
|
||||
@ -514,7 +521,8 @@ nsMsgMessageDataSource::HasArcOut(nsIRDFResource *source, nsIRDFResource *aArc,
|
||||
if (NS_SUCCEEDED(rv) && showThreads) {
|
||||
*result = (aArc == kNC_Total ||
|
||||
aArc == kNC_Unread ||
|
||||
aArc == kNC_MessageChild);
|
||||
aArc == kNC_MessageChild ||
|
||||
aArc == kNC_ThreadState);
|
||||
}
|
||||
*result = (*result ||
|
||||
aArc == kNC_Subject ||
|
||||
@ -607,6 +615,7 @@ nsMsgMessageDataSource::getMessageArcLabelsOut(PRBool showThreads,
|
||||
(*arcs)->AppendElement(kNC_Total);
|
||||
(*arcs)->AppendElement(kNC_Unread);
|
||||
(*arcs)->AppendElement(kNC_MessageChild);
|
||||
(*arcs)->AppendElement(kNC_ThreadState);
|
||||
}
|
||||
|
||||
(*arcs)->AppendElement(kNC_Subject);
|
||||
@ -785,6 +794,7 @@ nsresult nsMsgMessageDataSource::OnItemAddedOrRemovedFromMessage(nsIMessage *par
|
||||
OnChangeUnreadMessageCount(parentMessage);
|
||||
}
|
||||
OnChangeTotalMessageCount(parentMessage);
|
||||
OnChangeThreadState(parentMessage);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
@ -919,7 +929,10 @@ nsresult nsMsgMessageDataSource::OnChangeStatus(nsIRDFResource *resource, PRUint
|
||||
{
|
||||
nsCOMPtr<nsIMessage> message = do_QueryInterface(resource);
|
||||
if(message)
|
||||
{
|
||||
OnChangeUnreadMessageCount(message);
|
||||
OnChangeThreadState(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1042,6 +1055,41 @@ nsresult nsMsgMessageDataSource::OnChangeTotalMessageCount(nsIMessage *message)
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgMessageDataSource::OnChangeThreadState(nsIMessage *message)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
nsCOMPtr<nsIMsgThread> thread;
|
||||
|
||||
rv = message->GetMsgFolder(getter_AddRefs(folder));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = folder->GetThreadForMessage(message, getter_AddRefs(thread));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> threadStateNode;
|
||||
rv = GetThreadStateNode(thread, getter_AddRefs(threadStateNode));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIMessage> firstMessage;
|
||||
rv = GetThreadsFirstMessage(thread, folder, getter_AddRefs(firstMessage));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> firstMessageResource = do_QueryInterface(firstMessage);
|
||||
if(firstMessageResource)
|
||||
rv = NotifyPropertyChanged(firstMessageResource, kNC_ThreadState, threadStateNode);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgMessageDataSource::createMessageNode(nsIMessage *message,
|
||||
nsIRDFResource *property,
|
||||
@ -1101,6 +1149,8 @@ nsMsgMessageDataSource::createMessageNode(nsIMessage *message,
|
||||
rv = createMessageOrderReceivedNode(message, target);
|
||||
else if ((kNC_OrderReceivedSort == property))
|
||||
rv = createMessageOrderReceivedSortNode(message, target);
|
||||
else if ((kNC_ThreadState == property))
|
||||
rv = createMessageThreadStateNode(message, target);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_RDF_NO_VALUE;
|
||||
@ -1343,6 +1393,74 @@ nsMsgMessageDataSource::createMessageOrderReceivedSortNode(nsIMessage *message,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgMessageDataSource::createMessageThreadStateNode(nsIMessage *message, nsIRDFNode **target)
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
nsCOMPtr<nsIMsgThread> thread;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRBool showThreads;
|
||||
|
||||
GetIsThreaded(&showThreads);
|
||||
|
||||
|
||||
if(showThreads)
|
||||
{
|
||||
rv = GetMessageFolderAndThread(message, getter_AddRefs(folder), getter_AddRefs(thread));
|
||||
if(NS_SUCCEEDED(rv) && thread)
|
||||
{
|
||||
if(IsThreadsFirstMessage(thread, message))
|
||||
{
|
||||
rv = GetThreadStateNode(thread, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*target = kNoThreadLiteral;
|
||||
NS_IF_ADDREF(*target);
|
||||
}
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return NS_RDF_NO_VALUE;
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMsgMessageDataSource::GetThreadStateNode(nsIMsgThread *thread, nsIRDFNode **target)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 numUnread, numChildren;
|
||||
|
||||
*target = kNoThreadLiteral;
|
||||
|
||||
rv = thread->GetNumUnreadChildren(&numUnread);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = thread->GetNumChildren(&numChildren);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
//We need to have more than one child to show thread state.
|
||||
if(numChildren > 1)
|
||||
{
|
||||
//If we have at least one unread and two children then we should show the thread with unread
|
||||
//icon
|
||||
if(numUnread > 0)
|
||||
*target = kThreadWithUnreadLiteral;
|
||||
//otherwise just show the regular thread icon.
|
||||
else
|
||||
*target = kThreadLiteral;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*target);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgMessageDataSource::createMessageFlaggedNode(nsIMessage *message,
|
||||
nsIRDFNode **target, PRBool sort)
|
||||
|
@ -164,6 +164,7 @@ protected:
|
||||
nsresult createMessageMessageTypeNode(nsIMessage *message, nsIRDFNode **target);
|
||||
nsresult createMessageOrderReceivedNode(nsIMessage *message, nsIRDFNode **target);
|
||||
nsresult createMessageOrderReceivedSortNode(nsIMessage *message, nsIRDFNode **target);
|
||||
nsresult createMessageThreadStateNode(nsIMessage *message, nsIRDFNode **target);
|
||||
|
||||
nsresult createMessageUnreadNode(nsIMessage *message, nsIRDFNode **target);
|
||||
nsresult createMessageTotalNode(nsIMessage *message, nsIRDFNode **target);
|
||||
@ -212,9 +213,11 @@ protected:
|
||||
nsresult OnChangeIsImapDeleted(nsIRDFResource *resource, PRUint32 oldFlag, PRUint32 newFlag);
|
||||
nsresult OnChangeUnreadMessageCount(nsIMessage *message);
|
||||
nsresult OnChangeTotalMessageCount(nsIMessage *message);
|
||||
nsresult OnChangeThreadState(nsIMessage *message);
|
||||
|
||||
nsresult GetUnreadChildrenNode(nsIMsgThread *thread, nsIRDFNode **target);
|
||||
nsresult GetTotalChildrenNode(nsIMsgThread *thread, nsIRDFNode **target);
|
||||
nsresult GetThreadStateNode(nsIMsgThread *thread, nsIRDFNode **target);
|
||||
|
||||
virtual void Cleanup();
|
||||
|
||||
@ -244,6 +247,7 @@ protected:
|
||||
static nsIRDFResource* kNC_MessageType;
|
||||
static nsIRDFResource* kNC_OrderReceived;
|
||||
static nsIRDFResource* kNC_OrderReceivedSort;
|
||||
static nsIRDFResource* kNC_ThreadState;
|
||||
|
||||
|
||||
// commands
|
||||
@ -287,6 +291,11 @@ protected:
|
||||
nsCOMPtr<nsIRDFNode> kNewsLiteral;
|
||||
nsCOMPtr<nsIRDFNode> kMailLiteral;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> kNoThreadLiteral;
|
||||
nsCOMPtr<nsIRDFNode> kThreadLiteral;
|
||||
nsCOMPtr<nsIRDFNode> kThreadWithUnreadLiteral;
|
||||
|
||||
|
||||
// message properties
|
||||
static nsIAtom *kStatusAtom;
|
||||
static nsIAtom *kFlaggedAtom;
|
||||
|
@ -54,6 +54,7 @@ typedef struct _nsMsgRDFNotification {
|
||||
#define NC_RDF_ORDERRECEIVED NC_NAMESPACE_URI "OrderReceived"
|
||||
#define NC_RDF_HASATTACHMENT NC_NAMESPACE_URI "HasAttachment"
|
||||
#define NC_RDF_MESSAGETYPE NC_NAMESPACE_URI "MessageType"
|
||||
#define NC_RDF_THREADSTATE NC_NAMESPACE_URI "ThreadState"
|
||||
|
||||
#define NC_RDF_CHILD NC_NAMESPACE_URI "child"
|
||||
#define NC_RDF_MESSAGECHILD NC_NAMESPACE_URI "MessageChild"
|
||||
|
Loading…
Reference in New Issue
Block a user