fix 308737 sort within non date group should be by date, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2005-09-16 15:04:09 +00:00
Родитель 6a0134967f
Коммит f0851a6ce7
3 изменённых файлов: 14 добавлений и 11 удалений

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

@ -4218,7 +4218,7 @@ nsMsgViewIndex nsMsgDBView::GetIndexForThread(nsIMsgDBHdr *hdr)
} }
nsMsgViewIndex nsMsgDBView::GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyArray *keys, nsMsgViewIndex nsMsgDBView::GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyArray *keys,
nsMsgViewSortOrderValue sortOrder) nsMsgViewSortOrderValue sortOrder, nsMsgViewSortTypeValue sortType)
{ {
nsMsgViewIndex highIndex = keys->GetSize(); nsMsgViewIndex highIndex = keys->GetSize();
nsMsgViewIndex lowIndex = 0; nsMsgViewIndex lowIndex = 0;
@ -4230,7 +4230,7 @@ nsMsgViewIndex nsMsgDBView::GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyAr
nsresult rv; nsresult rv;
PRUint16 maxLen; PRUint16 maxLen;
eFieldType fieldType; eFieldType fieldType;
rv = GetFieldTypeAndLenForSort(m_sortType, &maxLen, &fieldType); rv = GetFieldTypeAndLenForSort(sortType, &maxLen, &fieldType);
const void *pValue1 = &EntryInfo1, *pValue2 = &EntryInfo2; const void *pValue1 = &EntryInfo1, *pValue2 = &EntryInfo2;
int (* PR_CALLBACK comparisonFun) (const void *pItem1, const void *pItem2, void *privateData)=nsnull; int (* PR_CALLBACK comparisonFun) (const void *pItem1, const void *pItem2, void *privateData)=nsnull;
@ -4239,17 +4239,17 @@ nsMsgViewIndex nsMsgDBView::GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyAr
switch (fieldType) switch (fieldType)
{ {
case kCollationKey: case kCollationKey:
rv = GetCollationKey(msgHdr, m_sortType, &EntryInfo1.key, &EntryInfo1.dword); rv = GetCollationKey(msgHdr, sortType, &EntryInfo1.key, &EntryInfo1.dword);
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create collation key"); NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create collation key");
comparisonFun = FnSortIdKeyPtr; comparisonFun = FnSortIdKeyPtr;
comparisonContext = m_db.get(); comparisonContext = m_db.get();
break; break;
case kU32: case kU32:
if (m_sortType == nsMsgViewSortType::byId) { if (sortType == nsMsgViewSortType::byId) {
EntryInfo1.dword = EntryInfo1.id; EntryInfo1.dword = EntryInfo1.id;
} }
else { else {
GetLongField(msgHdr, m_sortType, &EntryInfo1.dword); GetLongField(msgHdr, sortType, &EntryInfo1.dword);
} }
comparisonFun = FnSortIdDWord; comparisonFun = FnSortIdDWord;
break; break;
@ -4267,16 +4267,16 @@ nsMsgViewIndex nsMsgDBView::GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyAr
if (fieldType == kCollationKey) if (fieldType == kCollationKey)
{ {
PR_FREEIF(EntryInfo2.key); PR_FREEIF(EntryInfo2.key);
rv = GetCollationKey(tryHdr, m_sortType, &EntryInfo2.key, &EntryInfo2.dword); rv = GetCollationKey(tryHdr, sortType, &EntryInfo2.key, &EntryInfo2.dword);
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create collation key"); NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create collation key");
} }
else if (fieldType == kU32) else if (fieldType == kU32)
{ {
if (m_sortType == nsMsgViewSortType::byId) { if (sortType == nsMsgViewSortType::byId) {
EntryInfo2.dword = EntryInfo2.id; EntryInfo2.dword = EntryInfo2.id;
} }
else { else {
GetLongField(tryHdr, m_sortType, &EntryInfo2.dword); GetLongField(tryHdr, sortType, &EntryInfo2.dword);
} }
} }
retStatus = (*comparisonFun)(&pValue1, &pValue2, comparisonContext); retStatus = (*comparisonFun)(&pValue1, &pValue2, comparisonContext);
@ -4313,7 +4313,7 @@ nsMsgViewIndex nsMsgDBView::GetInsertIndex(nsIMsgDBHdr *msgHdr)
&& m_sortOrder != nsMsgViewSortType::byId) && m_sortOrder != nsMsgViewSortType::byId)
return GetIndexForThread(msgHdr); return GetIndexForThread(msgHdr);
return GetInsertIndexHelper(msgHdr, &m_keys, m_sortOrder); return GetInsertIndexHelper(msgHdr, &m_keys, m_sortOrder, m_sortType);
} }
nsresult nsMsgDBView::AddHdr(nsIMsgDBHdr *msgHdr) nsresult nsMsgDBView::AddHdr(nsIMsgDBHdr *msgHdr)

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

@ -105,7 +105,8 @@ public:
NS_DECL_NSIJUNKMAILCLASSIFICATIONLISTENER NS_DECL_NSIJUNKMAILCLASSIFICATIONLISTENER
nsMsgViewIndex GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyArray *keys, nsMsgViewIndex GetInsertIndexHelper(nsIMsgDBHdr *msgHdr, nsMsgKeyArray *keys,
nsMsgViewSortOrderValue sortOrder); nsMsgViewSortOrderValue sortOrder,
nsMsgViewSortTypeValue sortType);
protected: protected:
static nsrefcnt gInstanceCount; static nsrefcnt gInstanceCount;
// atoms used for styling the view. we're going to have a lot of // atoms used for styling the view. we're going to have a lot of

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

@ -188,7 +188,9 @@ nsresult nsMsgGroupThread::AddMsgHdrInDateOrder(nsIMsgDBHdr *child, nsMsgDBView
&& sortOrder == nsMsgViewSortOrder::descending) ? && sortOrder == nsMsgViewSortOrder::descending) ?
nsMsgViewSortOrder::descending : nsMsgViewSortOrder::ascending; nsMsgViewSortOrder::descending : nsMsgViewSortOrder::ascending;
insertIndex = view->GetInsertIndexHelper(child, &m_keys, threadSortOrder); // this actually sorts by the current grouping, so if we're grouped by
// subject, it tries to sort by subject. We don't want that...
insertIndex = view->GetInsertIndexHelper(child, &m_keys, threadSortOrder, nsMsgViewSortType::byDate);
} }
m_keys.InsertAt(insertIndex, newHdrKey); m_keys.InsertAt(insertIndex, newHdrKey);
if (!insertIndex) if (!insertIndex)