roll up tags in messages in collapsed threads for thread pane, r=bienvenu, bug 289411
authorRobin Message <+@robinmessage.com>
Fri, 26 Aug 2011 13:31:05 -0700
changeset 9060 e8423ae0f0ac0c3cdbacbd579280f2c969a68621
parent 9059 088aec7c13fb376cbbf77b311fd54db833ebcf40
child 9061 88fc3d12b3b768c1f8c4f6258cfc9626b431eb9a
push id230
push userbugzilla@standard8.plus.com
push dateTue, 08 Nov 2011 22:55:24 +0000
treeherdercomm-beta@63dad5648415 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu, bug
bugs289411
roll up tags in messages in collapsed threads for thread pane, r=bienvenu, bug 289411
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgDBView.h
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -902,16 +902,53 @@ nsresult nsMsgDBView::FetchKeywords(nsIM
         keywords.Append(' ');
       keywords.Append(labelStr);
     }
   }
   keywordString = keywords;
   return NS_OK;
 }
 
+// If the row is a collapsed thread, we roll-up the keywords in all the
+// messages in the thread, otherwise, return just the keywords for the row.
+nsresult nsMsgDBView::FetchRowKeywords(nsMsgViewIndex aRow, nsIMsgDBHdr *aHdr,
+                                       nsACString &keywordString)
+{
+  nsresult rv = FetchKeywords(aHdr,keywordString);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
+  {
+    if ((m_flags[aRow] & MSG_VIEW_FLAG_ISTHREAD)
+        && (m_flags[aRow] & nsMsgMessageFlags::Elided))
+    {
+      nsCOMPtr<nsIMsgThread> thread;
+      rv = GetThreadContainingIndex(aRow, getter_AddRefs(thread));
+      if (NS_SUCCEEDED(rv) && thread)
+      {
+        PRUint32 numChildren;
+        thread->GetNumChildren(&numChildren);
+        nsCOMPtr<nsIMsgDBHdr> msgHdr;
+        nsCString moreKeywords;
+        for (long index = 0; index < numChildren; index++)
+        {
+          thread->GetChildHdrAt(index, getter_AddRefs(msgHdr));
+          rv = FetchKeywords(msgHdr, moreKeywords);
+          NS_ENSURE_SUCCESS(rv,rv);
+
+          if (!keywordString.IsEmpty() && !moreKeywords.IsEmpty())
+            keywordString.Append(' ');
+          keywordString.Append(moreKeywords);
+        }
+      }
+    }
+  }
+  return rv;
+}
+
 nsresult nsMsgDBView::FetchTags(nsIMsgDBHdr *aHdr, nsAString &aTagString)
 {
   nsresult rv = NS_OK;
   if (!mTagService)
   {
     mTagService = do_GetService(NS_MSGTAGSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
   }
@@ -1419,17 +1456,17 @@ NS_IMETHODIMP nsMsgDBView::GetRowPropert
   rv = GetMsgHdrForViewIndex(index, getter_AddRefs(msgHdr));
 
   if (NS_FAILED(rv) || !msgHdr) {
     ClearHdrCache();
     return NS_MSG_INVALID_DBVIEW_INDEX;
   }
 
   nsCString keywordProperty;
-  FetchKeywords(msgHdr, keywordProperty);
+  FetchRowKeywords(index, msgHdr, keywordProperty);
   if (!keywordProperty.IsEmpty())
     AppendKeywordProperties(keywordProperty, properties, PR_FALSE);
 
   // give the custom column handlers a chance to style the row.
   for (int i = 0; i < m_customColumnHandlers.Count(); i++)
     m_customColumnHandlers[i]->GetRowProperties(index, properties);
 
   return NS_OK;
@@ -1504,17 +1541,17 @@ NS_IMETHODIMP nsMsgDBView::GetCellProper
   msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
   if (!junkScoreStr.IsEmpty()) {
     properties->AppendElement(junkScoreStr.ToInteger(&rv) == nsIJunkMailPlugin::IS_SPAM_SCORE ?
                               kJunkMsgAtom : kNotJunkMsgAtom);
     NS_ASSERTION(NS_SUCCEEDED(rv), "Converting junkScore to integer failed.");
   }
 
   nsCString keywords;
-  FetchKeywords(msgHdr, keywords);
+  FetchRowKeywords(aRow, msgHdr, keywords);
   if (!keywords.IsEmpty())
     AppendKeywordProperties(keywords, properties, PR_TRUE);
 
   // this is a double fetch of the keywords property since we also fetch
   // it for the tags - do we want to do this?
   // I'm not sure anyone uses the kw- property, though it could be nice
   // for people wanting to extend the thread pane.
   nsCString keywordProperty;
--- a/mailnews/base/src/nsMsgDBView.h
+++ b/mailnews/base/src/nsMsgDBView.h
@@ -211,16 +211,18 @@ protected:
   nsresult FetchSubject(nsIMsgDBHdr * aMsgHdr, PRUint32 aFlags, nsAString &aValue);
   nsresult FetchDate(nsIMsgDBHdr * aHdr, nsAString & aDateString, PRBool rcvDate = PR_FALSE);
   nsresult FetchStatus(PRUint32 aFlags, nsAString &aStatusString);
   nsresult FetchSize(nsIMsgDBHdr * aHdr, nsAString & aSizeString);
   nsresult FetchPriority(nsIMsgDBHdr *aHdr, nsAString & aPriorityString);
   nsresult FetchLabel(nsIMsgDBHdr *aHdr, nsAString & aLabelString);
   nsresult FetchTags(nsIMsgDBHdr *aHdr, nsAString & aTagString);
   nsresult FetchKeywords(nsIMsgDBHdr *aHdr, nsACString & keywordString);
+  nsresult FetchRowKeywords(nsMsgViewIndex aRow, nsIMsgDBHdr *aHdr,
+                            nsACString & keywordString);
   nsresult FetchAccount(nsIMsgDBHdr * aHdr, nsAString& aAccount);
   nsresult CycleThreadedColumn(nsIDOMElement * aElement);
 
   // The default enumerator is over the db, but things like
   // quick search views will enumerate just the displayed messages.
   virtual nsresult GetMessageEnumerator(nsISimpleEnumerator **enumerator);
   // this is a message enumerator that enumerates based on the view contents
   virtual nsresult GetViewEnumerator(nsISimpleEnumerator **enumerator);