trunk version of fix for 231846 delete bug in threaded view, when switching from flat sort, sr=mscott

git-svn-id: svn://10.0.0.236/trunk@162599 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bienvenu%nventure.com
2004-09-21 15:07:07 +00:00
parent b2cb8007ce
commit e24e2ca787

View File

@@ -201,7 +201,9 @@ nsresult nsMsgThreadedDBView::SortThreads(nsMsgViewSortTypeValue sortType, nsMsg
m_viewFlags |= nsMsgViewFlagsType::kThreadedDisplay;
DisableChangeUpdates();
// Loop through the original array, for each thread that's expanded, find it in the new array
// and expand the thread.
// and expand the thread. We have to update MSG_VIEW_FLAG_HAS_CHILDREN because
// we may be going from a flat sort, which doesn't maintain that flag,
// to a threaded sort, which requires that flag.
for (PRUint32 j = 0; j < m_keys.GetSize(); j++)
{
PRUint32 flags = m_flags[j];
@@ -211,6 +213,25 @@ nsresult nsMsgThreadedDBView::SortThreads(nsMsgViewSortTypeValue sortType, nsMsg
m_flags[j] = flags | MSG_FLAG_ELIDED;
ExpandByIndex(j, &numExpanded);
j += numExpanded;
if (numExpanded > 0)
m_flags[j - numExpanded] = flags | MSG_VIEW_FLAG_HASCHILDREN;
}
else if (flags & MSG_VIEW_FLAG_ISTHREAD && ! (flags & MSG_VIEW_FLAG_HASCHILDREN))
{
nsCOMPtr <nsIMsgDBHdr> msgHdr;
nsCOMPtr <nsIMsgThread> pThread;
m_db->GetMsgHdrForKey(m_keys[j], getter_AddRefs(msgHdr));
if (msgHdr)
{
m_db->GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(pThread));
if (pThread)
{
PRUint32 numChildren;
pThread->GetNumChildren(&numChildren);
if (numChildren > 1)
m_flags[j] = flags | MSG_VIEW_FLAG_HASCHILDREN | MSG_FLAG_ELIDED;
}
}
}
}
EnableChangeUpdates();