From 873cb1f58ab1db855980fbbdd6e89f62ae14336e Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Mon, 2 Apr 2001 07:22:27 +0000 Subject: [PATCH] fix #74354. the icon in the thread column should have the green arrow if the thread has any unread messages fix #72281. if new message arrive and they are children of a collapsed thread, they should not become the king of the thread. sr=bienvenu --- mailnews/base/src/nsMsgDBView.cpp | 47 ++++++++++----------- mailnews/base/src/nsMsgDBView.h | 3 +- mailnews/base/src/nsMsgThreadedDBView.cpp | 11 ++--- themes/classic/messenger/mac/threadPane.css | 4 +- themes/classic/messenger/win/threadPane.css | 4 +- themes/modern/messenger/threadPane.css | 4 +- 6 files changed, 33 insertions(+), 40 deletions(-) diff --git a/mailnews/base/src/nsMsgDBView.cpp b/mailnews/base/src/nsMsgDBView.cpp index a332b5e7766..5d75492126d 100644 --- a/mailnews/base/src/nsMsgDBView.cpp +++ b/mailnews/base/src/nsMsgDBView.cpp @@ -58,6 +58,7 @@ nsIAtom * nsMsgDBView::kFlaggedMsgAtom = nsnull; nsIAtom * nsMsgDBView::kNewsMsgAtom = nsnull; nsIAtom * nsMsgDBView::kImapDeletedMsgAtom = nsnull; nsIAtom * nsMsgDBView::kAttachMsgAtom = nsnull; +nsIAtom * nsMsgDBView::kHasUnreadAtom = nsnull; PRUnichar * nsMsgDBView::kHighestPriorityString = nsnull; PRUnichar * nsMsgDBView::kHighPriorityString = nsnull; @@ -110,6 +111,7 @@ void nsMsgDBView::InitializeAtomsAndLiterals() kNewsMsgAtom = NS_NewAtom("news"); kImapDeletedMsgAtom = NS_NewAtom("imapdeleted"); kAttachMsgAtom = NS_NewAtom("attach"); + kHasUnreadAtom = NS_NewAtom("hasUnread"); kHighestPriorityAtom = NS_NewAtom("priority-highest"); kHighPriorityAtom = NS_NewAtom("priority-high"); @@ -143,6 +145,7 @@ nsMsgDBView::~nsMsgDBView() NS_IF_RELEASE(kNewsMsgAtom); NS_IF_RELEASE(kImapDeletedMsgAtom); NS_IF_RELEASE(kAttachMsgAtom); + NS_IF_RELEASE(kHasUnreadAtom); NS_IF_RELEASE(kHighestPriorityAtom); NS_IF_RELEASE(kHighPriorityAtom); @@ -746,7 +749,25 @@ NS_IMETHODIMP nsMsgDBView::GetCellProperties(PRInt32 aRow, const PRUnichar *colI properties->AppendElement(kFlaggedMsgAtom); } } - + + if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) + { + if (m_flags[aRow] & MSG_VIEW_FLAG_ISTHREAD) + { + nsCOMPtr thread; + rv = GetThreadContainingIndex(aRow, getter_AddRefs(thread)); + if (NS_SUCCEEDED(rv) && thread) + { + PRUint32 numUnreadChildren; + thread->GetNumUnreadChildren(&numUnreadChildren); + if (numUnreadChildren > 0) + { + properties->AppendElement(kHasUnreadAtom); + } + } + } + } + return NS_OK; } @@ -3101,30 +3122,6 @@ nsresult nsMsgDBView::AddHdr(nsIMsgDBHdr *msgHdr) return NS_OK; } -nsresult nsMsgDBView::InsertHdrAt(nsIMsgDBHdr *msgHdr, nsMsgViewIndex insertIndex) -{ - PRUint32 flags = 0; - nsMsgKey msgKey; - msgHdr->GetFlags(&flags); - msgHdr->GetMessageKey(&msgKey); - - NoteStartChange(insertIndex, 1, nsMsgViewNotificationCode::changed); - m_keys.SetAt(insertIndex, msgKey); - m_flags.SetAt(insertIndex, flags); - PRInt32 level = 0; -#if 0 - if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) - { - level = FindLevelInThread(msgHdr, insertIndex); - } -#endif - m_levels.SetAt(insertIndex, level); - NoteEndChange(insertIndex, 1, nsMsgViewNotificationCode::changed); - OnHeaderAddedOrDeleted(); - return NS_OK; -} - - PRBool nsMsgDBView::WantsThisThread(nsIMsgThread * /*threadHdr*/) { return PR_TRUE; // default is to want all threads. diff --git a/mailnews/base/src/nsMsgDBView.h b/mailnews/base/src/nsMsgDBView.h index 47a124d3d30..bd8bf4db52a 100644 --- a/mailnews/base/src/nsMsgDBView.h +++ b/mailnews/base/src/nsMsgDBView.h @@ -81,6 +81,7 @@ protected: static nsIAtom* kNewsMsgAtom; static nsIAtom* kImapDeletedMsgAtom; static nsIAtom* kAttachMsgAtom; + static nsIAtom* kHasUnreadAtom; static nsIAtom* kHighestPriorityAtom; static nsIAtom* kHighPriorityAtom; @@ -145,8 +146,6 @@ protected: virtual nsresult GetThreadContainingIndex(nsMsgViewIndex index, nsIMsgThread **thread); virtual nsresult GetMsgHdrForViewIndex(nsMsgViewIndex index, nsIMsgDBHdr **msgHdr); - virtual nsresult InsertHdrAt(nsIMsgDBHdr *msgHdr, nsMsgViewIndex insertIndex); - nsresult ToggleExpansion(nsMsgViewIndex index, PRUint32 *numChanged); nsresult ExpandByIndex(nsMsgViewIndex index, PRUint32 *pNumExpanded); nsresult CollapseByIndex(nsMsgViewIndex index, PRUint32 *pNumCollapsed); diff --git a/mailnews/base/src/nsMsgThreadedDBView.cpp b/mailnews/base/src/nsMsgThreadedDBView.cpp index a81264db2c1..7154e8102ec 100644 --- a/mailnews/base/src/nsMsgThreadedDBView.cpp +++ b/mailnews/base/src/nsMsgThreadedDBView.cpp @@ -438,8 +438,9 @@ nsresult nsMsgThreadedDBView::OnNewHeader(nsMsgKey newKey, nsMsgKey aParentKey, PRUint32 flags = m_flags[threadIndex]; // if we have a collapsed thread which just got a new // top of thread, change the keys array. - char level = 0; // ### TODO - if ((flags & MSG_FLAG_ELIDED) && level == 0 + nsMsgViewIndex insertIndex = GetInsertIndex(msgHdr); + PRInt32 level = FindLevelInThread(msgHdr, insertIndex); + if ((flags & MSG_FLAG_ELIDED) && (level == 0) && (!(m_viewFlags & nsMsgViewFlagsType::kUnreadOnly) || !(msgFlags & MSG_FLAG_READ))) { nsMsgKey msgKey; @@ -457,12 +458,8 @@ nsresult nsMsgThreadedDBView::OnNewHeader(nsMsgKey newKey, nsMsgKey aParentKey, } if (! (flags & MSG_FLAG_ELIDED)) // thread is expanded { // insert child into thread - PRUint8 level = 0; // levels of other hdrs may have changed! + // levels of other hdrs may have changed! PRUint32 newFlags = msgFlags; - nsMsgViewIndex insertIndex = 0; -#if 0 - insertIndex = GetInsertInfoForNewHdr(newKey, threadIndex, &level); -#endif // this header is the new king! try collapsing the existing thread, // removing it, installing this header as king, and expanding it. if (level == 0) diff --git a/themes/classic/messenger/mac/threadPane.css b/themes/classic/messenger/mac/threadPane.css index 135e92ce696..0e546818c14 100644 --- a/themes/classic/messenger/mac/threadPane.css +++ b/themes/classic/messenger/mac/threadPane.css @@ -99,11 +99,11 @@ outlinerbody:-moz-outliner-image(threadCol, container, open) { list-style-image: url("chrome://messenger/skin/thread-open.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread) { list-style-image: url("chrome://messenger/skin/thread-new-closed.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread, open) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread, open) { list-style-image: url("chrome://messenger/skin/thread-new-open.gif"); } diff --git a/themes/classic/messenger/win/threadPane.css b/themes/classic/messenger/win/threadPane.css index 135e92ce696..0e546818c14 100644 --- a/themes/classic/messenger/win/threadPane.css +++ b/themes/classic/messenger/win/threadPane.css @@ -99,11 +99,11 @@ outlinerbody:-moz-outliner-image(threadCol, container, open) { list-style-image: url("chrome://messenger/skin/thread-open.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread) { list-style-image: url("chrome://messenger/skin/thread-new-closed.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread, open) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread, open) { list-style-image: url("chrome://messenger/skin/thread-new-open.gif"); } diff --git a/themes/modern/messenger/threadPane.css b/themes/modern/messenger/threadPane.css index 060d66aea7b..09e6fdbbd94 100644 --- a/themes/modern/messenger/threadPane.css +++ b/themes/modern/messenger/threadPane.css @@ -99,11 +99,11 @@ outlinerbody:-moz-outliner-image(threadCol, container, open) { list-style-image: url("chrome://messenger/skin/icons/thread-open.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread) { list-style-image: url("chrome://messenger/skin/icons/thread-new-closed.gif"); } -outlinerbody:-moz-outliner-image(threadCol, container, unread, open) { +outlinerbody:-moz-outliner-image(threadCol, container, hasUnread, open) { list-style-image: url("chrome://messenger/skin/icons/thread-new-open.gif"); }