80897 r=mscott sr=bienvenu. speed up multiple deletes in thread-pane by notifying removal of rows in blocks

to outliner. Also move nsIMsgCopyServiceListener from nsMsgDBView to nsMsgSearchDBView.


git-svn-id: svn://10.0.0.236/trunk@111090 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
naving%netscape.com 2001-12-26 21:58:32 +00:00
parent cfeaaf6fac
commit 489fd1cd67
7 changed files with 80 additions and 47 deletions

View File

@ -293,6 +293,9 @@ interface nsIMsgDBView : nsISupports
//to tell us if we are in the search view
attribute boolean isSearchView;
//to notify outliner that rows are going away
void onDeleteCompleted(in boolean succeeded);
};
/* this interface is rapidly morphing from a command updater interface into a more generic

View File

@ -235,6 +235,7 @@ var folderObserver = {
function HandleDeleteOrMoveMsgFailed(folder)
{
gDBView.onDeleteCompleted(false);
if(IsCurrentLoadedFolder(folder)) {
if(gNextMessageAfterDelete) {
gNextMessageAfterDelete = null;
@ -248,6 +249,7 @@ function HandleDeleteOrMoveMsgFailed(folder)
function HandleDeleteOrMoveMsgCompleted(folder)
{
gDBView.onDeleteCompleted(true);
if (gNextMessageViewIndexAfterDelete != -2)
{
if (IsCurrentLoadedFolder(folder))

View File

@ -107,7 +107,6 @@ NS_INTERFACE_MAP_BEGIN(nsMsgDBView)
NS_INTERFACE_MAP_ENTRY(nsIMsgDBView)
NS_INTERFACE_MAP_ENTRY(nsIDBChangeListener)
NS_INTERFACE_MAP_ENTRY(nsIOutlinerView)
NS_INTERFACE_MAP_ENTRY(nsIMsgCopyServiceListener)
NS_INTERFACE_MAP_ENTRY(nsIMsgSearchNotify)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_END
@ -128,7 +127,7 @@ nsMsgDBView::nsMsgDBView()
mIsSpecialFolder = PR_FALSE;
mIsNews = PR_FALSE;
mDeleteModel = nsMsgImapDeleteModels::MoveToTrash;
m_deletingMsgs = PR_FALSE;
m_deletingRows = PR_FALSE;
mRemovingRow = PR_FALSE;
mIsSearchView = PR_FALSE;
// initialize any static atoms or unicode strings
@ -1856,8 +1855,8 @@ nsMsgDBView::CopyMessages(nsIMsgWindow *window, nsMsgViewIndex *indices, PRInt32
if (msgHdr)
messageArray->AppendElement(msgHdr);
}
m_deletingMsgs = isMove;
rv = destFolder->CopyMessages(m_folder /* source folder */, messageArray, isMove, window, this /* listener */, PR_FALSE /* isFolder */, PR_TRUE /*allowUndo*/);
m_deletingRows = isMove && mDeleteModel != nsMsgImapDeleteModels::IMAPDelete;
rv = destFolder->CopyMessages(m_folder /* source folder */, messageArray, isMove, window, nsnull /* listener */, PR_FALSE /* isFolder */, PR_TRUE /*allowUndo*/);
return rv;
}
@ -1997,11 +1996,13 @@ nsresult nsMsgDBView::RemoveByIndex(nsMsgViewIndex index)
{
if (!IsValidIndex(index))
return NS_MSG_INVALID_DBVIEW_INDEX;
m_keys.RemoveAt(index);
m_flags.RemoveAt(index);
m_levels.RemoveAt(index);
NoteChange(index, -1, nsMsgViewNotificationCode::insertOrDelete);
if (!m_deletingRows)
NoteChange(index, -1, nsMsgViewNotificationCode::insertOrDelete); // an example where view is not the listener - D&D messages
return NS_OK;
}
@ -2020,8 +2021,9 @@ nsresult nsMsgDBView::DeleteMessages(nsIMsgWindow *window, nsMsgViewIndex *indic
messageArray->AppendElement(msgHdr);
}
m_deletingMsgs = PR_TRUE;
m_folder->DeleteMessages(messageArray, window, deleteStorage, PR_FALSE, this, PR_TRUE /*allow Undo*/ );
if (mDeleteModel != nsMsgImapDeleteModels::IMAPDelete)
m_deletingRows = PR_TRUE;
m_folder->DeleteMessages(messageArray, window, deleteStorage, PR_FALSE, nsnull, PR_TRUE /*allow Undo*/ );
return rv;
}
@ -4806,40 +4808,41 @@ nsMsgDBView::GetURIForFirstSelectedMessage(char **uri)
return NS_OK;
}
// nsIMsgCopyServiceListener methods
NS_IMETHODIMP
nsMsgDBView::OnStartCopy()
nsMsgDBView::OnDeleteCompleted(PRBool aSucceeded)
{
return NS_OK;
}
if (m_deletingRows)
{
if (aSucceeded)
{
PRInt32 selectionCount;
//selection count cannot be zero, we would not be here
mOutlinerSelection->GetRangeCount(&selectionCount);
NS_ASSERTION(selectionCount, "selected indices for deletion is 0");
PRInt32 *startRangeArray = (PRInt32*) PR_MALLOC(selectionCount* sizeof(PRInt32));
PRInt32 *endRangeArray = (PRInt32*) PR_MALLOC(selectionCount* sizeof(PRInt32));
PRInt32 i;
for (i=0; i<selectionCount; i++)
mOutlinerSelection->GetRangeAt(i, &startRangeArray[i], &endRangeArray[i]);
NS_IMETHODIMP
nsMsgDBView::OnProgress(PRUint32 aProgress, PRUint32 aProgressMax)
{
return NS_OK;
}
PRInt32 delta=0; //keeps no of rows deleted.
for (i=0; i<selectionCount; i++)
{
startRangeArray[i] -=delta;
endRangeArray[i] -= delta;
PRInt32 numRows = endRangeArray[i]-startRangeArray[i]+1;
delta += numRows;
NoteChange(startRangeArray[i], -1*numRows, nsMsgViewNotificationCode::insertOrDelete);
}
PR_FREEIF(startRangeArray);
PR_FREEIF(endRangeArray);
}
}
// believe it or not, these next two are msgcopyservice listener methods!
NS_IMETHODIMP
nsMsgDBView::SetMessageKey(PRUint32 aMessageKey)
{
return NS_OK;
}
m_deletingRows = PR_FALSE;
return NS_OK;
NS_IMETHODIMP
nsMsgDBView::GetMessageId(nsCString* aMessageId)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgDBView::OnStopCopy(nsresult aStatus)
{
m_deletingMsgs = PR_FALSE;
m_removedIndices.RemoveAll();
return NS_OK;
}
// end nsIMsgCopyServiceListener methods
PRBool nsMsgDBView::OfflineMsgSelected(nsMsgViewIndex * indices, PRInt32 numIndices)
{

View File

@ -87,7 +87,7 @@ enum eFieldType {
// I think this will be an abstract implementation class.
// The classes that implement the outliner support will probably
// inherit from this class.
class nsMsgDBView : public nsIMsgDBView, public nsIDBChangeListener, public nsIOutlinerView, public nsIMsgCopyServiceListener, public nsIMsgSearchNotify, public nsIObserver
class nsMsgDBView : public nsIMsgDBView, public nsIDBChangeListener, public nsIOutlinerView, public nsIMsgSearchNotify, public nsIObserver
{
public:
nsMsgDBView();
@ -97,7 +97,6 @@ public:
NS_DECL_NSIMSGDBVIEW
NS_DECL_NSIDBCHANGELISTENER
NS_DECL_NSIOUTLINERVIEW
NS_DECL_NSIMSGCOPYSERVICELISTENER
NS_DECL_NSIMSGSEARCHNOTIFY
NS_DECL_NSIOBSERVER
@ -313,10 +312,8 @@ protected:
nsMsgKey m_currentlyDisplayedMsgKey;
// if we're deleting messages, we want to hold off loading messages on selection changed until the delete is done
// and we want to batch notifications.
PRBool m_deletingMsgs;
// used for batching deletes
nsUInt32Array m_removedIndices;
PRBool m_deletingRows;
nsCOMPtr <nsIMsgFolder> m_folder;
PRBool mIsSpecialFolder; // for special folders, the Sender column really shows recipients.
PRBool mIsNews; // we have special icons for news, and for news, we show lines instead of size

View File

@ -44,6 +44,7 @@ nsresult createNode(const PRUnichar *str, nsIRDFNode **node, nsIRDFService *rdfS
{
nsresult rv;
nsCOMPtr<nsIRDFLiteral> value;
NS_ASSERTION(rdfService, "rdfService is null");
if (!rdfService) return NS_OK;

View File

@ -61,7 +61,7 @@ nsMsgSearchDBView::~nsMsgSearchDBView()
/* destructor code */
}
NS_IMPL_ISUPPORTS_INHERITED1(nsMsgSearchDBView, nsMsgDBView, nsIMsgDBView)
NS_IMPL_ISUPPORTS_INHERITED2(nsMsgSearchDBView, nsMsgDBView, nsIMsgDBView, nsIMsgCopyServiceListener)
NS_IMETHODIMP nsMsgSearchDBView::Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder, nsMsgViewFlagsTypeValue viewFlags, PRInt32 *pCount)
{
@ -352,6 +352,33 @@ nsMsgSearchDBView::InitializeGlobalsForDeleteAndFile(nsMsgViewIndex *indices, PR
}
// nsIMsgCopyServiceListener methods
NS_IMETHODIMP
nsMsgSearchDBView::OnStartCopy()
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchDBView::OnProgress(PRUint32 aProgress, PRUint32 aProgressMax)
{
return NS_OK;
}
// believe it or not, these next two are msgcopyservice listener methods!
NS_IMETHODIMP
nsMsgSearchDBView::SetMessageKey(PRUint32 aMessageKey)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchDBView::GetMessageId(nsCString* aMessageId)
{
return NS_OK;
}
NS_IMETHODIMP
nsMsgSearchDBView::OnStopCopy(nsresult aStatus)
@ -370,6 +397,8 @@ nsMsgSearchDBView::OnStopCopy(nsresult aStatus)
return rv;
}
// end nsIMsgCopyServiceListener methods
nsresult nsMsgSearchDBView::ProcessRequestsInOneFolder(nsIMsgWindow *window)
{
nsresult rv = NS_OK;

View File

@ -41,7 +41,7 @@
#include "nsMsgDBView.h"
#include "nsIMsgCopyServiceListener.h"
class nsMsgSearchDBView : public nsMsgDBView
class nsMsgSearchDBView : public nsMsgDBView, public nsIMsgCopyServiceListener
{
public:
nsMsgSearchDBView();
@ -49,6 +49,7 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMSGSEARCHNOTIFY
NS_DECL_NSIMSGCOPYSERVICELISTENER
virtual const char * GetViewName(void) {return "SearchView"; }
NS_IMETHOD Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder,
@ -64,9 +65,6 @@ public:
virtual nsresult OnNewHeader(nsMsgKey newKey, nsMsgKey parentKey, PRBool ensureListed);
NS_IMETHOD GetFolderForViewIndex(nsMsgViewIndex index, nsIMsgFolder **folder);
// override to chain move/copies from next folder in search results
NS_IMETHOD OnStopCopy(nsresult aStatus);
virtual nsresult GetFolders(nsISupportsArray **aFolders);
protected:
nsresult FetchLocation(PRInt32 aRow, PRUnichar ** aLocationString);