зеркало из https://github.com/mozilla/pjs.git
fix undoing delete from virtual folder when unread is search criteria, sr=mscott 383743
This commit is contained in:
Родитель
034d0bb127
Коммит
1a1ac26705
|
@ -156,6 +156,7 @@ nsMsgDBView::nsMsgDBView()
|
|||
mCommandsNeedDisablingBecauseOfSelection = PR_FALSE;
|
||||
mRemovingRow = PR_FALSE;
|
||||
m_saveRestoreSelectionDepth = 0;
|
||||
mRecentlyDeletedArrayIndex = 0;
|
||||
// initialize any static atoms or unicode strings
|
||||
if (gInstanceCount == 0)
|
||||
{
|
||||
|
@ -1539,6 +1540,31 @@ NS_IMETHODIMP nsMsgDBView::GetCellValue(PRInt32 aRow, nsITreeColumn* aCol, nsASt
|
|||
return rv;
|
||||
}
|
||||
|
||||
void nsMsgDBView::RememberDeletedMsgHdr(nsIMsgDBHdr *msgHdr)
|
||||
{
|
||||
nsCString messageId;
|
||||
msgHdr->GetMessageId(getter_Copies(messageId));
|
||||
if (mRecentlyDeletedArrayIndex >= mRecentlyDeletedMsgIds.Count())
|
||||
mRecentlyDeletedMsgIds.AppendCString(messageId);
|
||||
else
|
||||
mRecentlyDeletedMsgIds.ReplaceCStringAt(messageId, mRecentlyDeletedArrayIndex);
|
||||
// only remember last 20 deleted msgs.
|
||||
mRecentlyDeletedArrayIndex = ++mRecentlyDeletedArrayIndex % 20;
|
||||
}
|
||||
|
||||
PRBool nsMsgDBView::WasHdrRecentlyDeleted(nsIMsgDBHdr *msgHdr)
|
||||
{
|
||||
nsCString messageId;
|
||||
msgHdr->GetMessageId(getter_Copies(messageId));
|
||||
PRInt32 arrayCount;
|
||||
for (PRInt32 i = 0; i < mRecentlyDeletedMsgIds.Count(); i++)
|
||||
{
|
||||
if (messageId.Equals(*(mRecentlyDeletedMsgIds[i])))
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
|
||||
}
|
||||
//add a custom column handler
|
||||
NS_IMETHODIMP nsMsgDBView::AddColumnHandler(const nsAString& column, nsIMsgCustomColumnHandler* handler)
|
||||
{
|
||||
|
|
|
@ -388,6 +388,16 @@ protected:
|
|||
|
||||
nsUInt32Array mIndicesToNoteChange;
|
||||
|
||||
// the saved search views keep track of the XX most recently deleted msg ids, so that if the
|
||||
// delete is undone, we can add the msg back to the search results, even if it no longer
|
||||
// matches the search criteria (e.g., a saved search over unread messages).
|
||||
// We use mRecentlyDeletedArrayIndex to treat the array as a list of the XX
|
||||
// most recently deleted msgs.
|
||||
nsCStringArray mRecentlyDeletedMsgIds;
|
||||
PRInt32 mRecentlyDeletedArrayIndex;
|
||||
void RememberDeletedMsgHdr(nsIMsgDBHdr *msgHdr);
|
||||
PRBool WasHdrRecentlyDeleted(nsIMsgDBHdr *msgHdr);
|
||||
|
||||
//these hold pointers (and IDs) for the nsIMsgCustomColumnHandler object that constitutes the custom column handler
|
||||
nsCOMArray <nsIMsgCustomColumnHandler> m_customColumnHandlers;
|
||||
nsStringArray m_customColumnHandlerIDs;
|
||||
|
|
|
@ -72,6 +72,19 @@ NS_IMETHODIMP nsMsgQuickSearchDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTy
|
|||
return InitThreadedView(pCount);
|
||||
}
|
||||
|
||||
nsresult nsMsgQuickSearchDBView::DeleteMessages(nsIMsgWindow *window, nsMsgViewIndex *indices, PRInt32 numIndices, PRBool deleteStorage)
|
||||
{
|
||||
for (nsMsgViewIndex i = 0; i < (nsMsgViewIndex) numIndices; i++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
(void) GetMsgHdrForViewIndex(indices[i],getter_AddRefs(msgHdr));
|
||||
if (msgHdr)
|
||||
RememberDeletedMsgHdr(msgHdr);
|
||||
}
|
||||
|
||||
return nsMsgDBView::DeleteMessages(window, indices, numIndices, deleteStorage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgQuickSearchDBView::DoCommand(nsMsgViewCommandTypeValue aCommand)
|
||||
{
|
||||
if (aCommand == nsMsgViewCommandType::markAllRead)
|
||||
|
|
|
@ -73,6 +73,7 @@ protected:
|
|||
PRBool m_cacheEmpty;
|
||||
nsCOMArray <nsIMsgDBHdr> m_hdrHits;
|
||||
virtual nsresult OnNewHeader(nsIMsgDBHdr *newHdr, nsMsgKey aParentKey, PRBool ensureListed);
|
||||
virtual nsresult DeleteMessages(nsIMsgWindow *window, nsMsgViewIndex *indices, PRInt32 numIndices, PRBool deleteStorage);
|
||||
virtual nsresult SortThreads(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
|
||||
virtual nsresult GetFirstMessageHdrToDisplayInThread(nsIMsgThread *threadHdr, nsIMsgDBHdr **result);
|
||||
virtual nsresult ExpansionDelta(nsMsgViewIndex index, PRInt32 *expansionDelta);
|
||||
|
|
|
@ -343,10 +343,21 @@ nsresult nsMsgSearchDBView::RemoveByIndex(nsMsgViewIndex index)
|
|||
|
||||
nsresult nsMsgSearchDBView::DeleteMessages(nsIMsgWindow *window, nsMsgViewIndex *indices, PRInt32 numIndices, PRBool deleteStorage)
|
||||
{
|
||||
nsresult rv;
|
||||
GetFoldersAndHdrsForSelection(indices, numIndices);
|
||||
if (mDeleteModel != nsMsgImapDeleteModels::MoveToTrash)
|
||||
deleteStorage = PR_TRUE;
|
||||
nsresult rv;
|
||||
GetFoldersAndHdrsForSelection(indices, numIndices);
|
||||
if (mDeleteModel != nsMsgImapDeleteModels::MoveToTrash)
|
||||
deleteStorage = PR_TRUE;
|
||||
|
||||
// remember the deleted messages in case the user undoes the delete,
|
||||
// and we want to restore the hdr to the view, even if it no
|
||||
// longer matches the search criteria.
|
||||
for (nsMsgViewIndex i = 0; i < (nsMsgViewIndex) numIndices; i++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgDBHdr> msgHdr;
|
||||
(void) GetMsgHdrForViewIndex(indices[i],getter_AddRefs(msgHdr));
|
||||
if (msgHdr)
|
||||
RememberDeletedMsgHdr(msgHdr);
|
||||
}
|
||||
if (!deleteStorage)
|
||||
rv = ProcessRequestsInOneFolder(window);
|
||||
else
|
||||
|
@ -499,7 +510,7 @@ nsMsgSearchDBView::OnStopCopy(nsresult aStatus)
|
|||
mCurIndex++;
|
||||
PRUint32 numFolders =0;
|
||||
rv = m_uniqueFoldersSelected->Count(&numFolders);
|
||||
if ( mCurIndex < numFolders)
|
||||
if ( mCurIndex < (PRUint32) numFolders)
|
||||
ProcessRequestsInOneFolder(mMsgWindow);
|
||||
}
|
||||
|
||||
|
|
|
@ -131,10 +131,12 @@ nsresult nsMsgXFVirtualFolderDBView::OnNewHeader(nsIMsgDBHdr *newHdr, nsMsgKey a
|
|||
{
|
||||
if (newHdr)
|
||||
{
|
||||
PRBool match=PR_FALSE;
|
||||
PRBool match = PR_FALSE;
|
||||
nsCOMPtr <nsIMsgSearchSession> searchSession = do_QueryReferent(m_searchSession);
|
||||
if (searchSession)
|
||||
searchSession->MatchHdr(newHdr, m_db, &match);
|
||||
if (!match)
|
||||
match = WasHdrRecentlyDeleted(newHdr);
|
||||
if (match)
|
||||
{
|
||||
nsCOMPtr <nsIMsgFolder> folder;
|
||||
|
|
Загрузка…
Ссылка в новой задаче